|
|||||||||
| Home >> All >> gnu >> java >> beans >> [ decoder overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
gnu.java.beans.decoder
Class PersistenceParser

java.lang.Objectorg.xml.sax.helpers.DefaultHandler
gnu.java.beans.decoder.PersistenceParser
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, Context, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
- public class PersistenceParser
- extends org.xml.sax.helpers.DefaultHandler
- implements Context
- extends org.xml.sax.helpers.DefaultHandler
The PersistenceParser parses an XML data stream and delegates actions to ElementHandler instances. The parser catches and recovers from all exception which reside from wrong usage of attributes and tags.
| Field Summary | |
private ElementHandler |
currentHandler
Denotes the current ElementHandler. |
private java.beans.XMLDecoder |
decoder
The XMLDecoder instance that started this PersistenceParser |
private java.beans.ExceptionListener |
exceptionListener
The ExceptionListener instance which is informed of non-critical parsing exceptions. |
private java.util.HashMap |
handlerCreators
Stores the Creator instances which can instantiate the appropriate handler implementation for a given element. |
(package private) JavaHandler |
javaHandler
The real root element that stores all objects created during parsing. |
private java.util.List |
objects
Stores the decoded objects. |
private int |
skipElement
When an element was not usable all elements inside it should be skipped. |
| Constructor Summary | |
PersistenceParser(java.io.InputStream inputStream,
java.beans.ExceptionListener exceptionListener,
java.lang.ClassLoader cl,
java.beans.XMLDecoder decoder)
Creates a PersistenceParser which reads XML data from the given InputStream, reports exceptions to ExceptionListener instance, stores resulting object in the DecoderContext and uses the given ClassLoader to resolve classes. |
|
| Method Summary | |
void |
addParameterObject(java.lang.Object o)
Adds a decoded object to the Context. |
void |
characters(char[] ch,
int start,
int length)
Transfers character data to the current handler |
java.lang.Object |
endContext(Context outerContext)
Notifies that the context ends and the returns the appropriate result object. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Receive notification of the end of an element. |
java.lang.Object |
get(int index)
Calls an appropriate indexed get method if it is available or throws an AssemblerException if that is not allowed on this Context. |
java.lang.String |
getId()
Returns this Context's unique id or null if does not have such an id. |
java.lang.Object |
getResult()
Returns the result which was calculated by calling endContext() or reportStatement(). |
boolean |
isStatement()
Returns whether this Context is a statement (not returning result back to parent handler's Context) or not (= expression). |
java.util.Iterator |
iterator()
Returns an Iterator instance which returns the decoded objects. |
void |
notifyStatement(Context outerContext)
Notifies that the next element is a statement. |
void |
set(int index,
java.lang.Object o)
Calls an appropriate indexed set method if it is available or throws an AssemblerException if that is not allowed on this Context. |
void |
setId(java.lang.String id)
Gives this Context a unique id. |
void |
setStatement(boolean b)
Sets whether this Context is a statement or not. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
Receive notification of the start of an element. |
boolean |
subContextFailed()
Notifies that the assembly of a subcontext failed and returns whether this Context is affected in a way that it fails too. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
exceptionListener
private java.beans.ExceptionListener exceptionListener
- The ExceptionListener instance which is informed of non-critical parsing exceptions.
skipElement
private int skipElement
- When an element was not usable all elements inside it should be skipped.
This is done by skipping startElement() and endElement() invocations whenever
this value is above 0.
handlerCreators
private java.util.HashMap handlerCreators
- Stores the Creator instances which can instantiate the appropriate handler implementation
for a given element.
currentHandler
private ElementHandler currentHandler
- Denotes the current ElementHandler. To avoid checking for null-values it is pre-assigned
with a DummyHandler instance which must not be used but acts as a root element.
javaHandler
JavaHandler javaHandler
- The real root element that stores all objects created during parsing.
Package-private to avoid an accessor method.
objects
private java.util.List objects
- Stores the decoded objects.
decoder
private java.beans.XMLDecoder decoder
- The XMLDecoder instance that started this PersistenceParser
| Constructor Detail |
PersistenceParser
public PersistenceParser(java.io.InputStream inputStream, java.beans.ExceptionListener exceptionListener, java.lang.ClassLoader cl, java.beans.XMLDecoder decoder)
- Creates a PersistenceParser which reads XML data from the given InputStream, reports
exceptions to ExceptionListener instance, stores resulting object in the DecoderContext
and uses the given ClassLoader to resolve classes.
| Method Detail |
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of the start of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of the end of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler
characters
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
- Transfers character data to the current handler
- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler
addParameterObject
public void addParameterObject(java.lang.Object o) throws AssemblyException
- Adds a decoded object to the Context.
- Specified by:
addParameterObjectin interfaceContext
notifyStatement
public void notifyStatement(Context outerContext) throws AssemblyException
- Description copied from interface:
Context - Notifies that the next element is a statement. This can mean
that an argument list is complete to be called.
- Specified by:
notifyStatementin interfaceContext
endContext
public java.lang.Object endContext(Context outerContext) throws AssemblyException
- Description copied from interface:
Context - Notifies that the context ends and the returns the appropriate result
object.
- Specified by:
endContextin interfaceContext
subContextFailed
public boolean subContextFailed()
- Description copied from interface:
Context - Notifies that the assembly of a subcontext failed and returns
whether this Context is affected in a way that it fails too.
- Specified by:
subContextFailedin interfaceContext
set
public void set(int index,
java.lang.Object o)
throws AssemblyException
- Description copied from interface:
Context - Calls an appropriate indexed set method if it is available or
throws an AssemblerException if that is not allowed on this Context.
The behaviour of this method is equal to List.set(int, Object).
get
public java.lang.Object get(int index) throws AssemblyException
- Description copied from interface:
Context - Calls an appropriate indexed get method if it is available or
throws an AssemblerException if that is not allowed on this Context.
The behaviour of this method is equal to List.get(int).
getResult
public java.lang.Object getResult()
- Description copied from interface:
Context - Returns the result which was calculated by calling endContext() or reportStatement().
Its the handler's responsibility to care that any of these two methods was called.
This is used by sub-Contexts to access this Context's result.
setId
public void setId(java.lang.String id)
- Description copied from interface:
Context - Gives this Context a unique id. For convenience the id may be null which means
that no id exists at all.
getId
public java.lang.String getId()
- Description copied from interface:
Context - Returns this Context's unique id or null if does not have such an id.
isStatement
public boolean isStatement()
- Description copied from interface:
Context - Returns whether this Context is a statement (not returning result back
to parent handler's Context) or not (= expression).
- Specified by:
isStatementin interfaceContext
setStatement
public void setStatement(boolean b)
- Description copied from interface:
Context - Sets whether this Context is a statement or not.
- Specified by:
setStatementin interfaceContext
iterator
public java.util.Iterator iterator()
- Returns an Iterator instance which returns the decoded objects.
This method is used by the XMLDecoder directly.
|
|||||||||
| Home >> All >> gnu >> java >> beans >> [ decoder overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC