org.qtitools.qti.attribute
Class AbstractAttribute

java.lang.Object
  extended by org.qtitools.qti.attribute.AbstractAttribute
All Implemented Interfaces:
java.io.Serializable, Attribute, Validatable
Direct Known Subclasses:
MultipleAttribute, SingleAttribute

public abstract class AbstractAttribute
extends java.lang.Object
implements Attribute

Node's attribute implementation.

Author:
Jiri Kajaba
See Also:
Serialized Form

Field Summary
protected static org.slf4j.Logger logger
          Logger.
 
Constructor Summary
AbstractAttribute(XmlNode parent, java.lang.String name, boolean required, boolean supported)
          Constructs attribute.
 
Method Summary
 java.lang.String getFullName()
          Gets full name of attribute (full path from root node up to node's parent and node's name).
 java.lang.String getLoadedValue()
          Gets loaded attribute's value.
 QTIParseException getLoadingProblem()
          Gets parse exception (if there were problem while loading) or null.
 java.lang.String getName()
          Gets name of attribute.
 XmlNode getParent()
          Gets parent node of attribute.
 boolean isRequired()
          Returns true if attribute is mandatory; false otherwise (attribute is optional).
 boolean isSupported()
          Returns true if attribute is supported; false otherwise (attribute is not supported).
protected  void setLoadedValue(java.lang.String loadedValue)
          Sets new loaded value.
protected  void setLoadingProblem(QTIParseException loadingProblem)
          Sets new loading problem.
 void setSupported(boolean supported)
          Sets whenever this attribute is supported or not.
 java.lang.String toString()
           
 java.lang.String toXmlString(boolean printDefaultValue)
          Gets attribute converted to string (name="value").
 ValidationResult validate()
          Validates this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.qtitools.qti.attribute.Attribute
defaultValueToString, load, load, valueToString
 

Field Detail

logger

protected static org.slf4j.Logger logger
Logger.

Constructor Detail

AbstractAttribute

public AbstractAttribute(XmlNode parent,
                         java.lang.String name,
                         boolean required,
                         boolean supported)
Constructs attribute.

Parameters:
parent - parent of constructed attribute
name - name of constructed attribute
required - if true this attribute is required; otherwise this attribute is optional
supported - if true this attribute is supported; otherwise this attribute is unsupported
Method Detail

getParent

public XmlNode getParent()
Description copied from interface: Attribute
Gets parent node of attribute.

Specified by:
getParent in interface Attribute
Returns:
parent node of attribute

getName

public java.lang.String getName()
Description copied from interface: Attribute
Gets name of attribute.

Specified by:
getName in interface Attribute
Returns:
name of attribute

getFullName

public java.lang.String getFullName()
Description copied from interface: Attribute
Gets full name of attribute (full path from root node up to node's parent and node's name).

Specified by:
getFullName in interface Attribute
Returns:
full name of attribute (full path from root node up to node's parent and node's name)

isRequired

public boolean isRequired()
Description copied from interface: Attribute
Returns true if attribute is mandatory; false otherwise (attribute is optional).

Specified by:
isRequired in interface Attribute
Returns:
true if attribute is mandatory; false otherwise (attribute is optional)

isSupported

public boolean isSupported()
Description copied from interface: Attribute
Returns true if attribute is supported; false otherwise (attribute is not supported). This approach enables to load test even if there are unknown (not supported) attributes.

Specified by:
isSupported in interface Attribute
Returns:
true if attribute is supported; false otherwise (attribute is not supported)

setSupported

public void setSupported(boolean supported)
Sets whenever this attribute is supported or not.

Specified by:
setSupported in interface Attribute
Parameters:
supported - if true this attribute is supported; otherwise this attribute is unsupported

getLoadedValue

public java.lang.String getLoadedValue()
Description copied from interface: Attribute
Gets loaded attribute's value. If attribute has not string baseType loaded value can be different from value. For example if we have integer attribute, loaded value is a10, but value is null (a10 is not valid integer). This approach enables to load test even if there are errors.

Specified by:
getLoadedValue in interface Attribute
Returns:
loaded attribute's value

setLoadedValue

protected void setLoadedValue(java.lang.String loadedValue)
Sets new loaded value.

Parameters:
loadedValue - new loaded value
See Also:
getLoadedValue()

getLoadingProblem

public QTIParseException getLoadingProblem()
Description copied from interface: Attribute
Gets parse exception (if there were problem while loading) or null.

Specified by:
getLoadingProblem in interface Attribute
Returns:
parse exception (if there were problem while loading) or null

setLoadingProblem

protected void setLoadingProblem(QTIParseException loadingProblem)
Sets new loading problem.

Parameters:
loadingProblem - loading problem.
See Also:
getLoadingProblem()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toXmlString

public java.lang.String toXmlString(boolean printDefaultValue)
Description copied from interface: Attribute
Gets attribute converted to string (name="value"). If value is not defined or is same as defaultValue (and printDefaultValue is false), returns empty (but not null) string.

Specified by:
toXmlString in interface Attribute
Parameters:
printDefaultValue - if true, default value is printed; otherwise default value is not printed
Returns:
attribute converted to string (name="value")

validate

public ValidationResult validate()
Description copied from interface: Validatable
Validates this object.

Specified by:
validate in interface Validatable
Returns:
validation result


Copyright © 2009. All Rights Reserved.