org.apache.jackrabbit.jcr2spi.xml
Class ImportHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.jackrabbit.jcr2spi.xml.ImportHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ImportHandler
extends DefaultHandler

An ImportHandler instance can be used to import serialized data in System View XML or Document View XML. Processing of the XML is handled by specialized ContentHandlers (i.e. SysViewImportHandler and DocViewImportHandler).

The actual task of importing though is delegated to the implementation of the Importer interface.

Important Note:

These SAX Event Handlers expect that Namespace URI's and local names are reported in the start/endElement events and that start/endPrefixMapping events are reported (i.e. default SAX2 Namespace processing).


Field Summary
protected  boolean nsContextStarted
          this flag is used to determine whether a namespace context needs to be started in the startElement event or if the namespace context has already been started in a preceeding startPrefixMapping event; the flag is set per element in the first startPrefixMapping event and is cleared again in the following startElement event;
 
Constructor Summary
ImportHandler(Importer importer, NamespaceResolver nsResolver, NamespaceRegistry nsReg, NameFactory nameFactory, PathFactory pathFactory)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          
 void endDocument()
          
 void endElement(String namespaceURI, String localName, String qName)
          
 void endPrefixMapping(String prefix)
          
 void error(SAXParseException e)
          
 void fatalError(SAXParseException e)
          
 String getUniquePrefix(String uriHint)
          Returns a prefix that is unique among the already registered prefixes.
 void startDocument()
          
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
          
 void startPrefixMapping(String prefix, String uri)
          
 void warning(SAXParseException e)
          
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nsContextStarted

protected boolean nsContextStarted
this flag is used to determine whether a namespace context needs to be started in the startElement event or if the namespace context has already been started in a preceeding startPrefixMapping event; the flag is set per element in the first startPrefixMapping event and is cleared again in the following startElement event;

Constructor Detail

ImportHandler

public ImportHandler(Importer importer,
                     NamespaceResolver nsResolver,
                     NamespaceRegistry nsReg,
                     NameFactory nameFactory,
                     PathFactory pathFactory)
Method Detail

warning

public void warning(SAXParseException e)
             throws SAXException

Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler
Throws:
SAXException

error

public void error(SAXParseException e)
           throws SAXException

Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler
Throws:
SAXException

fatalError

public void fatalError(SAXParseException e)
                throws SAXException

Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class DefaultHandler
Throws:
SAXException

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

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException

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

characters

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

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

getUniquePrefix

public String getUniquePrefix(String uriHint)
                       throws RepositoryException
Returns a prefix that is unique among the already registered prefixes.

Parameters:
uriHint - namespace uri that serves as hint for the prefix generation
Returns:
a unique prefix
Throws:
RepositoryException


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.