Class ModelElement
- java.lang.Object
-
- com.yahoo.vespa.model.builder.xml.dom.ModelElement
-
public class ModelElement extends Object
A w3c Element wrapper with a better API. Author unknown.
-
-
Constructor Summary
Constructors Constructor Description ModelElement(Element xml)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
asDouble()
Duration
asDuration()
long
asLong()
String
asString()
boolean
booleanAttribute(String name)
boolean
booleanAttribute(String name, boolean defaultValue)
ModelElement
child(String name)
Returns the child with the given name, or null if none.Boolean
childAsBoolean(String path)
Double
childAsDouble(String path)
Duration
childAsDuration(String path)
Integer
childAsInteger(String path)
Long
childAsLong(String path)
String
childAsString(String path)
ModelElement
childByPath(String path)
List<ModelElement>
children(String name)
If not found, return empty list.Double
doubleAttribute(String name)
Element
getXml()
Integer
integerAttribute(String name)
Returns the value of this attribute or null if not presentInteger
integerAttribute(String name, Integer defaultValue)
Long
longAttribute(String name)
double
requiredDoubleAttribute(String name)
Returns the given attribute or throws IllegalArgumentException if not presentint
requiredIntegerAttribute(String name)
Returns the given attribute or throws IllegalArgumentException if not presentString
requiredStringAttribute(String name)
Returns the content of the attribute with the given name or throws IllegalArgumentException if not presentString
stringAttribute(String name)
Returns the content of the attribute with the given name, or null if noneString
stringAttribute(String name, String defaultValue)
Returns the content of the attribute with the given name, or the default value if noneList<ModelElement>
subElements(String name)
String
toString()
-
-
-
Constructor Detail
-
ModelElement
public ModelElement(Element xml)
-
-
Method Detail
-
getXml
public Element getXml()
-
child
public ModelElement child(String name)
Returns the child with the given name, or null if none.
-
children
public List<ModelElement> children(String name)
If not found, return empty list.
-
childByPath
public ModelElement childByPath(String path)
-
asString
public String asString()
-
asDouble
public double asDouble()
-
asLong
public long asLong()
-
asDuration
public Duration asDuration()
-
requiredIntegerAttribute
public int requiredIntegerAttribute(String name)
Returns the given attribute or throws IllegalArgumentException if not present
-
integerAttribute
public Integer integerAttribute(String name)
Returns the value of this attribute or null if not present
-
booleanAttribute
public boolean booleanAttribute(String name)
-
booleanAttribute
public boolean booleanAttribute(String name, boolean defaultValue)
-
requiredDoubleAttribute
public double requiredDoubleAttribute(String name)
Returns the given attribute or throws IllegalArgumentException if not present
-
stringAttribute
public String stringAttribute(String name)
Returns the content of the attribute with the given name, or null if none
-
stringAttribute
public String stringAttribute(String name, String defaultValue)
Returns the content of the attribute with the given name, or the default value if none
-
requiredStringAttribute
public String requiredStringAttribute(String name)
Returns the content of the attribute with the given name or throws IllegalArgumentException if not present
-
subElements
public List<ModelElement> subElements(String name)
-
-