Package org.robwork.sdurw_core
Class DOMElemPtr
- java.lang.Object
-
- org.robwork.sdurw_core.DOMElemPtr
-
public class DOMElemPtr extends java.lang.Object
Ptr stores a pointer and optionally takes ownership of the value.
-
-
Constructor Summary
Constructors Constructor Description DOMElemPtr()
Default constructor yielding a NULL-pointer.DOMElemPtr(long cPtr, boolean cMemoryOwn)
DOMElemPtr(DOMElem ptr)
Do not take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DOMElem
__ref__()
Dereferencing operator.DOMElemPtr
addAttribute(java.lang.String name)
Add an attribute element.DOMElemPtr
addChild()
Add a child with an empty name.DOMElemPtr
addChild(java.lang.String name)
Add a child element.DOMElem.Iterator
begin()
Get iterator to first child element.DOMElemCPtr
cptr()
void
delete()
DOMElem
deref()
The pointer stored in the object.DOMElem.Iterator
end()
Get iterator to last child element.boolean
equals(DOMElem p)
DOMElemPtr
getAttribute(java.lang.String name)
get a attribute with a specific name.DOMElemPtr
getAttribute(java.lang.String name, boolean optional)
get a attribute with a specific name.SWIGTYPE_p_rw__core__iter_pairT_rw__core__DOMElem__Iterator_t
getAttributes()
Get iterator to attributes.java.lang.String
getAttributeValue(java.lang.String name)
Get the value of attribute as a string.java.lang.String
getAttributeValue(java.lang.String name, java.lang.String default_value)
std::string&)boolean
getAttributeValueAsBool(java.lang.String name)
Get the value of attribute as an boolean.boolean
getAttributeValueAsBool(java.lang.String name, boolean default_value)
std::string&)double
getAttributeValueAsDouble(java.lang.String name)
Get the value of attribute as an double.double
getAttributeValueAsDouble(java.lang.String name, double default_value)
std::string&)int
getAttributeValueAsInt(java.lang.String name)
Get the value of attribute as an integer.int
getAttributeValueAsInt(java.lang.String name, int default_value)
std::string&)DOMElemPtr
getChild(java.lang.String name)
get a child with a specific name.DOMElemPtr
getChild(java.lang.String name, boolean optional)
get a child with a specific name.SWIGTYPE_p_rw__core__iter_pairT_rw__core__DOMElem__Iterator_t
getChildren()
Get iterator to child elements.static long
getCPtr(DOMElemPtr obj)
DOMElem
getDeref()
Member access operator.java.lang.String
getName()
get name of this DOMElemjava.lang.String
getValue()
get string value of this DOMElemboolean
getValueAsBool()
Get the value as a boolean.double
getValueAsDouble()
get value as an double floating point, throws an exception if this is not an
double value.vector_d
getValueAsDoubleList()
get value as a list of doubles, throws an exception if this is not a
list of doubles.vector_d
getValueAsDoubleList(int N)
get value as a list of N doubles, throws an exception if this is not a
list of N doubles.int
getValueAsInt()
get value as an integer, throws an exception if this is not an
int value.vector_s
getValueAsStringList()
get value as a list of strings, throws an exception if this is not a
list of strings.vector_s
getValueAsStringList(char stringseperator)
get value as a list of strings, throws an exception if this is not a
list of strings.boolean
hasAttribute(java.lang.String name)
test if this DOMElem has an attribute by name name.boolean
hasChild(java.lang.String name)
test if this DOMElem has a child by name name.boolean
hasChildren()
test if this DOMElem has any childrenboolean
isName(java.lang.String elemname)
test if name of this elem equals elemnameboolean
isNull()
checks if the pointer is nullboolean
isShared()
check if this Ptr has shared ownership or none
ownershipvoid
setName(java.lang.String val)
Set the name of this element.void
setValue(boolean val)
std::string&)void
setValue(double val)
std::string&)void
setValue(int val)
std::string&)void
setValue(java.lang.String val)
Set the value of this element.void
setValueString(java.lang.String val)
std::string&)
-
-
-
Constructor Detail
-
DOMElemPtr
public DOMElemPtr(long cPtr, boolean cMemoryOwn)
-
DOMElemPtr
public DOMElemPtr()
Default constructor yielding a NULL-pointer.
-
DOMElemPtr
public DOMElemPtr(DOMElem ptr)
Do not take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
-
-
Method Detail
-
getCPtr
public static long getCPtr(DOMElemPtr obj)
-
delete
public void delete()
-
deref
public DOMElem deref()
The pointer stored in the object.
-
__ref__
public DOMElem __ref__()
Dereferencing operator.
-
getDeref
public DOMElem getDeref()
Member access operator.
-
equals
public boolean equals(DOMElem p)
-
isShared
public boolean isShared()
check if this Ptr has shared ownership or none
ownership- Returns:
- true if Ptr has shared ownership, false if it has no ownership.
-
isNull
public boolean isNull()
checks if the pointer is null- Returns:
- Returns true if the pointer is null
-
cptr
public DOMElemCPtr cptr()
-
isName
public boolean isName(java.lang.String elemname)
test if name of this elem equals elemname- Parameters:
elemname
- [in] string name to test with- Returns:
- true if elemname equals name of this DOMElem, false otherwise
-
getName
public java.lang.String getName()
get name of this DOMElem- Returns:
- name of DOMElem
-
getValue
public java.lang.String getValue()
get string value of this DOMElem- Returns:
- string value of this elem
-
getValueAsInt
public int getValueAsInt()
get value as an integer, throws an exception if this is not an
int value.- Returns:
- the int value
-
getValueAsDouble
public double getValueAsDouble()
get value as an double floating point, throws an exception if this is not an
double value.- Returns:
- the double value
-
getValueAsStringList
public vector_s getValueAsStringList(char stringseperator)
get value as a list of strings, throws an exception if this is not a
list of strings. The default string seperator is semicolon (;).- Returns:
- list of strings
-
getValueAsStringList
public vector_s getValueAsStringList()
get value as a list of strings, throws an exception if this is not a
list of strings. The default string seperator is semicolon (;).- Returns:
- list of strings
-
getValueAsDoubleList
public vector_d getValueAsDoubleList()
get value as a list of doubles, throws an exception if this is not a
list of doubles. The default string seperator is space ( ).- Returns:
- list of doubles
-
getValueAsDoubleList
public vector_d getValueAsDoubleList(int N)
get value as a list of N doubles, throws an exception if this is not a
list of N doubles. The default string seperator is space ( ).- Returns:
- list of N doubles
-
getChild
public DOMElemPtr getChild(java.lang.String name, boolean optional)
get a child with a specific name. If more children with the same name occur then
it cannot be guaranteed which is returned. If optional is false then an exception will be
thrown if the child cannot be found. If optional is true then NULL is returned if child
is not found.- Parameters:
name
- [in] name of the child to findoptional
- [in]- Returns:
- the DOMElem child if found, else either NULL (is optional) or an exception is
thrown.
-
getChild
public DOMElemPtr getChild(java.lang.String name)
get a child with a specific name. If more children with the same name occur then
it cannot be guaranteed which is returned. If optional is false then an exception will be
thrown if the child cannot be found. If optional is true then NULL is returned if child
is not found.- Parameters:
name
- [in] name of the child to find
- Returns:
- the DOMElem child if found, else either NULL (is optional) or an exception is
thrown.
-
getAttribute
public DOMElemPtr getAttribute(java.lang.String name, boolean optional)
get a attribute with a specific name. If more attributes with the same name occur
then it cannot be guaranteed which is returned. If optional is false then an exception
will be thrown if the child cannot be found. If optional is true then NULL is returned if
child is not found.- Parameters:
name
- [in] name of the attribute to findoptional
- [in]- Returns:
- the DOMElem attribute if found, else either NULL (is optional) or an exception is
thrown.
-
getAttribute
public DOMElemPtr getAttribute(java.lang.String name)
get a attribute with a specific name. If more attributes with the same name occur
then it cannot be guaranteed which is returned. If optional is false then an exception
will be thrown if the child cannot be found. If optional is true then NULL is returned if
child is not found.- Parameters:
name
- [in] name of the attribute to find
- Returns:
- the DOMElem attribute if found, else either NULL (is optional) or an exception is
thrown.
-
hasChild
public boolean hasChild(java.lang.String name)
test if this DOMElem has a child by name name.- Parameters:
name
- [in] name of the child DOMElem- Returns:
- true if this DOMElem has a child with name name
-
hasChildren
public boolean hasChildren()
test if this DOMElem has any children- Returns:
- true if this DOMElem has any children
-
hasAttribute
public boolean hasAttribute(java.lang.String name)
test if this DOMElem has an attribute by name name.- Parameters:
name
- [in] name of the attribute DOMElem- Returns:
- true if this DOMElem has an attribute with name name
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String name)
Get the value of attribute as a string.- Parameters:
name
- [in] the name of the attribute.- Returns:
- the value.
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String name, java.lang.String default_value)
std::string&)- Parameters:
default_value
- [in] a default value to return if attibute is not found.
-
getAttributeValueAsInt
public int getAttributeValueAsInt(java.lang.String name)
Get the value of attribute as an integer.- Parameters:
name
- [in] the name of the attribute.- Returns:
- the value.
-
getAttributeValueAsInt
public int getAttributeValueAsInt(java.lang.String name, int default_value)
std::string&)- Parameters:
default_value
- [in] a default value to return if attibute is not found.
-
getAttributeValueAsDouble
public double getAttributeValueAsDouble(java.lang.String name)
Get the value of attribute as an double.- Parameters:
name
- [in] the name of the attribute.- Returns:
- the value.
-
getAttributeValueAsDouble
public double getAttributeValueAsDouble(java.lang.String name, double default_value)
std::string&)- Parameters:
default_value
- [in] a default value to return if attibute is not found.
-
getValueAsBool
public boolean getValueAsBool()
Get the value as a boolean.- Returns:
- boolean value.
-
getAttributeValueAsBool
public boolean getAttributeValueAsBool(java.lang.String name)
Get the value of attribute as an boolean.- Parameters:
name
- [in] the name of the attribute.- Returns:
- the value.
-
getAttributeValueAsBool
public boolean getAttributeValueAsBool(java.lang.String name, boolean default_value)
std::string&)- Parameters:
default_value
- [in] a default value to return if attibute is not found.
-
begin
public DOMElem.Iterator begin()
Get iterator to first child element.- Returns:
- iterator.
-
end
public DOMElem.Iterator end()
Get iterator to last child element.- Returns:
- iterator.
-
getChildren
public SWIGTYPE_p_rw__core__iter_pairT_rw__core__DOMElem__Iterator_t getChildren()
Get iterator to child elements.- Returns:
- iterator pair for the first and last elements.
-
getAttributes
public SWIGTYPE_p_rw__core__iter_pairT_rw__core__DOMElem__Iterator_t getAttributes()
Get iterator to attributes.- Returns:
- iterator pair for the first and last attributes.
-
addChild
public DOMElemPtr addChild()
Add a child with an empty name.- Returns:
- pointer to the new child element.
-
addChild
public DOMElemPtr addChild(java.lang.String name)
Add a child element.- Parameters:
name
- [in] name of child.- Returns:
- pointer to the new child element.
-
addAttribute
public DOMElemPtr addAttribute(java.lang.String name)
Add an attribute element.- Parameters:
name
- [in] name of the attribute.- Returns:
- pointer to the new attribute.
-
setValue
public void setValue(java.lang.String val)
Set the value of this element.- Parameters:
val
- [in] new value.
-
setValue
public void setValue(boolean val)
std::string&)
-
setValue
public void setValue(int val)
std::string&)
-
setValue
public void setValue(double val)
std::string&)
-
setName
public void setName(java.lang.String val)
Set the name of this element.- Parameters:
val
- [in] new name.
-
setValueString
public void setValueString(java.lang.String val)
std::string&)
-
-