org.apache.commons.betwixt.io
Class BeanReader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.commons.digester.Digester
          extended by org.apache.commons.betwixt.io.BeanReader
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class BeanReader
extends Digester

BeanReader reads a tree of beans from an XML document.

Version:
$Revision: 1.10 $
Author:
James Strachan

Field Summary
private  XMLIntrospector introspector
          Introspector used
private  org.apache.commons.logging.Log log
          Log used for logging (Doh!)
private  boolean matchIDs
          Should the reader use ID's to match
private  java.util.Set registeredClasses
          The registered classes
 
Fields inherited from class org.apache.commons.digester.Digester
bodyText, bodyTexts, classLoader, configured, entityResolver, entityValidator, errorHandler, factory, inputSources, JAXP_SCHEMA_LANGUAGE, locator, match, matches, namespaceAware, namespaces, params, parser, publicId, reader, root, rules, saxLog, schemaLanguage, schemaLocation, stack, substitutor, useContextClassLoader, validating, W3C_XML_SCHEMA
 
Constructor Summary
BeanReader()
          Construct a new BeanReader with default properties.
BeanReader(javax.xml.parsers.SAXParser parser)
          Construct a new BeanReader, allowing a SAXParser to be passed in.
BeanReader(org.xml.sax.XMLReader reader)
          Construct a new BeanReader, allowing an XMLReader to be passed in.
 
Method Summary
protected  void addBeanCreateRule(java.lang.String path, ElementDescriptor elementDescriptor, java.lang.Class beanClass)
          Adds a new bean create rule for the specified path
 org.apache.commons.logging.Log getLog()
           Get the current level for logging.
 boolean getMatchIDs()
          Should the reader use ID attributes to match beans.
 XMLIntrospector getXMLIntrospector()
           Get the introspector used.
 void registerBeanClass(java.lang.Class beanClass)
          Registers a bean class which is used by the reader to deduce the digester rules.
 void registerBeanClass(java.lang.String path, java.lang.Class beanClass)
          Registers a bean class at the given path expression which is used by the reader to deduce the digester rules.
 void setLog(org.apache.commons.logging.Log log)
           Set the current logging level.
 void setMatchIDs(boolean matchIDs)
          Set whether the read should use ID attributes to match beans.
 void setXMLIntrospector(XMLIntrospector introspector)
           Set the introspector to be used.
 
Methods inherited from class org.apache.commons.digester.Digester
addBeanPropertySetter, addBeanPropertySetter, addCallMethod, addCallMethod, addCallMethod, addCallMethod, addCallParam, addCallParam, addCallParam, addCallParam, addCallParamPath, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addFactoryCreate, addObjectCreate, addObjectCreate, addObjectCreate, addObjectCreate, addObjectParam, addRule, addRuleSet, addSetNestedProperties, addSetNestedProperties, addSetNestedProperties, addSetNext, addSetNext, addSetProperties, addSetProperties, addSetProperties, addSetProperty, addSetRoot, addSetRoot, addSetTop, addSetTop, characters, cleanup, clear, configure, createInputSourceFromURL, createInputSourceFromURL, createSAXException, createSAXException, createSAXException, endDocument, endElement, endPrefixMapping, error, fatalError, findNamespaceURI, getClassLoader, getCount, getCurrentElementName, getCurrentNamespaces, getCustomContentHandler, getDebug, getDocumentLocator, getEntityResolver, getErrorHandler, getFactory, getFeature, getLogger, getMatch, getNamespaceAware, getParser, getProperty, getPublicId, getReader, getRoot, getRuleNamespaceURI, getRules, getSAXLogger, getSchema, getSchemaLanguage, getStackAction, getSubstitutor, getUseContextClassLoader, getValidating, getXMLReader, ignorableWhitespace, initialize, isEmpty, log, log, notationDecl, parse, parse, parse, parse, parse, parse, peek, peek, peek, peek, peekParams, peekParams, pop, pop, popParams, processingInstruction, push, push, pushParams, register, register, resetRoot, resolveEntity, setClassLoader, setCustomContentHandler, setDebug, setDocumentLocator, setEntityResolver, setErrorHandler, setFeature, setLogger, setNamespaceAware, setProperty, setPublicId, setRuleNamespaceURI, setRules, setSAXLogger, setSchema, setSchemaLanguage, setStackAction, setSubstitutor, setUseContextClassLoader, setValidating, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

introspector

private XMLIntrospector introspector
Introspector used


log

private org.apache.commons.logging.Log log
Log used for logging (Doh!)


registeredClasses

private java.util.Set registeredClasses
The registered classes


matchIDs

private boolean matchIDs
Should the reader use ID's to match

Constructor Detail

BeanReader

public BeanReader()
Construct a new BeanReader with default properties.


BeanReader

public BeanReader(javax.xml.parsers.SAXParser parser)
Construct a new BeanReader, allowing a SAXParser to be passed in. This allows BeanReader to be used in environments which are unfriendly to JAXP1.1 (such as WebLogic 6.0). Thanks for the request to change go to James House (james@interobjective.com). This may help in places where you are able to load JAXP 1.1 classes yourself.

Parameters:
parser - use this SAXParser

BeanReader

public BeanReader(org.xml.sax.XMLReader reader)
Construct a new BeanReader, allowing an XMLReader to be passed in. This allows BeanReader to be used in environments which are unfriendly to JAXP1.1 (such as WebLogic 6.0). Note that if you use this option you have to configure namespace and validation support yourself, as these properties only affect the SAXParser and emtpy constructor.

Parameters:
reader - use this XMLReader as source for SAX events
Method Detail

registerBeanClass

public void registerBeanClass(java.lang.Class beanClass)
                       throws java.beans.IntrospectionException
Registers a bean class which is used by the reader to deduce the digester rules.

Parameters:
beanClass - the Class to be registered
Throws:
java.beans.IntrospectionException - if the bean introspection fails

registerBeanClass

public void registerBeanClass(java.lang.String path,
                              java.lang.Class beanClass)
                       throws java.beans.IntrospectionException
Registers a bean class at the given path expression which is used by the reader to deduce the digester rules.

Parameters:
path - the xml path expression where the class is to registered. This should be in digester path notation
beanClass - the Class to be registered
Throws:
java.beans.IntrospectionException - if the bean introspection fails

getXMLIntrospector

public XMLIntrospector getXMLIntrospector()

Get the introspector used.

The XMLBeanInfo used to map each bean is created by the XMLIntrospector. One way in which the mapping can be customized is by altering the XMLIntrospector.

Returns:
the XMLIntrospector used for the introspection

setXMLIntrospector

public void setXMLIntrospector(XMLIntrospector introspector)

Set the introspector to be used.

The XMLBeanInfo used to map each bean is created by the XMLIntrospector. One way in which the mapping can be customized is by altering the XMLIntrospector.

Parameters:
introspector - use this introspector

getLog

public org.apache.commons.logging.Log getLog()

Get the current level for logging.

Returns:
the Log implementation this class logs to

setLog

public void setLog(org.apache.commons.logging.Log log)

Set the current logging level.

Parameters:
log - the Logimplementation to use for logging

getMatchIDs

public boolean getMatchIDs()
Should the reader use ID attributes to match beans.

Returns:
true if ID and IDREF attributes should be used to match instances

setMatchIDs

public void setMatchIDs(boolean matchIDs)
Set whether the read should use ID attributes to match beans.

Parameters:
matchIDs - pass true if ID's should be matched

addBeanCreateRule

protected void addBeanCreateRule(java.lang.String path,
                                 ElementDescriptor elementDescriptor,
                                 java.lang.Class beanClass)
Adds a new bean create rule for the specified path

Parameters:
path - the digester path at which this rule should be added
elementDescriptor - the ElementDescriptor describes the expected element
beanClass - the Class of the bean created by this rule