org.specrunner.util.xom.node.core
Class NodeHolderDefault

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

public class NodeHolderDefault
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.node.INodeHolder
ATTRIBUTE_ARGUMENT_CONVERTER_PREFIX, ATTRIBUTE_ARGUMENT_FORMATTER_PREFIX, ATTRIBUTE_COMPARATOR, ATTRIBUTE_CONVERTER, ATTRIBUTE_EVALUATION, ATTRIBUTE_FORCE_CONTENT, ATTRIBUTE_FORCE_VALUE, ATTRIBUTE_FORMATTER, ATTRIBUTE_PROPERTY, ATTRIBUTE_READER, ATTRIBUTE_VALUE, DEFAULT_PROPERTY_ACCEPT_NULL_PATH, DEFAULT_PROPERTY_INVALID_PATH_AS_NULL, FEATURE_PROPERTY_ACCEPT_NULL_PATH, FEATURE_PROPERTY_INVALID_PATH_AS_NULL
 
Fields inherited from interface org.specrunner.util.expression.IAbstraction
DEFAULT_EVAL_ARGS, FEATURE_EVAL_ARGS
 
Constructor Summary
NodeHolderDefault(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.
protected  List<Object> getArgumentsLocal(IContext context, boolean silent, List<String> arguments)
          Get arguments for evaluation.
 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.
 IFormatter getFormatter()
          Get the abstraction formatter.
 IFormatter getFormatter(IFormatter formatterDefault)
          Get the abstraction formatter.
 List<String> getFormatterArguments()
          Get formatter attributes.
 List<String> getFormatterArguments(List<String> arguments)
          Get formatter arguments.
protected  Object getLocal(IContext context, boolean silent, IConverter converter, List<String> arguments)
           
 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.
protected  Object getProperty(IContext context, boolean silent)
          Get property value.
 String getQualifiedName()
          Get qualified name (include namespace).
 IReader getReader()
          Get reader object.
 IReader getReader(IReader readerDefault)
          Get reader object or default if not found.
 String getValue(IContext context)
          Get element value.
protected  Object getValue(IContext context, boolean silent)
          Get value.
 String getValue(IContext context, Object[] args)
          Get element value.
 boolean hasAttribute(String name)
          Check if an given attribute is present.
 boolean hasName(String name)
          Check a tag name.
protected  boolean isProperty()
          Is property value set.
protected  boolean notEval()
          Is evaluation turned off.
 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

NodeHolderDefault

public NodeHolderDefault(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(IContext context)
Description copied from interface: IAbstraction
Get element value.

Specified by:
getValue in interface IAbstraction
Parameters:
context - The test context.
Returns:
Element value.

getValue

public String getValue(IContext context,
                       Object[] args)
Description copied from interface: IAbstraction
Get element value.

Specified by:
getValue in interface IAbstraction
Parameters:
context - The test context.
args - Arguments to return value.
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.

getReader

public IReader getReader()
Description copied from interface: IAbstraction
Get reader object.

Specified by:
getReader in interface IAbstraction
Returns:
A reader.

getReader

public IReader getReader(IReader readerDefault)
Description copied from interface: IAbstraction
Get reader object or default if not found.

Specified by:
getReader in interface IAbstraction
Parameters:
readerDefault - The default reader.
Returns:
A reader.

getConverter

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

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

getConverter

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

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

getArguments

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

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

getArguments

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

Specified by:
getArguments in interface IAbstraction
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: IAbstraction
Get the comparator of the given element.

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

getComparator

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

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

getFormatterArguments

public List<String> getFormatterArguments()
Description copied from interface: IAbstraction
Get formatter attributes.

Specified by:
getFormatterArguments in interface IAbstraction
Returns:
Formatter attributes.

getFormatterArguments

public List<String> getFormatterArguments(List<String> arguments)
Description copied from interface: IAbstraction
Get formatter arguments.

Specified by:
getFormatterArguments in interface IAbstraction
Parameters:
arguments - Default list of arguments.
Returns:
A list of arguments.

getFormatter

public IFormatter getFormatter()
                        throws FormatterException
Description copied from interface: IAbstraction
Get the abstraction formatter.

Specified by:
getFormatter in interface IAbstraction
Returns:
A formatter if it exists, null, otherwise.
Throws:
FormatterException - On formatter lookup error.

getFormatter

public IFormatter getFormatter(IFormatter formatterDefault)
                        throws FormatterException
Description copied from interface: IAbstraction
Get the abstraction formatter.

Specified by:
getFormatter in interface IAbstraction
Parameters:
formatterDefault - Default formatter.
Returns:
A formatter if it exists, default otherwise.
Throws:
FormatterException - On formatter lookup error.

getObject

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

Specified by:
getObject in interface IAbstraction
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: IAbstraction
Gets the corresponding value object.

Specified by:
getObject in interface IAbstraction
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.

getLocal

protected Object getLocal(IContext context,
                          boolean silent,
                          IConverter converter,
                          List<String> arguments)
                   throws PluginException
Throws:
PluginException
See Also:
getObject.

isProperty

protected boolean isProperty()
Is property value set.

Returns:
true, if 'property' is set, and 'forceValue' is not true.

getProperty

protected Object getProperty(IContext context,
                             boolean silent)
                      throws PluginException
Get property value.

Parameters:
context - A context.
silent - Silent evaluation flag.
Returns:
The property value (including null), or null if property path has some null.
Throws:
PluginException - On lookup errors.

getValue

protected Object getValue(IContext context,
                          boolean silent)
                   throws PluginException
Get value.

Parameters:
context - A context.
silent - Silent evaluation flag.
Returns:
The tag value, evaluated (default is evaluate) or not (set eval='false').
Throws:
PluginException - On evaluation errors.

notEval

protected boolean notEval()
Is evaluation turned off. Default is false.

Returns:
true, if evaluation flag set to 'false', false otherwise.

getArgumentsLocal

protected List<Object> getArgumentsLocal(IContext context,
                                         boolean silent,
                                         List<String> arguments)
                                  throws PluginException
Get arguments for evaluation.

Parameters:
context - A context.
silent - Silent evaluation flag.
arguments - Value arguments.
Returns:
List of arguments.
Throws:
PluginException - On evaluation 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 © 2015. All rights reserved.