public static class ERXML.E extends ERXML.Node
Constructor and Description |
---|
E(String name)
Constructs a new element.
|
E(String name,
String text)
Constructs a new element.
|
Modifier and Type | Method and Description |
---|---|
ERXML.E |
add(ERXML.Attr attribute)
Adds the given attribute to this element.
|
<T extends ERXML.Node> |
add(T child)
Adds a new node to this element.
|
List<ERXML.Attr> |
attributes()
Returns the attributes for this element.
|
ERXML.CDATA |
cdata(String cdata)
Creates and appends a new CDATA node to this element.
|
ERXML.E |
child(String name)
Returns the child element with the given name from this element, or null if there isn't one.
|
boolean |
childBoolean(String name,
boolean defaultValue)
Returns the boolean variant of the child element with the given name from this element, or defaultValue if there isn't one.
|
<T extends Enum<T>> |
childEnum(String name,
Class<T> enumClass,
T defaultValue)
Returns the enum variant of the child element with the given name from this element, or defaultValue if there isn't one.
|
float |
childFloat(String name,
float defaultValue)
Returns the float variant of the child element with the given name from this element, or defaultValue if there isn't one.
|
int |
childInt(String name,
int defaultValue)
Returns the int variant of the child element with the given name from this element, or defaultValue if there isn't one.
|
List<ERXML.Node> |
children()
Returns the children nodes of this element.
|
List<ERXML.E> |
children(String name)
Returns a list of direct children of this element that have the given name, or an empty
list if there aren't any.
|
String |
childText(String name)
Returns the text of the child element with the given name from this element, or null if there isn't one.
|
ERXML.Comment |
comment(String comment)
Creates and appends a new comment node to this element.
|
Set<ERXML.E> |
descendents(String name)
Returns a set of descendent elements of this element that have the given name, or an empty
list if there aren't any.
|
Set<String> |
descendentsText(String name)
Returns a set of the text of the descendent elements of this element that have the given name, or an empty
list if there aren't any.
|
ERXML.E |
e(String name)
Creates and appends a new element to this element.
|
ERXML.E |
e(String name,
String value)
Creates and appends a new element to this element.
|
String |
get(String attributeName)
Returns the value of the attribute with the given name, or null if there isn't one.
|
ERXML.Attr |
getAttr(String attributeName)
Returns the attribute with the given name, or null if there isn't one.
|
boolean |
getBoolean(String attributeName,
boolean defaultValue)
Returns the boolean variant of the value of the attribute with the given name, or null if there isn't one.
|
<T extends Enum<T>> |
getEnum(String attributeName,
Class<T> enumClass,
T defaultValue)
Returns the enum variant of the value of the attribute with the given name, or null if there isn't one.
|
float |
getFloat(String attributeName,
float defaultValue)
Returns the float variant of the value of the attribute with the given name, or null if there isn't one.
|
int |
getInt(String attributeName,
int defaultValue)
Returns the int variant of the value of the attribute with the given name, or null if there isn't one.
|
String |
name()
Returns the name of this element.
|
void |
remove(ERXML.Attr attribute)
Removes the given attribute from this element.
|
void |
remove(ERXML.Node child)
Removes the given node from this element.
|
ERXML.Attr |
remove(String attributeName)
Removes the attribute with the given name.
|
ERXML.E |
set(String... nvPairs)
Sets a series of attributes in the format "name1","value1", "name2","value2", ...
|
ERXML.E |
set(String name,
String value)
Sets the attribute of the given name to the given value.
|
void |
setName(String name)
Sets the name of this element.
|
ERXML.E |
setText(String text)
Sets the text value of this element.
|
String |
text()
Returns the text value of this element, or null if there isn't one.
|
ERXML.Text |
text(String text)
Creates and appends a new text node to this element.
|
ERXML.Text |
textNode()
Returns the text value of this element, or null if there isn't one.
|
void |
visit(ERXML.Visitor visitor)
Visits this item and any of its children (if the visitor allows).
|
Node |
w3c(Document doc) |
void |
write(PrintWriter writer,
int indent)
Writes this item to the given writer with a certain indentation.
|
protected void |
writeAttributes(PrintWriter writer)
Writes the attributes of this element to the writer.
|
doc, parent, setParent, toString, writeEscapedString, writeIndent
public E(String name)
name
- the name of this elementpublic void setName(String name)
name
- the name of this elementpublic String name()
public void visit(ERXML.Visitor visitor)
ERXML.Item
visit
in class ERXML.Item
visitor
- the visitor to visit withpublic ERXML.E set(String name, String value)
name
- the name of the attributevalue
- the value of the attributepublic ERXML.E set(String... nvPairs)
nvPairs
- an array of name-value pairspublic ERXML.E add(ERXML.Attr attribute)
attribute
- the attribute to addpublic ERXML.Attr getAttr(String attributeName)
attributeName
- the name of the attribute to look uppublic ERXML.Attr remove(String attributeName)
attributeName
- the name of the attribute to removepublic void remove(ERXML.Attr attribute)
attribute
- the attribute to removepublic String get(String attributeName)
attributeName
- the name of the attribute to look uppublic int getInt(String attributeName, int defaultValue)
attributeName
- the name of the attribute to lookupdefaultValue
- the default value to return if there is no attribute, or if the attribute value is nullpublic float getFloat(String attributeName, float defaultValue)
attributeName
- the name of the attribute to lookupdefaultValue
- the default value to return if there is no attribute, or if the attribute value is nullpublic boolean getBoolean(String attributeName, boolean defaultValue)
attributeName
- the name of the attribute to lookupdefaultValue
- the default value to return if there is no attribute, or if the attribute value is nullpublic <T extends Enum<T>> T getEnum(String attributeName, Class<T> enumClass, T defaultValue)
attributeName
- the name of the attribute to lookupenumClass
- the class of the enum to returndefaultValue
- the default value to return if there is no attribute, or if the attribute value is nullpublic List<ERXML.Attr> attributes()
public ERXML.E setText(String text)
text
- the new text value for this nodepublic ERXML.Text textNode()
public String text()
public List<ERXML.Node> children()
public String childText(String name)
name
- the name of the element to look uppublic int childInt(String name, int defaultValue)
name
- the name of the element to look updefaultValue
- the default value to return if there is no child node, or if the child node is emptypublic float childFloat(String name, float defaultValue)
name
- the name of the element to look updefaultValue
- the default value to return if there is no child node, or if the child node is emptypublic boolean childBoolean(String name, boolean defaultValue)
name
- the name of the element to look updefaultValue
- the default value to return if there is no child node, or if the child node is emptypublic <T extends Enum<T>> T childEnum(String name, Class<T> enumClass, T defaultValue)
name
- the name of the element to look upenumClass
- the class of the enum to returndefaultValue
- the default value to return if there is no child node, or if the child node is emptypublic ERXML.E child(String name)
name
- the name of the element to look uppublic List<ERXML.E> children(String name)
name
- the name of the children elements to look uppublic Set<String> descendentsText(String name)
name
- the name of the descendent elements to look uppublic Set<ERXML.E> descendents(String name)
name
- the name of the descendent elements to look uppublic ERXML.E e(String name)
name
- the name of the new elementpublic ERXML.E e(String name, String value)
name
- the name of the new elementvalue
- the text value of the new elementpublic ERXML.Text text(String text)
text
- the text value to appendpublic ERXML.CDATA cdata(String cdata)
cdata
- the cdata value to appendpublic ERXML.Comment comment(String comment)
comment
- the comment value to appendpublic void remove(ERXML.Node child)
child
- the child node to removepublic <T extends ERXML.Node> T add(T child)
T
- the type of the node to addchild
- the child to addprotected void writeAttributes(PrintWriter writer)
writer
- the writer to write attributes topublic void write(PrintWriter writer, int indent)
ERXML.Item
write
in class ERXML.Item
writer
- the writer to write toindent
- the current indentationpublic Node w3c(Document doc)
w3c
in class ERXML.Node
Copyright © 2002 – 2020 Project Wonder.