|
|||||||||
| Home >> All >> org >> apache >> ws >> jaxme >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.ws.jaxme.util
Class Configurator

java.lang.Objectorg.apache.ws.jaxme.util.Configurator
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, NamespaceResolver
- public class Configurator
- extends java.lang.Object
- implements org.xml.sax.ContentHandler, NamespaceResolver
- extends java.lang.Object
The Configurator is an idea borrowed by the Ant project. It is a SAX2 handler that reads a config file which is represented by a hierarchy of Java beans. For example:
<outerBean foo="true" bar="Quite right">
<innerBean whatever="57">
</innerBean
</outerBean>
The example would create an object outerBean and call its
methods setFoo(boolean) and
setBar(String) to process the attributes.
It would also create a bean innerBean by calling the
outerBeans method createInnerBean().
Finally the innerBean is configured by calling
setWhatever(int).
- Version:
- $Id: Configurator.java,v 1.4 2005/03/10 10:14:03 jochen Exp $
| Field Summary | |
private java.lang.Object |
beanFactory
|
private java.util.List |
beans
|
private java.lang.Object |
currentBean
|
private java.lang.String |
currentName
|
private int |
ignoreLevel
|
private org.xml.sax.Locator |
locator
|
private java.util.List |
names
|
private java.lang.String[] |
namespaces
|
private NamespaceSupport |
nss
|
(package private) boolean |
nssNeedsContext
|
private static java.lang.Class[] |
oneClassAttributes
|
private static java.lang.Class[] |
oneClassString
|
private java.lang.Object |
resultBean
|
private java.lang.Object |
rootObject
|
private static java.lang.Class[] |
zeroClasses
|
private static java.lang.Object[] |
zeroObjects
|
| Constructor Summary | |
Configurator()
|
|
| Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Handles atomic child elements by invoking their method addText(String pText). |
void |
endDocument()
Receive notification of the end of a document. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String qName,
java.lang.String localName)
Terminates parsing the current bean by calling its finish() method, if any. |
void |
endPrefixMapping(java.lang.String pPrefix)
End the scope of a prefix-URI mapping. |
java.lang.Object |
getBeanFactory()
Returns the bean factory, creating the outermost element. |
org.xml.sax.Locator |
getDocumentLocator()
Returns the Locator being used in error messages. |
protected java.lang.String |
getMethodNameFor(java.lang.String pPrefix,
java.lang.String pName)
Given a prefix and a name, creates a method name matching the prefix and the name. |
java.lang.String[] |
getNamespaces()
Returns the namespaces handled by the configurator. |
java.lang.Object |
getResult()
Returns the parsed result bean. |
java.lang.Object |
getRootObject()
An alternative to using the bean factory. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
protected java.lang.Object |
invokeMethod(java.lang.String pMethodName,
java.lang.Object pBean,
java.lang.Class[] pSignature,
java.lang.Object[] pArgs)
|
protected boolean |
isNamespaceMatching(java.lang.String pNamespace)
Returns whether a namespace is matching the configured namespace. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
boolean |
processName(java.lang.String pName,
java.lang.String[] parts)
Splits the XML name pName into its
namespace URI, qualified name and local name, which
are stored into the array parts:
parts[0]: namespace URI; empty if no namespace is used
parts[1]: local name, with the prefix removed
parts[2]: qualified name (same as pName)
|
void |
setBeanFactory(java.lang.Object pFactory)
Sets the bean factory, creating the outermost element. |
void |
setDocumentLocator(org.xml.sax.Locator pLocator)
Sets the Locator being used in error messages. |
void |
setNamespace(java.lang.String pNamespace)
Sets the namespace handled by the configurator. |
void |
setNamespaces(java.lang.String[] pNamespaces)
Sets the namespaces handled by the configurator. |
void |
setRootObject(java.lang.Object pRootObject)
An alternative to using the bean factory. |
void |
skippedEntity(java.lang.String name)
Receive notification of a skipped entity. |
void |
startDocument()
Receive notification of the beginning of a document. |
void |
startElement(java.lang.String pNamespaceURI,
java.lang.String pQName,
java.lang.String pLocalName,
org.xml.sax.Attributes pAttr)
Creates a new bean, matching the element name pLocalName. |
void |
startPrefixMapping(java.lang.String pPrefix,
java.lang.String pURI)
Begin the scope of a prefix-URI Namespace mapping. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
zeroClasses
private static final java.lang.Class[] zeroClasses
zeroObjects
private static final java.lang.Object[] zeroObjects
oneClassString
private static final java.lang.Class[] oneClassString
oneClassAttributes
private static final java.lang.Class[] oneClassAttributes
namespaces
private java.lang.String[] namespaces
beans
private java.util.List beans
names
private java.util.List names
currentBean
private java.lang.Object currentBean
currentName
private java.lang.String currentName
locator
private org.xml.sax.Locator locator
beanFactory
private java.lang.Object beanFactory
rootObject
private java.lang.Object rootObject
resultBean
private java.lang.Object resultBean
ignoreLevel
private int ignoreLevel
nss
private NamespaceSupport nss
nssNeedsContext
boolean nssNeedsContext
| Constructor Detail |
Configurator
public Configurator()
| Method Detail |
setNamespace
public void setNamespace(java.lang.String pNamespace)
Sets the namespace handled by the configurator. Defaults to no namespace. Shortcut for
setNamespace(new String[]{pNamespace}).
setNamespaces
public void setNamespaces(java.lang.String[] pNamespaces)
Sets the namespaces handled by the configurator. Defaults to no namespace.
getNamespaces
public java.lang.String[] getNamespaces()
Returns the namespaces handled by the configurator. Defaults to no namespace.
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator pLocator)
Sets the Locator being used in error messages.
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler
getDocumentLocator
public org.xml.sax.Locator getDocumentLocator()
Returns the Locator being used in error messages.
setBeanFactory
public void setBeanFactory(java.lang.Object pFactory)
Sets the bean factory, creating the outermost element. The bean factory must have a matching
createElementName()method, with ElementName being the element name of the document element.
getBeanFactory
public java.lang.Object getBeanFactory()
Returns the bean factory, creating the outermost element. The bean factory must have a matching
createElementName()method, with ElementName being the element name of the document element.
setRootObject
public void setRootObject(java.lang.Object pRootObject)
An alternative to using the bean factory. This object is used as the root object, regardless of its name.
getRootObject
public java.lang.Object getRootObject()
An alternative to using the bean factory. This object is used as the root object, regardless of its name.
startDocument
public void startDocument()
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - Receive notification of the beginning of a document.
The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator 55 ).
- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler
endDocument
public void endDocument()
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - Receive notification of the end of a document.
The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.
- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler
startPrefixMapping
public void startPrefixMapping(java.lang.String pPrefix, java.lang.String pURI) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - Begin the scope of a prefix-URI Namespace mapping.
The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the
http://xml.org/sax/features/namespacesfeature is true (the default).There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.
Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement 55 event, and all endPrefixMapping 55 events will occur after the corresponding endElement 55 event, but their order is not otherwise guaranteed.
There should never be start/endPrefixMapping events for the "xml" prefix, since it is predeclared and immutable.
- Specified by:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler
endPrefixMapping
public void endPrefixMapping(java.lang.String pPrefix) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - End the scope of a prefix-URI mapping.
See startPrefixMapping 55 for details. This event will always occur after the corresponding endElement 55 event, but the order of endPrefixMapping 55 events is not otherwise guaranteed.
- Specified by:
endPrefixMappingin interfaceorg.xml.sax.ContentHandler
isNamespaceMatching
protected boolean isNamespaceMatching(java.lang.String pNamespace)
Returns whether a namespace is matching the configured namespace.
getMethodNameFor
protected java.lang.String getMethodNameFor(java.lang.String pPrefix, java.lang.String pName)
Given a prefix and a name, creates a method name matching the prefix and the name.
startElement
public void startElement(java.lang.String pNamespaceURI, java.lang.String pQName, java.lang.String pLocalName, org.xml.sax.Attributes pAttr) throws org.xml.sax.SAXException
Creates a new bean, matching the element name
pLocalName. If this is the outermost bean, calls the bean factoryscreateBeanName()method, otherwise calls the current beanscreateBeanName()method, with beanName being the value of thepLocalNameparameter.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler
invokeMethod
protected java.lang.Object invokeMethod(java.lang.String pMethodName, java.lang.Object pBean, java.lang.Class[] pSignature, java.lang.Object[] pArgs) throws org.xml.sax.SAXException
endElement
public void endElement(java.lang.String namespaceURI, java.lang.String qName, java.lang.String localName) throws org.xml.sax.SAXException
Terminates parsing the current bean by calling its
finish()method, if any.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler
characters
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
Handles atomic child elements by invoking their method
addText(String pText). Note that it may happen, that this method is invoked multiple times, if the parser splits a piece of text into multiple SAX events.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler
ignorableWhitespace
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - Receive notification of ignorable whitespace in element content.
Validating Parsers must use this method to report each chunk of whitespace in element content (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.
SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - Receive notification of a processing instruction.
The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.
A SAX parser must never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.
- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler
skippedEntity
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ContentHandler - Receive notification of a skipped entity.
The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the
http://xml.org/sax/features/external-general-entitiesand thehttp://xml.org/sax/features/external-parameter-entitiesproperties.- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler
getResult
public java.lang.Object getResult()
- Returns the parsed result bean.
processName
public boolean processName(java.lang.String pName, java.lang.String[] parts)
- Description copied from interface:
NamespaceResolver Splits the XML name
pNameinto its namespace URI, qualified name and local name, which are stored into the array parts:parts[0]: namespace URI; empty if no namespace is usedparts[1]: local name, with the prefix removedparts[2]: qualified name (same as pName)
- Specified by:
processNamein interfaceNamespaceResolver
|
|||||||||
| Home >> All >> org >> apache >> ws >> jaxme >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.ws.jaxme.util.Configurator