| java.lang.Object org.geoserver.util.ReaderUtils
ReaderUtils | public class ReaderUtils (Code) | | ReaderUtils purpose.
This class is intended to be used as a library of XML relevant operation for
the XMLConfigReader class.
author: dzwiers, Refractions Research, Inc. version: $Id: ReaderUtils.java 7958 2007-12-06 16:25:43Z arneke $ See Also: XMLConfigReader |
Method Summary | |
public static File | checkFile(File file, boolean isDir) Checks to ensure the file is valid.
Returns the file passed in to allow this to wrap file creations.
Parameters: file - A file Handle to test. Parameters: isDir - true when the File passed in is expected to be a directory,false when the handle is expected to be a file. | public static String | getAttribute(Element elem, String attName, boolean mandatory) getIntAttribute purpose.
Used to help with XML manipulations. | public static boolean | getBooleanAttribute(Element elem, String attName, boolean mandatory, boolean defaultValue) getBooleanAttribute purpose.
Used to help with XML manipulations. | public static Element | getChildElement(Element root, String name, boolean mandatory) getChildElement purpose.
Used to help with XML manipulations. | public static Element | getChildElement(Element root, String name) getChildElement purpose.
Used to help with XML manipulations. | public static Element[] | getChildElements(Element root, String name) getChildElements purpose.
Used to help with XML manipulations. | public static Element[] | getChildElements(Element root, String name, boolean mandatory) getChildElements purpose.
Used to help with XML manipulations. | public static String | getChildText(Element root, String childName) getChildText purpose.
Used to help with XML manipulations. | public static String | getChildText(Element root, String childName, boolean mandatory) getChildText purpose.
Used to help with XML manipulations. | public static double | getDoubleAttribute(Element elem, String attName, boolean mandatory) getDoubleAttribute purpose.
Used to help with XML manipulations. | public static String | getElementText(Element elem) getChildText purpose.
Used to help with XML manipulations. | public static String | getElementText(Element elem, boolean mandatory) getChildText purpose.
Used to help with XML manipulations. | public static Element | getFirstChildElement(Element root) getFirstChildElement purpose.
Used to help with XML manipulations. | public static int | getIntAttribute(Element elem, String attName, boolean mandatory, int defaultValue) getIntAttribute purpose.
Used to help with XML manipulations. | public static List | getKeyWords(Element keywordsElem) getKeyWords purpose.
Used to help with XML manipulations. | public static Element | parse(Reader xml) Parses the specified reader into a DOM tree.
Parameters: xml - Reader representing xml stream to parse. | public static void | validate(Document xml, DefaultHandler errorHandler, String targetNamespace, String schemaLocation) Validates an xml document against a specified schema.
Parameters: xml - The document. Parameters: errorHandler - The validation error handler. | public static void | validate(Reader xml, DefaultHandler errorHandler, String targetNamespace, String schemaLocation) Validates an xml document against a specified schema.
Parameters: xml - Reader representing xml stream to parse. Parameters: errorHandler - The validation error handler. |
checkFile | public static File checkFile(File file, boolean isDir) throws FileNotFoundException(Code) | | Checks to ensure the file is valid.
Returns the file passed in to allow this to wrap file creations.
Parameters: file - A file Handle to test. Parameters: isDir - true when the File passed in is expected to be a directory,false when the handle is expected to be a file. the File handle passed in throws: Exception - When the file does not exist or is notthe type specified. |
getAttribute | public static String getAttribute(Element elem, String attName, boolean mandatory) throws Exception(Code) | | getIntAttribute purpose.
Used to help with XML manipulations. Returns the first child integer
attribute of the specified name. An exception occurs when the node is
required and not found.
Parameters: elem - The root element to look for children in. Parameters: attName - The name of the attribute to look for. Parameters: mandatory - true when an exception should be thrown if theattribute element does not exist. The value if the attribute was found, the null otherwise. throws: Exception - When a child attribute is required andnot found. throws: NullPointerException - DOCUMENT ME! |
getBooleanAttribute | public static boolean getBooleanAttribute(Element elem, String attName, boolean mandatory, boolean defaultValue) throws Exception(Code) | | getBooleanAttribute purpose.
Used to help with XML manipulations. Returns the first child integer
attribute of the specified name. An exception occurs when the node is
required and not found.
Parameters: elem - The root element to look for children in. Parameters: attName - The name of the attribute to look for. Parameters: mandatory - true when an exception should be thrown if theattribute element does not exist. Parameters: defaultValue - what to return for a non-mandatory that is notfound. The value if the attribute was found, the false otherwise. throws: Exception - When a child attribute is required andnot found. |
getChildElement | public static Element getChildElement(Element root, String name, boolean mandatory) throws Exception(Code) | | getChildElement purpose.
Used to help with XML manipulations. Returns the first child element of
the specified name. An exception occurs when the node is required and
not found.
Parameters: root - The root element to look for children in. Parameters: name - The name of the child element to look for. Parameters: mandatory - true when an exception should be thrown if the childelement does not exist. The child element found, null if not found. throws: Exception - When a child element is required and notfound. |
getChildElement | public static Element getChildElement(Element root, String name)(Code) | | getChildElement purpose.
Used to help with XML manipulations. Returns the first child element of
the specified name.
Parameters: root - The root element to look for children in. Parameters: name - The name of the child element to look for. The child element found, null if not found. See Also: getChildElement(Element,String,boolean) |
getChildElements | public static Element[] getChildElements(Element root, String name)(Code) | | getChildElements purpose.
Used to help with XML manipulations. Returns *all* child elements of
the specified name.
Parameters: root - The root element to look for children in. Parameters: name - The name of the child element to look for. The child element found, null if not found. See Also: getChildElement(Element,String,boolean) |
getChildElements | public static Element[] getChildElements(Element root, String name, boolean mandatory) throws Exception(Code) | | getChildElements purpose.
Used to help with XML manipulations. Returns *all* child elements of
the specified name. An exception occurs when the node is required and
not found.
Parameters: root - The root element to look for children in. Parameters: name - The name of the child element to look for. Parameters: mandatory - true when an exception should be thrown if the childelement does not exist. The child element found, null if not found. throws: Exception - When a child element is required and notfound. |
getChildText | public static String getChildText(Element root, String childName)(Code) | | getChildText purpose.
Used to help with XML manipulations. Returns the first child text value
of the specified element name.
Parameters: root - The root element to look for children in. Parameters: childName - The name of the attribute to look for. The value if the child was found, the null otherwise. |
getChildText | public static String getChildText(Element root, String childName, boolean mandatory) throws Exception(Code) | | getChildText purpose.
Used to help with XML manipulations. Returns the first child text value
of the specified element name. An exception occurs when the node is
required and not found.
Parameters: root - The root element to look for children in. Parameters: childName - The name of the attribute to look for. Parameters: mandatory - true when an exception should be thrown if the textdoes not exist. The value if the child was found, the null otherwise. throws: Exception - When a child attribute is required andnot found. |
getDoubleAttribute | public static double getDoubleAttribute(Element elem, String attName, boolean mandatory) throws Exception(Code) | | getDoubleAttribute purpose.
Used to help with XML manipulations. Returns the first child integer
attribute of the specified name. An exception occurs when the node is
required and not found.
Parameters: elem - The root element to look for children in. Parameters: attName - The name of the attribute to look for. Parameters: mandatory - true when an exception should be thrown if theattribute element does not exist. The double value if the attribute was found, the NaN otherwise. throws: Exception - When a attribute element is required andnot found. |
getElementText | public static String getElementText(Element elem)(Code) | | getChildText purpose.
Used to help with XML manipulations. Returns the text value of the
specified element name.
Parameters: elem - The root element to look for children in. The value if the text was found, the null otherwise. |
getElementText | public static String getElementText(Element elem, boolean mandatory) throws Exception(Code) | | getChildText purpose.
Used to help with XML manipulations. Returns the text value of the
specified element name. An exception occurs when the node is required
and not found.
Parameters: elem - The root element to look for children in. Parameters: mandatory - true when an exception should be thrown if the textdoes not exist. The value if the text was found, the null otherwise. throws: Exception - When text is required and not found. |
getFirstChildElement | public static Element getFirstChildElement(Element root)(Code) | | getFirstChildElement purpose.
Used to help with XML manipulations. Returns the element which
represents the first child.
Parameters: root - The root element to look for children in. The element if a child was found, the null otherwise. |
getIntAttribute | public static int getIntAttribute(Element elem, String attName, boolean mandatory, int defaultValue) throws Exception(Code) | | getIntAttribute purpose.
Used to help with XML manipulations. Returns the first child integer
attribute of the specified name. An exception occurs when the node is
required and not found.
Parameters: elem - The root element to look for children in. Parameters: attName - The name of the attribute to look for. Parameters: mandatory - true when an exception should be thrown if theattribute element does not exist. Parameters: defaultValue - a default value to return incase the attribute wasnot found. mutually exclusive with the Exceptionthrown. The int value if the attribute was found, the default otherwise. throws: Exception - When a attribute element is required andnot found. |
getKeyWords | public static List getKeyWords(Element keywordsElem)(Code) | | getKeyWords purpose.
Used to help with XML manipulations. Returns a list of keywords that
were found.
Parameters: keywordsElem - The root element to look for children in. The list of keywords that were found. |
parse | public static Element parse(Reader xml)(Code) | | Parses the specified reader into a DOM tree.
Parameters: xml - Reader representing xml stream to parse. the root element of resulting DOM tree throws: RuntimeException - If reader failed to parse properly. |
validate | public static void validate(Document xml, DefaultHandler errorHandler, String targetNamespace, String schemaLocation)(Code) | | Validates an xml document against a specified schema.
Parameters: xml - The document. Parameters: errorHandler - The validation error handler. Parameters: targetNamespace - The target namespace of the schema, may be null Parameters: schemaLocation - The location of the schema to validate against, may be null throws: RuntimeException - If reader failed to parse properly. |
validate | public static void validate(Reader xml, DefaultHandler errorHandler, String targetNamespace, String schemaLocation)(Code) | | Validates an xml document against a specified schema.
Parameters: xml - Reader representing xml stream to parse. Parameters: errorHandler - The validation error handler. Parameters: targetNamespace - The target namespace of the schema, may be null Parameters: schemaLocation - The location of the schema to validate against, may be null throws: RuntimeException - If reader failed to parse properly. |
|
|