|
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 Enum<E>,A extends Enum<A>,X extends 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(File file,
IXMLResolver<E,A> xmlResolver)
Create new reader. |
|
XMLReader(File file,
String encoding,
IXMLResolver<E,A> xmlResolver)
Create reader. |
|
XMLReader(File file,
String encoding,
URL schemaURL,
IXMLResolver<E,A> xmlResolver)
Create reader. |
|
XMLReader(File file,
URL schemaURL,
IXMLResolver<E,A> xmlResolver)
Create reader. |
|
| Method Summary | ||
|---|---|---|
protected boolean |
getBooleanAttribute(A attribute)
Get boolean value of an attribute. |
|
protected String |
getChildText(E childElement)
Get the text content of a child element of the current element. |
|
protected
|
getEnumAttribute(A attribute,
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 String |
getStringAttribute(A attribute)
Get attribute value. |
|
protected 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(File file,
IXMLResolver<E,A> xmlResolver)
file - the file to be readxmlResolver - resolvers used by this reader
public XMLReader(File file,
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 reader
public XMLReader(File file,
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 reader
public XMLReader(File file,
String encoding,
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 reader| Method Detail |
|---|
protected boolean getBooleanAttribute(A attribute)
boolean value of an attribute.
null values is defined by
Boolean.valueOf(String).protected String getChildText(E childElement)
childElement - the child element
null if the current element doesn't have
the requested child element
protected <T extends Enum<T>> T getEnumAttribute(A attribute,
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 String getStringAttribute(A attribute)
null if attribute is
undefined.protected String getText()
protected void parseFile()
throws SAXException,
IOException
Sub classes should typically wrap this method with a proper error handling mechanism.
SAXException - if a parsing exceptions occurs
IOException - if an IO exception occurs.
protected void processChildElements(IXMLElementProcessor<E,X> processor)
throws X extends Exception
IXMLElementProcessor.getTargetElement().
processor - the processor used to process the elements
X - if the processor throws an exception
X extends Exception
protected void processDecendantElements(IXMLElementProcessor<E,X> processor)
throws X extends 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 Exception
|
TUM CCSM Commons | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||