|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.xom.ElementDef
public abstract class ElementDef
ElementDef is the base class for all element definitions. It specifies the basic interface as well as provides useful services for all elements.
Constructor Summary | |
---|---|
ElementDef()
|
Method Summary | |
---|---|
void |
addChild(NodeDef child)
|
void |
addChildren(NodeDef[] children)
|
protected Object |
clone()
Clone an ElementDef. |
static NodeDef |
constructElement(DOMWrapper wrapper,
Class elemClass)
constructElement is a helper function which builds the appropriate type of ElementDef from an XML Element. |
static NodeDef |
constructElement(DOMWrapper wrapper,
Class enclosure,
String prefix)
constructElement is a helper function which builds the appropriate type of ElementDef from an XML Element. |
ElementDef |
deepCopy()
Public version of clone(); returns a deep copy of this ElementDef. |
String |
diff(ElementDef other)
The diff function compares this element against another, determining if they are exactly equal. |
protected static void |
displayAttribute(PrintWriter out,
String name,
Object value,
int indent)
This convenience function displays an XML attribute value with the given attribute name at the given indentation level. |
protected static boolean |
displayAttributeDiff(String name,
Object value1,
Object value2,
PrintWriter out,
int indent)
This convenience function displays differences in two versions of the same XML attribute value. |
boolean |
displayDiff(ElementDef other,
PrintWriter out,
int indent)
The displayDiff function compares this element definition against another, compiling a message containing all diffs. |
protected static void |
displayElement(PrintWriter out,
String name,
ElementDef value,
int indent)
This convenience function displays any ElementDef with the given parameter name at the given indentation level. |
protected static void |
displayElementArray(PrintWriter out,
String name,
NodeDef[] values,
int indent)
This convenience function displays any array of ElementDef values with the given parameter name (assumed to represent an array) at the given indentation level. |
protected static boolean |
displayElementArrayDiff(String name,
NodeDef[] values1,
NodeDef[] values2,
PrintWriter out,
int indent)
This convenience function diffs any array of ElementDef values with the given array name. |
protected static boolean |
displayElementDiff(String name,
NodeDef value1,
NodeDef value2,
PrintWriter out,
int indent)
This convenience function displays differences in the values of any two ElementDefs, returning true if they match and false if not. |
protected static void |
displayIndent(PrintWriter out,
int indent)
This function writes an indentation level to the given PrintWriter. |
protected static void |
displayString(PrintWriter out,
String name,
String value,
int indent)
This convenience function displays a String value with the given parameter name at the given indentation level. |
protected static void |
displayStringArray(PrintWriter out,
String name,
String[] values,
int indent)
This convenience function displays any array of String values with the given parameter name (assumed to represent an array) at the given indentation level. |
protected static boolean |
displayStringArrayDiff(String name,
String[] values1,
String[] values2,
PrintWriter out,
int indent)
This convenience function diffs any array of strings with the given array name. |
protected static boolean |
displayStringDiff(String name,
String value1,
String value2,
PrintWriter out,
int indent)
This convenience function displays differences in two versions of the same string object. |
void |
displayXML(XMLOutput out)
|
void |
displayXML(XMLOutput out,
int indent)
Outputs this element definition in XML to any XMLOutput. |
protected static void |
displayXMLElement(XMLOutput out,
ElementDef value)
This convenience function displays any ElementDef in XML. |
protected static void |
displayXMLElementArray(XMLOutput out,
NodeDef[] values)
This convenience function displays an array of ElementDef values in XML. |
protected static void |
displayXMLString(XMLOutput out,
String tag,
String value)
This convenience function displays a String value in XML. |
protected static void |
displayXMLStringArray(XMLOutput out,
String tag,
String[] values)
This convenience function displays a String array in XML. |
boolean |
equals(Object other)
Determines if this ElementDef is equal to other (deeply), returning true if the two are equal. |
NodeDef[] |
getChildren()
Returns the children of this node. |
protected static ElementDef[] |
getElementChildren(DOMWrapper _def,
Class clazz,
String prefix)
|
static Class |
getElementClass(DOMWrapper wrapper,
Class enclosure,
String prefix)
getElementClass is a static helper function which finds the XMLDef class corresponding to an Element. |
Location |
getLocation()
Returns the location of this element in its document. |
protected static NodeDef[] |
getMixedChildren_new(DOMWrapper _def,
Class clazz,
String prefix)
|
protected static NodeDef[] |
getMixedChildren(DOMWrapper _def,
Class clazz,
String prefix)
|
String |
getName()
Returns the name of this node's tag. |
String |
getText()
Returns the text inside this node. |
int |
getType()
Returns the type of this element. |
DOMWrapper |
getWrapper()
Retrieves the DOMWrapper which was used to create this
node. |
int |
hashCode()
Returns a unique hash of this instance. |
String |
toCompactXML()
The toCompactXML function automatically uses displayXML() to produce an XML version of this ElementDef as a String. |
String |
toString()
The toString function automatically uses display() to produce a string version of this ElementDef. |
String |
toXML()
The toXML function automatically uses displayXML() to produce an XML version of this ElementDef as a String. |
void |
verifyEqual(ElementDef other)
Verifies that this ElementDef is equal to other, throwing a XOMException with a lengthy explanation if equality fails. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eigenbase.xom.NodeDef |
---|
display |
Constructor Detail |
---|
public ElementDef()
Method Detail |
---|
public static Class getElementClass(DOMWrapper wrapper, Class enclosure, String prefix) throws XOMException
XOMException
wrapper
- the DOMWrapper whose class to look up.enclosure
- a Class which encloses the Class to lookup.prefix
- a prefix which must appear on the tag name.
public static NodeDef constructElement(DOMWrapper wrapper, Class elemClass) throws XOMException
XOMException
- if clazz has no constructor which takes Element,
or if construction fails.wrapper
- the DOM Element wrapper from which to build this class.elemClass
- the Class to use to construct this class. It must have
a constructor which takes the Element type.
public static NodeDef constructElement(DOMWrapper wrapper, Class enclosure, String prefix) throws XOMException
XOMException
- if no subclass of ElementDef can be found,
or if def is malformed.wrapper
- the DOM Element Wrapper from which to build this class.
public void displayXML(XMLOutput out, int indent)
NodeDef
displayXML
in interface NodeDef
out
- the XMLOutput class to display the XMLpublic void displayXML(XMLOutput out)
public boolean displayDiff(ElementDef other, PrintWriter out, int indent)
other
- the ElementDef to which to compare this element.out
- a PrintWriter to which to display any discovered differences,
or null if just doing an equality check (and no diff report is needed).indent
- the current indentation level (used for nice display of diffs).
public String getName()
NodeDef
getName
in interface NodeDef
public int getType()
NodeDef
DOMWrapper.getType()
.
getType
in interface NodeDef
public String getText()
NodeDef
getText
in interface NodeDef
protected static void displayIndent(PrintWriter out, int indent)
out
- the PrintWriter to which to write the indent.indent
- the indentation levelprotected static void displayString(PrintWriter out, String name, String value, int indent)
out
- the PrintWriter to which to write this String.name
- the parameter name of this string.value
- the value of the String parameter.indent
- the indentation level.protected static void displayAttribute(PrintWriter out, String name, Object value, int indent)
out
- the PrintWriter to which to write this String.name
- the attribute name.value
- the attribute value.indent
- the indentation level.protected static void displayElement(PrintWriter out, String name, ElementDef value, int indent)
out
- the PrintWriter to which to write this ElementDef.name
- the parameter name for this ElementDef.value
- the parameter's value (as an ElementDef).indent
- the indentation level.protected static void displayElementArray(PrintWriter out, String name, NodeDef[] values, int indent)
out
- the PrintWriter to which to write this ElementDef.name
- the parameter name for this ElementDef.values
- the parameter's values (as an ElementDef[] array).indent
- the indentation level.protected static void displayStringArray(PrintWriter out, String name, String[] values, int indent)
out
- the PrintWriter to which to write this ElementDef.name
- the parameter name for this ElementDef.values
- the parameter's values (as a String[] array).indent
- the indentation level.protected static void displayXMLString(XMLOutput out, String tag, String value)
out
- XMLOutput class to which to generate XML.tag
- the Tag name of this String object.value
- the String value.protected static void displayXMLElement(XMLOutput out, ElementDef value)
out
- the XMLOutput class to which to generate XML.value
- the ElementDef to display.protected static void displayXMLElementArray(XMLOutput out, NodeDef[] values)
out
- the XMLOutput class to which to generate XML.values
- the ElementDef to display.protected static void displayXMLStringArray(XMLOutput out, String tag, String[] values)
out
- the XMLOutput class to which to generate XML.tag
- the tag name for the String elements.values
- the actual string values.protected static boolean displayStringDiff(String name, String value1, String value2, PrintWriter out, int indent)
name
- the object name.value1
- the first string.value2
- the second string.out
- the PrintWriter to which to write differences.indent
- the indentation level.
protected static boolean displayAttributeDiff(String name, Object value1, Object value2, PrintWriter out, int indent)
name
- the attribute name.value1
- the first attribute value.value2
- the second attribute value.out
- the PrintWriter to which to write differences.indent
- the indentation level.
protected static boolean displayElementDiff(String name, NodeDef value1, NodeDef value2, PrintWriter out, int indent)
name
- the object name.value1
- the first value.value2
- the second value.out
- the PrintWriter to which to write differences.indent
- the indentation level.
protected static boolean displayElementArrayDiff(String name, NodeDef[] values1, NodeDef[] values2, PrintWriter out, int indent)
name
- the array name.values1
- the first array.values2
- the second array.out
- the PrintWriter to which to write differences.indent
- the indentation level.
protected static boolean displayStringArrayDiff(String name, String[] values1, String[] values2, PrintWriter out, int indent)
name
- the array name.values1
- the first array.values2
- the second array.out
- the PrintWriter to which to write differences.indent
- the indentation level.
public String toString()
toString
in class Object
public String toXML()
public String toCompactXML()
public String diff(ElementDef other)
public boolean equals(Object other)
equals
in class Object
ClassCastException
- if other is not an ElementDef.
public int hashCode()
hashCode
in class Object
public void verifyEqual(ElementDef other) throws XOMException
XOMException
other
- the ElementDef to compare to this one.protected Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public ElementDef deepCopy() throws XOMException
XOMException
public DOMWrapper getWrapper()
NodeDef
DOMWrapper
which was used to create this
node. Only works if this nodes's MetaDef.FullDefinition.keepDef
was
true (or, if it is not set, if the default
MetaDef.Model.defaultKeepDef
is true);
otherwise, returns null
.
getWrapper
in interface NodeDef
public NodeDef[] getChildren()
NodeDef
getChildren
in interface NodeDef
public void addChild(NodeDef child) throws XOMException
XOMException
public void addChildren(NodeDef[] children) throws XOMException
XOMException
protected static NodeDef[] getMixedChildren_new(DOMWrapper _def, Class clazz, String prefix) throws XOMException
XOMException
protected static NodeDef[] getMixedChildren(DOMWrapper _def, Class clazz, String prefix) throws XOMException
XOMException
protected static ElementDef[] getElementChildren(DOMWrapper _def, Class clazz, String prefix) throws XOMException
XOMException
public Location getLocation()
NodeDef
getLocation
in interface NodeDef
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |