org.modeshape.jcr.xml

## Class NodeImportXmlHandler

- java.lang.Object
- - org.xml.sax.helpers.DefaultHandler
  - - org.xml.sax.ext.DefaultHandler2
    - - org.modeshape.jcr.xml.NodeImportXmlHandler

- All Implemented Interfaces:
    ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, EntityResolver2, LexicalHandler

      @NotThreadSafe
      public class NodeImportXmlHandler
      extends DefaultHandler2

  A simplified version of the graph xml import handler (from ModeShape 2.x) which is used for importing initial content into workspaces.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NodeImportXmlHandler.AttributeScoping` The choices for how attributes that have no namespace prefix should be assigned a namespace.
    `class` | `NodeImportXmlHandler.ImportElement` Element entries represent in-memory representations of the xml elements (either nodes or properties) encountered between a `startElement(String, String, String, Attributes)` and a `endElement(String, String, String)` event.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `multiValueSeparator` The separator string used for determining multi-valued properties
    `protected PathFactory` | `pathFactory` The reference to the `PathFactory`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NodeImportXmlHandler(NodeImportDestination destination)` Creates a new handler instance, using only an execution context and some default values.
    `NodeImportXmlHandler(NodeImportDestination destination, String nameAttribute, String typeAttribute, String typeAttributeValue, String multiValueSeparator, NodeImportXmlHandler.AttributeScoping scoping)` Create a handler that parses an xml file.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `characters(char[] ch, int start, int length)`
    `protected String` | `createName(String uri, String localName)`
    `void` | `endDocument()`
    `void` | `endElement(String uri, String localName, String name)`
    `void` | `endPrefixMapping(String prefix)`
    `void` | `startDocument()`
    `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, unparsedEntityDecl, warning`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### pathFactory

          protected final PathFactory pathFactory

      The reference to the `PathFactory`

    - #### multiValueSeparator

          protected String multiValueSeparator

      The separator string used for determining multi-valued properties

  - ### Constructor Detail

    - #### NodeImportXmlHandler

          public NodeImportXmlHandler(NodeImportDestination destination)

      Creates a new handler instance, using only an execution context and some default values.
      Parameters:
        `destination` - a non-null `NodeImportDestination`

    - #### NodeImportXmlHandler

          public NodeImportXmlHandler(NodeImportDestination destination,
                              String nameAttribute,
                              String typeAttribute,
                              String typeAttributeValue,
                              String multiValueSeparator,
                              NodeImportXmlHandler.AttributeScoping scoping)

      Create a handler that parses an xml file.
      Parameters:
        `destination` - a non-null `NodeImportDestination` which is expected to provide a valid context and to handle the results of the import process.
        `nameAttribute` - 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 name
        `typeAttribute` - the name of the property that should be set with the type of the XML element, or null if there is no such property
        `typeAttributeValue` - 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 element
        `multiValueSeparator` - the string that should be used a separator for creating multi-valued properties.
        `scoping` - defines how to choose the namespace of attributes that do not have a namespace prefix; if null, the `DEFAULT_ATTRIBUTE_SCOPING` value is used @throws IllegalArgumentException if the destination reference is null

  - ### Method Detail

    - #### startPrefixMapping

          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.

      Specified by:
        `startPrefixMapping` in interface `ContentHandler`
      Overrides:
        `startPrefixMapping` in class `DefaultHandler`
      See Also:
        `DefaultHandler.startPrefixMapping(java.lang.String, java.lang.String)`

    - #### endPrefixMapping

          public void endPrefixMapping(String prefix)

      Specified by:
        `endPrefixMapping` in interface `ContentHandler`
      Overrides:
        `endPrefixMapping` in class `DefaultHandler`

    - #### startElement

          public void startElement(String uri,
                          String localName,
                          String name,
                          Attributes attributes)
                            throws SAXException

      Specified by:
        `startElement` in interface `ContentHandler`
      Overrides:
        `startElement` in class `DefaultHandler`
      Throws:
        `SAXException`

    - #### createName

          protected String createName(String uri,
                          String localName)

    - #### endElement

          public void endElement(String uri,
                        String localName,
                        String name)

      Specified by:
        `endElement` in interface `ContentHandler`
      Overrides:
        `endElement` in class `DefaultHandler`

    - #### characters

          public void characters(char[] ch,
                        int start,
                        int length)

      Specified by:
        `characters` in interface `ContentHandler`
      Overrides:
        `characters` in class `DefaultHandler`

    - #### startDocument

          public void startDocument()
                             throws SAXException

      Specified by:
        `startDocument` in interface `ContentHandler`
      Overrides:
        `startDocument` in class `DefaultHandler`
      Throws:
        `SAXException`

    - #### endDocument

          public void endDocument()
                           throws SAXException

      Specified by:
        `endDocument` in interface `ContentHandler`
      Overrides:
        `endDocument` in class `DefaultHandler`
      Throws:
        `SAXException`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.