public enum XMLKeys extends Enum<XMLKeys>
_ATTR
. The class also offers some helper methods used by parsers and builders.Modifier and Type | Class and Description |
---|---|
static interface |
XMLKeys.Function<IType,RType> |
Modifier and Type | Field and Description |
---|---|
static XMLKeys.Function<String,Boolean> |
BooleanFromString |
static XMLKeys.Function<String,Double> |
DoubleFromString |
static XMLKeys.Function<String,Integer> |
IntegerFromString |
Modifier and Type | Method and Description |
---|---|
Element |
createElement(Document doc)
|
Element |
createElement(Document doc,
Element parent)
Creates an element for the given
Document doc and adds it to the list of children of the
node parent . |
boolean |
equals(String val)
Checks if this enum is labelled by the given
String val . |
Double |
getDoubleValueFor(Element el)
Gets the value of this attribute as an
Double . |
Integer |
getIntegerValueFor(Element el)
Gets the value of this attribute as an
Integer . |
String |
getValueFor(Element el)
Returns the value of the attribute labelled by this enum (if it exists).
|
Boolean |
getValueFor(Element el,
Boolean default_value)
Gets the value of this attribute as an
Boolean . |
Double |
getValueFor(Element el,
Double default_value)
Gets the value of this attribute as an
Double . |
Integer |
getValueFor(Element el,
Integer default_value)
Gets the value of this attribute as an
Integer . |
String |
getValueFor(Element el,
String default_value)
Gets the value of this attribute for the given
Element if the attribute exists. |
<R> R |
getValueFor(Element el,
XMLKeys.Function<String,R> translate)
Gets the value of this attribute converted to
R type. |
<R> R |
getValueFor(Element el,
XMLKeys.Function<String,R> translate,
R default_value)
Gets the value of this attribute converted to
R type. |
boolean |
isAttributeOf(Element el)
Checks if this enum is an attribute of the given
Element el . |
boolean |
labelsElement(Element e)
Checks if this enum labels the given
Element . |
void |
setAttribute(Element el,
String value)
Sets an attribute labelled by this enum with the given
value . |
<T> void |
setAttribute(Element el,
T value)
Sets an attribute labelled by this enum.
|
<T> void |
setNotDefaultAttribute(Element el,
T value,
T default_value)
Sets an attribute if its value is not equal to a default one.
|
static XMLKeys |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static XMLKeys[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final XMLKeys JBOTSIM
public static final XMLKeys TOPOLOGY
public static final XMLKeys CLASSES
public static final XMLKeys NODECLASS
public static final XMLKeys NODE
public static final XMLKeys LINK
public static final XMLKeys GRAPH
public static final XMLKeys LINK_RESOLVER
public static final XMLKeys MESSAGE_ENGINE
public static final XMLKeys SCHEDULER
public static final XMLKeys CLOCKCLASS
public static final XMLKeys VERSION_ATTR
public static final XMLKeys IDENTIFIER_ATTR
public static final XMLKeys DIRECTED_ATTR
public static final XMLKeys CLASS_ATTR
public static final XMLKeys SENSING_RANGE_ATTR
public static final XMLKeys COMMUNICATION_RANGE_ATTR
public static final XMLKeys WIRELESS_ENABLED_ATTR
public static final XMLKeys SOURCE_ATTR
public static final XMLKeys DESTINATION_ATTR
public static final XMLKeys DIRECTION_ATTR
public static final XMLKeys TIME_UNIT_ATTR
public static final XMLKeys NODECLASS_ATTR
public static final XMLKeys WIDTH_ATTR
public static final XMLKeys HEIGHT_ATTR
public static final XMLKeys COLOR_ATTR
public static final XMLKeys ICON_ATTR
public static final XMLKeys SIZE_ATTR
public static final XMLKeys LOCATION_X_ATTR
public static final XMLKeys LOCATION_Y_ATTR
public static final XMLKeys LOCATION_Z_ATTR
public static final XMLKeys TRACE
public static final XMLKeys ADD_NODE
public static final XMLKeys DELETE_NODE
public static final XMLKeys SELECT_NODE
public static final XMLKeys MOVE_NODE
public static final XMLKeys START_TOPOLOGY
public static final XMLKeys TIME_ATTR
public static final XMLKeys.Function<String,Boolean> BooleanFromString
public static final XMLKeys.Function<String,Integer> IntegerFromString
public static final XMLKeys.Function<String,Double> DoubleFromString
public static XMLKeys[] values()
for (XMLKeys c : XMLKeys.values()) System.out.println(c);
public static XMLKeys valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic boolean equals(String val)
String
val
.val
- the String
for which the enum is checked for equality.true
if val
is equal to the value of this enum.public boolean labelsElement(Element e)
Element
.e
- the checked Element
true
if the name of e
is the value of this enum.public void setAttribute(Element el, String value)
value
.el
- the Element
for which the attribute is set.value
- of the attributepublic <T> void setAttribute(Element el, T value)
value
. The type of
value
must be supported by a valueOf
method of String
.T
- the type of the value assigned to the attributeel
- the Element
for which the attribute is set.value
- of the attributeString.valueOf(java.lang.Object)
public <T> void setNotDefaultAttribute(Element el, T value, T default_value)
T
- the type of the value assigned to the attributeel
- the Element
for which the attribute is set.value
- of the attributedefault_value
- the default value against which value
is checked for equality.public String getValueFor(Element el)
el
- the Element
null
if it does noe exists.public boolean isAttributeOf(Element el)
Element
el
.el
- the checked Element
true
if el
has an attribute labelled with this enum.public String getValueFor(Element el, String default_value)
Element
if the attribute exists.
If element
has an attribute with the name of this enum its (String
) value is returned. If the
attribute does not exists the default_value
is returned.el
- the Element
for which the attribute is readdefault_value
- the default value returned if the attribute is not presentpublic Integer getValueFor(Element el, Integer default_value)
Integer
.
If the element has this attribute its String
value is converted into an Integer
using
Integer.valueOf(java.lang.String, int)
.el
- the Element
for which the attribute is retrieved.default_value
- the default value of the attribute if not presentpublic Integer getIntegerValueFor(Element el) throws NoSuchElementException
Integer
.
If this attribute does not exists a NoSuchElementException
is raised.el
- the Element
for which the attribute is retrieved.NoSuchElementException
- if this attribute does not exists for el
.public Double getValueFor(Element el, Double default_value)
Double
.
If the element has this attribute its String
value is converted into an Double
using
Double.valueOf(java.lang.String)
.el
- the Element
from which the attribute is retrieved.default_value
- the value returned if this attribute is not present.default_value
if not.public Double getDoubleValueFor(Element el) throws NoSuchElementException
Double
.
If this attribute does not exists a NoSuchElementException
is raised.el
- the Element
for which the attribute is retrieved.NoSuchElementException
- if this attribute does not exists for el
.public Boolean getValueFor(Element el, Boolean default_value)
Boolean
.
If the element has this attribute its String
value is converted into an Boolean
using
Boolean.valueOf(boolean)
.el
- the Element
from which the attribute is retrieved.default_value
- the value returned if this attribute is not present.default_value
if not.public <R> R getValueFor(Element el, XMLKeys.Function<String,R> translate, R default_value)
R
type.
If element el
has this enum as attribute, its String
value is translated into an R
object using the function translate
. If the attribute does not exists default_value
is returned.R
- the class used to store the value of this attribute.el
- the Element
from which the attribute is retrieved.translate
- a XMLKeys.Function
used to translate the String
value of the attribute into R
type.default_value
- the value returned if this attribute is not present.translate
.public <R> R getValueFor(Element el, XMLKeys.Function<String,R> translate) throws NoSuchElementException
R
type.
If element el
has this enum as attribute, its String
value is translated into an R
object using the function translate
. If the attribute does not exists an exception is raised.R
- the class used to store the value of this attribute.el
- the Element
from which the attribute is retrieved.translate
- a XMLKeys.Function
used to translate the String
value of the attribute into R
type.translate
.NoSuchElementException
- if this attribute does not exists for el
.