Package com.dtolabs.shared.resources
Class ResourceXMLParser
- java.lang.Object
-
- com.dtolabs.shared.resources.ResourceXMLParser
-
public class ResourceXMLParser extends java.lang.ObjectResourceXMLParser parses a resources.xml formatted file, and provides several interfaces for using the result data.
Theparse()method parses the configured File as a sequence ofResourceXMLParser.Entityobjects, one for each entry in the file. It passes these objects to any configuredResourceXMLReceiverobject. One should be set usingsetReceiver(ResourceXMLReceiver)to receive parsed entities or the entire entity set.
The default entityXpath property value is set to match all entity types in the resource xml(node|setting|package|deployment), but this can be set to any Xpath to limit the entities that are parsed from the document. (e.g. "node|package" or "node[@name='mynode']").
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResourceXMLParser.EntityRepresents a parsed resource entity in the xml, which consists of a name property, a type property, and a set of name/value properties.static classResourceXMLParser.EntitySetContains the set of parsed entities from the document.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_ENTITY_XPATH
-
Constructor Summary
Constructors Constructor Description ResourceXMLParser(java.io.File file)Constructor for the ResourceXMLParserResourceXMLParser(java.io.InputStream input)Constructor for the ResourceXMLParserResourceXMLParser(org.dom4j.Document doc)Constructor for the ResourceXMLParser
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.xml.sax.EntityResolvercreateEntityResolver()ResourceXMLReceivergetReceiver()Return the ResourceXMLReceivervoidparse()Parse the document, applying the configured Receiver to the parsed entitiesprotected static java.lang.StringreportNodeErrorLocation(org.dom4j.Node e)Return a String describing the DOM node's location and parent type namevoidsetReceiver(ResourceXMLReceiver receiver)Set the ResourceXMLReceiver to use.
-
-
-
Field Detail
-
DEFAULT_ENTITY_XPATH
public static final java.lang.String DEFAULT_ENTITY_XPATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResourceXMLParser
public ResourceXMLParser(java.io.File file)
Constructor for the ResourceXMLParser- Parameters:
file- source file
-
ResourceXMLParser
public ResourceXMLParser(java.io.InputStream input)
Constructor for the ResourceXMLParser- Parameters:
input- source file
-
ResourceXMLParser
public ResourceXMLParser(org.dom4j.Document doc)
Constructor for the ResourceXMLParser- Parameters:
doc- source document
-
-
Method Detail
-
parse
public void parse() throws ResourceXMLParserException, java.io.IOExceptionParse the document, applying the configured Receiver to the parsed entities- Throws:
ResourceXMLParserException- parse errorjava.io.IOException- io error
-
createEntityResolver
public static org.xml.sax.EntityResolver createEntityResolver()
-
reportNodeErrorLocation
protected static java.lang.String reportNodeErrorLocation(org.dom4j.Node e)
Return a String describing the DOM node's location and parent type name- Parameters:
e- the node- Returns:
- string describing xpath location and parent "type" element name
-
getReceiver
public ResourceXMLReceiver getReceiver()
Return the ResourceXMLReceiver- Returns:
- the ResourceXMLReceiver
-
setReceiver
public void setReceiver(ResourceXMLReceiver receiver)
Set the ResourceXMLReceiver to use. It will be invoked to receive theResourceXMLParser.Entityobjects created during theparse()method, and will also receive the completeResourceXMLParser.EntitySetat the end of the sequence. It can govern whether parsing should continue or not, seeResourceXMLReceiver- Parameters:
receiver- the new ResourceXMLReceiver
-
-