com.openharbor.beck
Class ObjectXMLReader

java.lang.Object
  extended bycom.openharbor.beck.ObjectXMLReader

public class ObjectXMLReader
extends java.lang.Object

Copies Java objects from XML. This class is not thread-safe; each thread should use a separate instance.


Field Summary
protected  SAXContentHandler _contentHandler
           
protected  org.xml.sax.EntityResolver _entityResolver
           
protected  org.xml.sax.ErrorHandler _errorHandler
           
protected  boolean _validation
           
protected  org.apache.commons.logging.Log log
           
static java.lang.String SCHEMA_VALIDATION_FEATURE_ID
           
static java.lang.String VALIDATION_FEATURE_ID
           
 
Constructor Summary
ObjectXMLReader()
          Use the default configuration (equivalent to an empty mapping XML).
ObjectXMLReader(MapFromXML.Source mapperSource)
          Allocate mappers from the given Source.
ObjectXMLReader(MapFromXML mapper)
          Use the given mapper.
 
Method Summary
protected  void changeMapper(MapFromXML newMapper)
           
static java.lang.Object parse(java.lang.String xml, MapFromXML mapper)
          Construct an object from XML, using a given _mapper.
static Configuration parseConfiguration(java.lang.String xml)
          Construct a Configuration from mapping XML.
protected  org.xml.sax.XMLReader prep(org.xml.sax.XMLReader reader, java.lang.String baseURI)
           
 java.lang.Object read(org.xml.sax.InputSource source)
          Map an object from an XML document stream.
 java.lang.Object read(java.lang.String url)
          Map an object from an XML document identified by URL.
 java.lang.Object read(org.xml.sax.XMLReader reader, org.xml.sax.InputSource source)
          Map an object from an XML document stream.
 java.lang.Object read(org.xml.sax.XMLReader reader, java.lang.String url)
          Map an object from an XML document identified by URL.
static Configuration readConfiguration(java.lang.ClassLoader loader, java.lang.String resourceName)
          Construct a Configuration from a mapping XML resource file.
static Configuration readConfiguration(java.io.File file)
          Construct a Configuration from a mapping XML file.
static Configuration readConfiguration(org.xml.sax.InputSource source)
          Construct a Configuration from mapping XML.
static Configuration readConfiguration(java.net.URL url)
          Construct a Configuration from mapping XML identified by a URL.
 void setEntityResolver(org.xml.sax.EntityResolver resolver)
          Set the SAX entity resolver.
protected  void setMapper(MapFromXML newMapper)
           
 void setValidation(boolean validation)
          Choose whether to validate the XML from which objects are mapped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

_contentHandler

protected SAXContentHandler _contentHandler

_errorHandler

protected org.xml.sax.ErrorHandler _errorHandler

_entityResolver

protected org.xml.sax.EntityResolver _entityResolver

_validation

protected boolean _validation

VALIDATION_FEATURE_ID

public static final java.lang.String VALIDATION_FEATURE_ID
See Also:
Constant Field Values

SCHEMA_VALIDATION_FEATURE_ID

public static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID
See Also:
Constant Field Values
Constructor Detail

ObjectXMLReader

public ObjectXMLReader()
                throws java.lang.Exception
Use the default configuration (equivalent to an empty mapping XML).


ObjectXMLReader

public ObjectXMLReader(MapFromXML mapper)
Use the given mapper. This is not thread-safe.


ObjectXMLReader

public ObjectXMLReader(MapFromXML.Source mapperSource)
Allocate mappers from the given Source.

Method Detail

setValidation

public void setValidation(boolean validation)
Choose whether to validate the XML from which objects are mapped.


setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Set the SAX entity resolver. This can be useful for directing the parser to load DTD, schema documents or other external entities.


setMapper

protected void setMapper(MapFromXML newMapper)

changeMapper

protected void changeMapper(MapFromXML newMapper)
                     throws java.lang.NullPointerException
Throws:
java.lang.NullPointerException

prep

protected org.xml.sax.XMLReader prep(org.xml.sax.XMLReader reader,
                                     java.lang.String baseURI)
                              throws java.lang.Exception
Throws:
java.lang.Exception

read

public java.lang.Object read(org.xml.sax.XMLReader reader,
                             org.xml.sax.InputSource source)
                      throws java.lang.Exception
Map an object from an XML document stream.

Throws:
java.lang.Exception

read

public java.lang.Object read(org.xml.sax.XMLReader reader,
                             java.lang.String url)
                      throws java.lang.Exception
Map an object from an XML document identified by URL.

Throws:
java.lang.Exception

read

public java.lang.Object read(org.xml.sax.InputSource source)
                      throws java.lang.Exception
Map an object from an XML document stream.

Throws:
java.lang.Exception

read

public java.lang.Object read(java.lang.String url)
                      throws java.lang.Exception
Map an object from an XML document identified by URL.

Throws:
java.lang.Exception

readConfiguration

public static Configuration readConfiguration(java.io.File file)
                                       throws java.lang.Exception
Construct a Configuration from a mapping XML file.

Throws:
java.lang.Exception

readConfiguration

public static Configuration readConfiguration(java.lang.ClassLoader loader,
                                              java.lang.String resourceName)
                                       throws java.lang.Exception
Construct a Configuration from a mapping XML resource file. loader.getResource resolves the resourceName to its URL.

Throws:
java.io.FileNotFoundException - no resource of the given name is available from the given loader.
java.lang.Exception

readConfiguration

public static Configuration readConfiguration(java.net.URL url)
                                       throws java.lang.Exception
Construct a Configuration from mapping XML identified by a URL.

Throws:
java.lang.Exception

readConfiguration

public static Configuration readConfiguration(org.xml.sax.InputSource source)
                                       throws java.lang.Exception
Construct a Configuration from mapping XML.

Throws:
java.lang.Exception

parse

public static java.lang.Object parse(java.lang.String xml,
                                     MapFromXML mapper)
                              throws java.lang.Exception
Construct an object from XML, using a given _mapper.

Throws:
java.lang.Exception

parseConfiguration

public static Configuration parseConfiguration(java.lang.String xml)
                                        throws java.lang.Exception
Construct a Configuration from mapping XML.

Throws:
java.lang.Exception