|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eigenbase.xom.DOMElementParser
public class DOMElementParser
DOMElementParser is a utility wrapper around DOMWrapper. Implements a parseable stream of child DOMWrappers and also provides validation on an XML document beyond the DTD.
![]() |
![]() |
![]() |
![]() |
Constructor Summary | |
---|---|
DOMElementParser(DOMWrapper wrapper,
String prefix,
Class enclosure)
Constructs a new ElementParser based on an Element of the XML parse tree wrapped in a DOMWrapper, and a prefix (to be applied to all element tags except the root), and the name of the enclosing class. |
Method Summary | |
---|---|
NodeDef[] |
classArray(Class elemClass,
int min,
int max)
This function retrieves a collection of elements which are subclasses of the given class, returning them as an array. |
NodeDef[] |
getArray(Class elemClass,
int min,
int max)
This function retrieves a collection of elements which are subclasses of the given class, returning them as an array. |
Object |
getAttribute(String attrName,
String attrType,
String defaultValue,
String[] values,
boolean required)
Retrieve an Attribute from the parser. |
NodeDef |
getElement(Class elementClass,
boolean required)
This function retrieves an Element from this parser, advancing the parser if the element is found. |
static Class |
getPluginClass(Class managerClass)
Get a Class object representing a plugin class, given a manager class that implements the static method getXMLDefClass(). |
static Class |
getPluginClass(String packageName,
String className)
Get a Class object representing a plugin class, identified either directly by a Java package and Java class name, or indirectly by a Java package and Java class which defines a method called getXMLDefClass() to return the appropriate class. |
String |
getString(String elementName,
boolean required)
This function retrieves a String element from this parser, advancing the parser if the element is found. |
String[] |
getStringArray(String elemName,
int min,
int max)
This function returns a collection of String elements of the given name, returning them as an array. |
String |
getText()
This function is used to return a CDATA section as text. |
int |
lastOptionIndex()
Returns the option index of the element returned through the last requiredOption call. |
DOMWrapper[] |
optionalArray(String elemName,
int min,
int max)
This function retrieves a collection of elements with the given name, returning them as an array. |
String |
optionalAttribute(String attrName)
This function retrieves an optional Attribute by name from the current Element. |
Boolean |
optionalBooleanAttribute(String attrName)
This function retrieves an optional Attribute by name from the current Element, converting it to an Boolean. |
Double |
optionalDoubleAttribute(String attrName)
This function retrieves an optional Attribute by name from the current Element, converting it to a Double. |
DOMWrapper |
optionalElement(String elementName)
This function retrieves an optional Element from this parser, advancing the parser if the element is found. |
Integer |
optionalIntegerAttribute(String attrName)
This function retrieves an optional Attribute by name from the current Element, converting it to an Integer. |
String |
optionalString(String elementName)
This function retrieves an optional String element from this parser, advancing the parser if the element is found. |
String |
requiredAttribute(String attrName)
This function retrieves a required Attribute by name from the current Element. |
Boolean |
requiredBooleanAttribute(String attrName)
This function retrieves an required Attribute by name from the current Element, converting it to a Boolean. |
NodeDef |
requiredClass(Class classTemplate)
This function retrieves a required Element of a specific class from this parser, advancing the parser after the read. |
static String |
requiredDefAttribute(DOMWrapper wrapper,
String attrName,
String defaultVal)
This static version of requiredAttribute uses any element definition as a basis for the attribute. |
DOMWrapper |
requiredElement(String elementName)
This function retrieves a required Element from this parser, advancing the parser after the read. |
Integer |
requiredIntegerAttribute(String attrName)
This function retrieves an required Attribute by name from the current Element, converting it to an Integer. |
DOMWrapper |
requiredOption(String[] elementNames)
This function retrieves a required element which may have one of a number of names. |
String |
requiredString(String elementName)
This function retrieves a required String element from this parser, advancing the parser after the read. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DOMElementParser(DOMWrapper wrapper, String prefix, Class enclosure) throws XOMException
XOMException
wrapper
- a DOMWrapper representing the section of the XML parse tree
to traverse.Method Detail |
---|
public String requiredString(String elementName) throws XOMException
XOMException
- if there is no element with the given name.elementName
- the name of the element to retrieve.
public String optionalString(String elementName) throws XOMException
XOMException
elementName
- the name of the element to retrieve.
public DOMWrapper requiredElement(String elementName) throws XOMException
XOMException
- if there is no element with the given name.elementName
- the name of the element to retrieve.
public String getText()
public DOMWrapper optionalElement(String elementName) throws XOMException
XOMException
elementName
- the name of the element to retrieve.
public DOMWrapper requiredOption(String[] elementNames) throws XOMException
XOMException
- if there are no more elements to read or if
the next element's name is not in the elementNames list.elementNames
- an array of allowed names. Names are compared in
a case-insensitive fashion.
public NodeDef requiredClass(Class classTemplate) throws XOMException
XOMException
public int lastOptionIndex()
public String requiredAttribute(String attrName) throws XOMException
XOMException
- if no attribute of this name is set.attrName
- the name of the attribute.
public static String requiredDefAttribute(DOMWrapper wrapper, String attrName, String defaultVal) throws XOMException
XOMException
- if no attribute of this name is set.wrapper
- the Element in which to find the attribute.attrName
- the name of the attribute to retrieve.defaultVal
- the default value of the attribute to retrieve.public String optionalAttribute(String attrName) throws XOMException
XOMException
attrName
- the name of the attribute.
public Integer optionalIntegerAttribute(String attrName) throws XOMException
XOMException
- if the value is set to an illegal
integer value.attrName
- the name of the attribute.
public Double optionalDoubleAttribute(String attrName) throws XOMException
XOMException
- if the value is set to an illegal
double value.attrName
- the name of the attribute.
public Integer requiredIntegerAttribute(String attrName) throws XOMException
XOMException
- if the value is not set, or is set to
an illegal integer value.attrName
- the name of the attribute.
public Boolean optionalBooleanAttribute(String attrName) throws XOMException
XOMException
- if the value is set to an illegal
integer value.attrName
- the name of the attribute.
public Boolean requiredBooleanAttribute(String attrName) throws XOMException
XOMException
attrName
- the name of the attribute.
public DOMWrapper[] optionalArray(String elemName, int min, int max) throws XOMException
XOMException
- if there are fewer than min or more than max
elements with the name elemName.elemName
- the element name.min
- the minimum number of elements required in the array. Set
this parameter to 0 to indicate no minimum.max
- the maximum number of elements allowed in the array. Set
this parameter to 0 to indicate no maximum.
public NodeDef[] classArray(Class elemClass, int min, int max) throws XOMException
XOMException
- if there are fewer than min or more than max
elements with the name elemName.elemClass
- the element class.min
- the minimum number of elements required in the array. Set
this parameter to 0 to indicate no minimum.max
- the maximum number of elements allowed in the array. Set
this parameter to 0 to indicate no maximum.
public NodeDef getElement(Class elementClass, boolean required) throws XOMException
XOMException
- if required is true and the element could not
be found.elementClass
- the Class of the element to retrieve.required
- true to throw an exception if the element is not
found, false to simply return null.
public NodeDef[] getArray(Class elemClass, int min, int max) throws XOMException
XOMException
- if there are fewer than min or more than max
elements with the name elemName.elemClass
- the element class.min
- the minimum number of elements required in the array. Set
this parameter to 0 to indicate no minimum.max
- the maximum number of elements allowed in the array. Set
this parameter to 0 to indicate no maximum.
public String getString(String elementName, boolean required) throws XOMException
XOMException
elementName
- the name of the element to retrieve.required
- true to throw an exception if the element is not
found, false to simply return null.
public String[] getStringArray(String elemName, int min, int max) throws XOMException
XOMException
- if there are fewer than min or more than max
elements with the name elemName.elemName
- the element name.min
- the minimum number of elements required in the array. Set
this parameter to 0 to indicate no minimum.max
- the maximum number of elements allowed in the array. Set
this parameter to 0 to indicate no maximum.
public static Class getPluginClass(String packageName, String className) throws XOMException
XOMException
- if the plugin class cannot be located
or if the designated class is not suitable as a plugin class.packageName
- the name of the Java package containing the
plugin class.className
- the name of the plugin definition class.public static Class getPluginClass(Class managerClass) throws XOMException
XOMException
managerClass
- any Class that implements getXMLDefClass.
public Object getAttribute(String attrName, String attrType, String defaultValue, String[] values, boolean required) throws XOMException
XOMException
attrName
- the name of the attribute to retreive.attrType
- a String naming a Java Class to serve as the type.
If attrType contains a "." character, the class is looked up directly
from the type name. Otherwise, the class is looked up in the
java.lang package. Finally, the class must have a constructor which
takes a String as an argument.defaultValue
- the default value for this attribute. If values
is set, the defaultValue must also be one of the set of values.
defaultValue may be null.values
- an array of possible values for the attribute. If
this parameter is not null, then the attribute's value must be one
of the listed set of values or an exception will be thrown.required
- if set, then this function will throw an exception
if the attribute has no value and defaultValue is null.
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |