org.specrunner.util.xom
Class NodeHolder

java.lang.Object
  extended by org.specrunner.util.xom.NodeHolder
All Implemented Interfaces:
INodeHolder
Direct Known Subclasses:
CellAdapter, RowAdapter, TableAdapter

public class NodeHolder
extends Object
implements INodeHolder

Default implementation of element holder.

Author:
Thiago Santos

Field Summary
protected  String attributeValue
          The attribute value.
protected  nu.xom.Node node
          The node encapsulated.
 
Fields inherited from interface org.specrunner.util.xom.INodeHolder
ATTRIBUTE_ARGUMENT_PREFIX, ATTRIBUTE_COMPARATOR, ATTRIBUTE_CONVERTER, ATTRIBUTE_EVALUATION, ATTRIBUTE_PROPERTY, ATTRIBUTE_VALUE
 
Constructor Summary
NodeHolder(nu.xom.Node element)
          Create a element holder.
 
Method Summary
 void append(nu.xom.Node child)
          Append node to the node.
 void append(String text)
          Append text to the node.
 boolean attributeContains(String name, String value)
          Check if an attribute exists, and if it exists, if it contains the given value.
 boolean attributeEquals(String name, String value)
          Check if an attribute exists, and if it exists, if it is equal to the given value.
 void detach()
          Detaches the current node.
 List<String> getArguments()
          Get element arguments in a array.
 List<String> getArguments(List<String> arguments)
          Get element arguments in a array.
 String getAttribute(String name)
          Get attribute value by type.
 String getAttribute(String name, String defaultValue)
          Get attribute value by type.
 String getAttributeValue()
          Set attribute value to look for on getObject(...)
 IComparator getComparator()
          Get the comparator of the given element.
 IComparator getComparator(IComparator comparatorDefault)
          Get the comparator of the given element.
 IConverter getConverter()
          Get the converter.
 IConverter getConverter(IConverter converterDefault)
          Get the converter, if any, otherwise returns the default converter.
 nu.xom.Node getNode()
          Get the hold node.
 Object getObject(IContext context, boolean silent)
          Gets the corresponding value object.
 Object getObject(IContext context, boolean silent, IConverter converter, List<String> arguments)
          Gets the corresponding value object.
 String getQualifiedName()
          Get qualified name (include namespace).
 String getValue()
          Get element value.
 boolean hasAttribute(String name)
          Check if an given attribute is present.
 boolean hasName(String name)
          Check a tag name.
 void prepend(nu.xom.Node child)
          Prepend a note to the node.
 void prepend(String text)
          Prepend text to the node.
 void removeAttribute(String name)
          Remove a attribute.
 void setAttribute(String name, String value)
          Set attribute value.
 void setAttributeValue(String attributeValue)
          Set value attribute holder.
 void setNode(nu.xom.Node element)
          Set the hold node.
 void setValue(String text)
          Set text to a node removing all children elements.
 String toString()
           
 String toXML()
          The XML representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node

protected nu.xom.Node node
The node encapsulated.


attributeValue

protected String attributeValue
The attribute value.

Constructor Detail

NodeHolder

public NodeHolder(nu.xom.Node element)
Create a element holder.

Parameters:
element - The element.
Method Detail

getNode

public nu.xom.Node getNode()
Description copied from interface: INodeHolder
Get the hold node.

Specified by:
getNode in interface INodeHolder
Returns:
The node.

setNode

public void setNode(nu.xom.Node element)
Description copied from interface: INodeHolder
Set the hold node.

Specified by:
setNode in interface INodeHolder
Parameters:
element - The node.

detach

public void detach()
Description copied from interface: INodeHolder
Detaches the current node.

Specified by:
detach in interface INodeHolder

getAttributeValue

public String getAttributeValue()
Description copied from interface: INodeHolder
Set attribute value to look for on getObject(...) calls.Default is ATTRIBUTE_VALUE.

Specified by:
getAttributeValue in interface INodeHolder
Returns:
The attribute value holder.

setAttributeValue

public void setAttributeValue(String attributeValue)
Description copied from interface: INodeHolder
Set value attribute holder.

Specified by:
setAttributeValue in interface INodeHolder
Parameters:
attributeValue - A attribute name.

getQualifiedName

public String getQualifiedName()
Description copied from interface: INodeHolder
Get qualified name (include namespace).

Specified by:
getQualifiedName in interface INodeHolder
Returns:
The local name.

hasName

public boolean hasName(String name)
Description copied from interface: INodeHolder
Check a tag name.

Specified by:
hasName in interface INodeHolder
Parameters:
name - The name.
Returns:
true, if element name match, false, otherwise.

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: INodeHolder
Check if an given attribute is present.

Specified by:
hasAttribute in interface INodeHolder
Parameters:
name - The attribute name.
Returns:
true, if present, false, otherwise.

getAttribute

public String getAttribute(String name)
Description copied from interface: INodeHolder
Get attribute value by type.

Specified by:
getAttribute in interface INodeHolder
Parameters:
name - The name.
Returns:
The value, if exists, null, otherwise.

getAttribute

public String getAttribute(String name,
                           String defaultValue)
Description copied from interface: INodeHolder
Get attribute value by type.

Specified by:
getAttribute in interface INodeHolder
Parameters:
name - The name.
defaultValue - The defaul value.
Returns:
The value, if exists, null, otherwise.

setAttribute

public void setAttribute(String name,
                         String value)
Description copied from interface: INodeHolder
Set attribute value.

Specified by:
setAttribute in interface INodeHolder
Parameters:
name - The name.
value - The value.

removeAttribute

public void removeAttribute(String name)
Description copied from interface: INodeHolder
Remove a attribute.

Specified by:
removeAttribute in interface INodeHolder
Parameters:
name - The attribute name.

attributeContains

public boolean attributeContains(String name,
                                 String value)
Description copied from interface: INodeHolder
Check if an attribute exists, and if it exists, if it contains the given value.

Specified by:
attributeContains in interface INodeHolder
Parameters:
name - The attribute name.
value - The attribute value.
Returns:
true, if attribute exists and if contains value, false, otherwise.

attributeEquals

public boolean attributeEquals(String name,
                               String value)
Description copied from interface: INodeHolder
Check if an attribute exists, and if it exists, if it is equal to the given value.

Specified by:
attributeEquals in interface INodeHolder
Parameters:
name - The attribute name.
value - The attribute value.
Returns:
true, if attribute exists and the value matches, false, otherwise.

getValue

public String getValue()
Description copied from interface: INodeHolder
Get element value.

Specified by:
getValue in interface INodeHolder
Returns:
Element value.

setValue

public void setValue(String text)
Description copied from interface: INodeHolder
Set text to a node removing all children elements.

Specified by:
setValue in interface INodeHolder
Parameters:
text - The expected text.

prepend

public void prepend(String text)
Description copied from interface: INodeHolder
Prepend text to the node.

Specified by:
prepend in interface INodeHolder
Parameters:
text - A text.

prepend

public void prepend(nu.xom.Node child)
Description copied from interface: INodeHolder
Prepend a note to the node.

Specified by:
prepend in interface INodeHolder
Parameters:
child - A node.

append

public void append(String text)
Description copied from interface: INodeHolder
Append text to the node.

Specified by:
append in interface INodeHolder
Parameters:
text - A text.

append

public void append(nu.xom.Node child)
Description copied from interface: INodeHolder
Append node to the node.

Specified by:
append in interface INodeHolder
Parameters:
child - A node.

getConverter

public IConverter getConverter()
Description copied from interface: INodeHolder
Get the converter.

Specified by:
getConverter in interface INodeHolder
Returns:
A converter.

getConverter

public IConverter getConverter(IConverter converterDefault)
Description copied from interface: INodeHolder
Get the converter, if any, otherwise returns the default converter.

Specified by:
getConverter in interface INodeHolder
Parameters:
converterDefault - The default converter.
Returns:
A converter.

getArguments

public List<String> getArguments()
Description copied from interface: INodeHolder
Get element arguments in a array.

Specified by:
getArguments in interface INodeHolder
Returns:
The list of values set for 'arg0', 'arg1',... 'argN'.

getArguments

public List<String> getArguments(List<String> arguments)
Description copied from interface: INodeHolder
Get element arguments in a array.

Specified by:
getArguments in interface INodeHolder
Parameters:
arguments - The default arguments in case of not found.
Returns:
The list of values set for 'arg0', 'arg1',... 'argN'.

getComparator

public IComparator getComparator()
                          throws ComparatorException
Description copied from interface: INodeHolder
Get the comparator of the given element.

Specified by:
getComparator in interface INodeHolder
Returns:
The element comparator.
Throws:
ComparatorException - O comparator lookup errors.

getComparator

public IComparator getComparator(IComparator comparatorDefault)
                          throws ComparatorException
Description copied from interface: INodeHolder
Get the comparator of the given element.

Specified by:
getComparator in interface INodeHolder
Parameters:
comparatorDefault - The default comparator.
Returns:
The element comparator.
Throws:
ComparatorException - O comparator lookup errors.

getObject

public Object getObject(IContext context,
                        boolean silent)
                 throws PluginException
Description copied from interface: INodeHolder
Gets the corresponding value object.

Specified by:
getObject in interface INodeHolder
Parameters:
context - The context.
silent - Flag to evaluate silently or not.
Returns:
The value object.
Throws:
PluginException - On plugin errors.

getObject

public Object getObject(IContext context,
                        boolean silent,
                        IConverter converter,
                        List<String> arguments)
                 throws PluginException
Description copied from interface: INodeHolder
Gets the corresponding value object.

Specified by:
getObject in interface INodeHolder
Parameters:
context - The context.
silent - Flag to evaluate silently or not.
converter - The converter.
arguments - The arguments.
Returns:
The value object.
Throws:
PluginException - On plugin errors.

toXML

public String toXML()
Description copied from interface: INodeHolder
The XML representation.

Specified by:
toXML in interface INodeHolder
Returns:
The XML version.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All rights reserved.