| java.lang.Object org.cougaar.lib.aggagent.util.XmlUtils
XmlUtils | public class XmlUtils (Code) | | The XmlUtils class is the home of a suite of static convenience methods for
handling XML documents. Support for parsing, traversing, and generating
these documents may be found here.
|
Field Summary | |
public static boolean | debug when debug is set to true, all XML is printed to standard out before it
is parsed. |
Method Summary | |
public static Element | getChildElement(Element elt, String tag) Search for an Element of the given name that is a child of the specified
Element. | public static int | getChildInt(Element elt, String tag) This convenience method searches for a child Element and attempts to
parse its content text as an integer. | public static String | getChildText(Element elt, String tag) This convenience method extracts the text content of a child Element
whose name is specified by the caller. | public static String | getElementText(Element elt) This convenience method extracts the text content of an XML element
(including white spaces). | public static Element | parse(String s) Parse an XML document and return the "document element", which is the
root of the XML structure as specified in the text of the document. | public static Element | parse(InputStream s) Parse an XML document and return the "document element", which is the
root of the XML structure as specified in the text of the document. | public static Element | parse(InputSource in) Parse an XML document and return the "document element", which is the
root of the XML structure as specified in the text of the document. | public static String | readToString(InputStream is) | public static String | requestString(String urlString, String request) Post request to URL represented by passed string. | public static Element | requestXML(String urlString, String request) Post request to URL represented by passed string. | public static InputStream | sendRequest(String urlString, String request) Post request to URL represented by passed string. |
debug | public static boolean debug(Code) | | when debug is set to true, all XML is printed to standard out before it
is parsed.
|
getChildElement | public static Element getChildElement(Element elt, String tag)(Code) | | Search for an Element of the given name that is a child of the specified
Element. If any such Elements exist, the first is returned; otherwise,
the method returns null. Note: the search will return only direct
children, as opposed to higher-order descendants (e.g., grandchildren).
|
getChildInt | public static int getChildInt(Element elt, String tag) throws NumberFormatException(Code) | | This convenience method searches for a child Element and attempts to
parse its content text as an integer. An Exception will be raised if
no such Element exists, or else one exists, but its contents cannot be
intrepreted as an integer. If the Element has more than one child with
the given name, then the first one is used (even if the contents are
invalid).
|
getChildText | public static String getChildText(Element elt, String tag)(Code) | | This convenience method extracts the text content of a child Element
whose name is specified by the caller. Assuming such an Element exists,
its contents are handled as in getElementText (q.v.). If there are many
child Elements matching the description, the first one is used. If there
are no such Elements, then this method returns null.
|
getElementText | public static String getElementText(Element elt)(Code) | | This convenience method extracts the text content of an XML element
(including white spaces). If the Element has child Elements, they are
ignored, and the intervening Text nodes are concatenated into the result.
This method will return null if and only if it is passed a null Element.
|
parse | public static Element parse(String s) throws IOException, SAXException(Code) | | Parse an XML document and return the "document element", which is the
root of the XML structure as specified in the text of the document. For
this method, the text must come from a String.
|
parse | public static Element parse(InputStream s) throws IOException, SAXException(Code) | | Parse an XML document and return the "document element", which is the
root of the XML structure as specified in the text of the document. For
this method, the text must come from an InputStream.
|
parse | public static Element parse(InputSource in) throws IOException, SAXException(Code) | | Parse an XML document and return the "document element", which is the
root of the XML structure as specified in the text of the document. By
and large, this method will be called by other parse methods after
converting the source of the XML text into an InputSource.
|
requestString | public static String requestString(String urlString, String request)(Code) | | Post request to URL represented by passed string. Return response as
string. Currently just catches exceptions and prints message to
standard out (returning null).
|
requestXML | public static Element requestXML(String urlString, String request)(Code) | | Post request to URL represented by passed string. Return parsed XML
response. Currently just catches exceptions and prints message to
standard out (returning null).
|
|
|