|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.xml.XMLReader<E,A,X>
public abstract class XMLReader<E extends java.lang.Enum<E>,A extends java.lang.Enum<A>,X extends java.lang.Exception>
Utility class for reading XML documents. Please consult test case
XMLReaderTest
to see how this class is intended to be used.
Constructor Summary | |
---|---|
XMLReader(java.io.File file,
IXMLResolver<E,A> xmlResolver)
Create new reader. |
|
XMLReader(java.io.File file,
java.lang.String encoding,
IXMLResolver<E,A> xmlResolver)
Create reader. |
|
XMLReader(java.io.File file,
java.lang.String encoding,
java.net.URL schemaURL,
IXMLResolver<E,A> xmlResolver)
Create reader. |
|
XMLReader(java.io.File file,
java.net.URL schemaURL,
IXMLResolver<E,A> xmlResolver)
Create reader. |
Method Summary | ||
---|---|---|
protected boolean |
getBooleanAttribute(A attribute)
Get boolean value of an attribute. |
|
protected java.lang.String |
getChildText(E childElement)
Get the text content of a child element of the current element. |
|
protected
|
getEnumAttribute(A attribute,
java.lang.Class<T> enumClass)
Translate attribute value to an enumeration element. |
|
protected int |
getIntAttribute(A attribute)
Get int value of an attribute. |
|
protected long |
getLongAttribute(A attribute)
Get long value of an attribute. |
|
protected java.lang.String |
getStringAttribute(A attribute)
Get attribute value. |
|
protected java.lang.String |
getText()
Get text content of current node. |
|
protected void |
parseFile()
Parse file. |
|
protected void |
processChildElements(IXMLElementProcessor<E,X> processor)
Process the child elements of the current element with a given processor. |
|
protected void |
processDecendantElements(IXMLElementProcessor<E,X> processor)
Process all descendant elements of the current element with a given processor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLReader(java.io.File file, IXMLResolver<E,A> xmlResolver)
file
- the file to be readxmlResolver
- resolvers used by this readerpublic XMLReader(java.io.File file, java.lang.String encoding, IXMLResolver<E,A> xmlResolver)
file
- the file to be readencoding
- XML encoding of the file. No encoding is set if
null
.xmlResolver
- resolvers used by this readerpublic XMLReader(java.io.File file, java.net.URL schemaURL, IXMLResolver<E,A> xmlResolver)
file
- the file to be readschemaURL
- the URL pointing to the schema that is used for validation. No
validation will be performed if null
.xmlResolver
- resolvers used by this readerpublic XMLReader(java.io.File file, java.lang.String encoding, java.net.URL schemaURL, IXMLResolver<E,A> xmlResolver)
file
- the file to be readencoding
- XML encoding of the file. No encoding is set if
null
.schemaURL
- the URL pointing to the schema that is used for validation. No
validation will be performed if null
.xmlResolver
- resolvers used by this readerMethod Detail |
---|
protected boolean getBooleanAttribute(A attribute)
boolean
value of an attribute.
null
values is defined by
Boolean.valueOf(String)
.protected java.lang.String getChildText(E childElement)
childElement
- the child element
null
if the current element doesn't have
the requested child elementprotected <T extends java.lang.Enum<T>> T getEnumAttribute(A attribute, java.lang.Class<T> enumClass)
attribute
- the attributeenumClass
- the enumeration class
null
values is defined by
Enum.valueOf(Class, String)
.protected int getIntAttribute(A attribute)
int
value of an attribute.
null
values is defined by
Integer.valueOf(String)
.protected long getLongAttribute(A attribute)
long
value of an attribute.
null
values is defined by
Integer.valueOf(String)
.protected java.lang.String getStringAttribute(A attribute)
null
if attribute is
undefined.protected java.lang.String getText()
protected void parseFile() throws org.xml.sax.SAXException, java.io.IOException
Sub classes should typically wrap this method with a proper error handling mechanism.
org.xml.sax.SAXException
- if a parsing exceptions occurs
java.io.IOException
- if an IO exception occurs.protected void processChildElements(IXMLElementProcessor<E,X> processor) throws X extends java.lang.Exception
IXMLElementProcessor.getTargetElement()
.
processor
- the processor used to process the elements
X
- if the processor throws an exception
X extends java.lang.Exception
protected void processDecendantElements(IXMLElementProcessor<E,X> processor) throws X extends java.lang.Exception
processChildElements(IXMLElementProcessor)
, not only direct
child elements are processed. Descendant elements are processed in the
sequence they are found during a top-down, left-right traversal of the
XML document.
Target elements are specified by
IXMLElementProcessor.getTargetElement()
.
processor
- the processor used to process the elements
X
- if the processor throws an exception
X extends java.lang.Exception
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |