|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.ws.jaxme.util.Configurator
public class Configurator
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)
.
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()
|
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)
|
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)
|
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)
|
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)
|
void |
startDocument()
|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Configurator()
Method Detail |
---|
public void setNamespace(java.lang.String pNamespace)
Sets the namespace handled by the configurator. Defaults
to no namespace. Shortcut for
setNamespace(new String[]{pNamespace})
.
pNamespace
- The namespace being setpublic void setNamespaces(java.lang.String[] pNamespaces)
Sets the namespaces handled by the configurator. Defaults to no namespace.
pNamespaces
- The namespaces being setpublic java.lang.String[] getNamespaces()
Returns the namespaces handled by the configurator. Defaults to no namespace.
public void setDocumentLocator(org.xml.sax.Locator pLocator)
Sets the Locator being used in error messages.
setDocumentLocator
in interface org.xml.sax.ContentHandler
public org.xml.sax.Locator getDocumentLocator()
Returns the Locator being used in error messages.
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.
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.
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.
public java.lang.Object getRootObject()
An alternative to using the bean factory. This object is used as the root object, regardless of its name.
public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void startPrefixMapping(java.lang.String pPrefix, java.lang.String pURI) throws org.xml.sax.SAXException
startPrefixMapping
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void endPrefixMapping(java.lang.String pPrefix) throws org.xml.sax.SAXException
endPrefixMapping
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
protected boolean isNamespaceMatching(java.lang.String pNamespace)
Returns whether a namespace is matching the configured namespace.
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.
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 factorys
createBeanName()
method, otherwise calls the current beans
createBeanName()
method, with beanName
being the value of the pLocalName
parameter.
startElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
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
org.xml.sax.SAXException
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.
endElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
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.
characters
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
skippedEntity
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public java.lang.Object getResult()
public boolean processName(java.lang.String pName, java.lang.String[] parts)
NamespaceResolver
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 usedparts[1]
: local name, with the prefix removedparts[2]
: qualified name (same as pName)
processName
in interface NamespaceResolver
pName
was successfully resolved. False otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |