| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.xml.sax.ext.DefaultHandler2
org.modeshape.graph.xml.XmlHandler
@NotThreadSafe public class XmlHandler

A DefaultHandler2 specialization that responds to XML content events by creating the corresponding content in the
 supplied graph. This implementation ignores DTD entities, XML contents, and other XML processing instructions. If other
 behavior is required, the appropriate methods can be overridden. (Which is why this class extends DefaultHandler2,
 which has support for processing all the different parts of XML.
 
 This class can be passed to the SAXParser's parse(..,DefaultHandler) methods.
 
| Nested Class Summary | |
|---|---|
| static class | XmlHandler.AttributeScopingThe choices for how attributes that have no namespace prefix should be assigned a namespace. | 
| protected static class | XmlHandler.ElementEntryStatePossible states for an ElementEntryinstance. | 
| Field Summary | |
|---|---|
| protected  Path | currentPathThe path for the node representing the current element. | 
| protected  TextDecoder | decoderThe TextDecoder that is used to decode the names. | 
| static XmlHandler.AttributeScoping | DEFAULT_ATTRIBUTE_SCOPINGThe default XmlHandler.AttributeScoping. | 
| static TextDecoder | DEFAULT_DECODERDecoder for XML names, to turn '_xHHHH_' sequences in the XML element and attribute names into the corresponding UTF-16 characters. | 
| protected  Destination | destinationThe destination where the content should be sent. | 
| protected  Name | nameAttributeThe name of the XML attribute whose value should be used for the name of the node. | 
| protected  NameFactory | nameFactoryThe cached reference to the graph's name factory. | 
| protected  NamespaceRegistry | namespaceRegistryThe cached reference to the graph's namespace registry. | 
| protected  PathFactory | pathFactoryThe cached reference to the graph's path factory. | 
| protected  List<Property> | propertiesA temporary list used to store the properties for a single node. | 
| protected  PropertyFactory | propertyFactoryThe cached reference to the graph's property factory. | 
| protected  Object[] | propertyValuesA working array that contains a single value object that is used to create Property objects (without having to create an array of values for each property). | 
| protected  boolean | skipFirstElementFlag the records whether the first element should be skipped. | 
| protected  Name | typeAttributeThe name of the property that is to be set with the type of the XML element. | 
| protected  Name | typeAttributeValueThe value of the node type property, if the node's name is set with the nameAttribute. | 
| Constructor Summary | |
|---|---|
| XmlHandler(Destination destination,
           boolean skipRootElement,
           Path parent,
           TextDecoder textDecoder,
           Name nameAttribute,
           Name typeAttribute,
           Name typeAttributeValue,
           XmlHandler.AttributeScoping scoping)Create a handler that creates content in the supplied graph | |
| Method Summary | |
|---|---|
|  void | characters(char[] ch,
           int start,
           int length) | 
| protected  Property | createProperty(Name propertyName,
               Collection<Object> values)Create a property with the given name and values, obtained from an attribute name and value in the XML content. | 
| protected  Property | createProperty(Name propertyName,
               Object value)Create a property with the given name and value, obtained from an attribute name and value in the XML content. | 
|  void | endDocument() | 
|  void | endElement(String uri,
           String localName,
           String name) | 
|  void | endPrefixMapping(String prefix) | 
|  void | startElement(String uri,
             String localName,
             String name,
             Attributes attributes) | 
|  void | startPrefixMapping(String prefix,
                   String uri)This method ensures that the namespace is registered with the registry, using the supplied prefix
 to register the namespace if required. | 
| Methods inherited from class org.xml.sax.ext.DefaultHandler2 | 
|---|
| attributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, getExternalSubset, internalEntityDecl, resolveEntity, resolveEntity, startCDATA, startDTD, startEntity | 
| Methods inherited from class org.xml.sax.helpers.DefaultHandler | 
|---|
| error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, unparsedEntityDecl, warning | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static TextDecoder DEFAULT_DECODER
public static XmlHandler.AttributeScoping DEFAULT_ATTRIBUTE_SCOPING
XmlHandler.AttributeScoping.
protected final Destination destination
protected final Name nameAttribute
protected final Name typeAttribute
protected final Name typeAttributeValue
nameAttribute.
protected final PathFactory pathFactory
protected final NameFactory nameFactory
protected final PropertyFactory propertyFactory
protected final NamespaceRegistry namespaceRegistry
protected final TextDecoder decoder
protected Path currentPath
protected boolean skipFirstElement
protected final List<Property> properties
protected final Object[] propertyValues
| Constructor Detail | 
|---|
public XmlHandler(Destination destination,
                  boolean skipRootElement,
                  Path parent,
                  TextDecoder textDecoder,
                  Name nameAttribute,
                  Name typeAttribute,
                  Name typeAttributeValue,
                  XmlHandler.AttributeScoping scoping)
destination - the destination where the content should be sent.graph in which the content should be placedskipRootElement - true if the root element of the document should be skipped, or false if the root element should be
        converted to the top-level node of the contentparent - the path to the node in the graph under which the content should be placed; if null, the root node is assumedtextDecoder - the text decoder that should be used to decode the XML element names and XML attribute names, prior to
        using those values to create names; or null if the default encoder should be usednameAttribute - the name of the property whose value should be used for the names of the nodes (typically, this is
        "jcr:name" or something equivalent); or null if the XML element name should always be used as the node nametypeAttribute - the name of the property that should be set with the type of the XML element, or null if there is no
        such propertytypeAttributeValue - the value of the type property that should be used if the node has no nameAttribute,
        or null if the value should be set to the type of the XML elementscoping - defines how to choose the namespace of attributes that do not have a namespace prefix; if null, the
        DEFAULT_ATTRIBUTE_SCOPING value is used
IllegalArgumentException - if the destination reference is null| Method Detail | 
|---|
public void startPrefixMapping(String prefix,
                               String uri)
 This method ensures that the namespace is registered with the registry, using the supplied prefix
 to register the namespace if required. Note that because this class does not really use the namespace prefixes to create
 Name objects, no attempt is made to match the XML namespace prefixes.
 
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class DefaultHandlerDefaultHandler.startPrefixMapping(java.lang.String, java.lang.String)public void endPrefixMapping(String prefix)
endPrefixMapping in interface ContentHandlerendPrefixMapping in class DefaultHandlerDefaultHandler.endPrefixMapping(java.lang.String)
public void startElement(String uri,
                         String localName,
                         String name,
                         Attributes attributes)
startElement in interface ContentHandlerstartElement in class DefaultHandlerDefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String,
      org.xml.sax.Attributes)
public void endElement(String uri,
                       String localName,
                       String name)
endElement in interface ContentHandlerendElement in class DefaultHandlerDefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void characters(char[] ch,
                       int start,
                       int length)
characters in interface ContentHandlercharacters in class DefaultHandlerDefaultHandler.characters(char[], int, int)public void endDocument()
endDocument in interface ContentHandlerendDocument in class DefaultHandlerDefaultHandler.endDocument()
protected Property createProperty(Name propertyName,
                                  Object value)
By default, this method creates a property by directly using the value as the sole value of the property.
propertyName - the name of the property; never nullvalue - the attribute value
protected Property createProperty(Name propertyName,
                                  Collection<Object> values)
By default, this method creates a property by directly using the values as the values of the property.
propertyName - the name of the property; never nullvalues - the attribute values
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||