com.edustructures.sifworks
Class Element

java.lang.Object
  extended by com.edustructures.sifworks.Element
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
SIFElement, SimpleField

public abstract class Element
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

The abstract base class for all element and attribute classes in the SIF Data Objects library.

Agent developers do not generally work with this class directly.

ElementDef

Each Element instance is associated with an ElementDef that both identifies and describes the element or attribute encapsulated by this class. ElementDef constants are defined by the SIFDTD class for each element and attribute defined in the SIF Specification. These objects provide information about how to render elements in a version-dependent way, including the tag name and sequence number (which may vary from one version of SIF to the next), the SDO implementation class name, the earliest version of SIF the element or attribute appeared in, and the latest version of SIF that supports the element or attribute.

An ElementDef must be provided to the constructor.

Version:
ADK 1.0
See Also:
Serialized Form

Field Summary
static int CURRENT_SERIALIZE_VERSION
           
 
Constructor Summary
Element(ElementDef def)
          Constructor
 
Method Summary
 int compareTo(Element target)
          Compare the text value of this Element to another Element
 ElementDef getElementDef()
          Gets the metadata for this Element
 Element getParent()
          Gets the parent of this Element.
 Element getRoot()
          Enumerating the ancestry of this object to return the root Element
abstract  SIFSimpleType getSIFValue()
          Gets the SIF strongly-typed value of this element
abstract  java.lang.String getTextValue()
          Gets the text value of this element if applicable.
 boolean isChanged()
          Determines if this object is in the changed state.
 boolean isDoNotEncode()
          Determines if automatic XML Encoding of character entities should be performed on this element when rendered by the ADK.
 boolean isEmpty()
          Determines if this object is in the empty state
 void setChanged()
          Sets this DataObject and each of its children to the dirty state.
 void setChanged(boolean changed)
          Sets this DataObject and each of its children to the specified dirty state.
 void setDoNotEncode(boolean option)
          Determines if automatic XML Encoding of character entities should be performed on this element when rendered by the ADK.
 void setElementDef(ElementDef def)
          Sets the metadata for this Element.
 void setEmpty()
          Sets this DataObject and each of its children to the empty state.
 void setEmpty(boolean empty)
          Sets this DataObject and each of its children to the specified empty state.
 void setParent(Element parent)
          Sets the parent of this Element.
abstract  void setSIFValue(SIFSimpleType value)
          Sets the SIF strongly-typed value of this element
abstract  void setTextValue(java.lang.String value)
          Sets the text value of this element if applicable.
 java.lang.String toString()
          Returns the value of getTextValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRENT_SERIALIZE_VERSION

public static final int CURRENT_SERIALIZE_VERSION
See Also:
Constant Field Values
Constructor Detail

Element

public Element(ElementDef def)
Constructor

Parameters:
def - The metadata that describes this Element
Method Detail

getElementDef

public ElementDef getElementDef()
Gets the metadata for this Element

Returns:
an ElementDef that describes this Element

setElementDef

public void setElementDef(ElementDef def)
Sets the metadata for this Element.

Note this method should not generally be called by agents because the ElementDef metadata is established in the constructor. It is provided in order to support the dynamic creation of Element instances by clients that do not (or cannot) use reflection to call the default constructor. These clients can call the Class.newInstance method followed by setElementDef to construct an Element dynamically.

Parameters:
def - An ElementDef instance that describes this Element

getTextValue

public abstract java.lang.String getTextValue()
Gets the text value of this element if applicable. The default format of the text value is the SIF 1.x format

To change the format used for Text values on elements, set the ADK.setTextFormatter(SIFFormatter) property

Returns:
The text value of this element

setTextValue

public abstract void setTextValue(java.lang.String value)
Sets the text value of this element if applicable. The text value will be parsed into the native datatype of the the element.

The formatter used for parsing by default is the SIF 1.x formatter, which means this value must be able to be parsed using SIF 1.x formatting rules. To change the format used for Text values on elements, set the ADK.setTextFormatter(SIFFormatter) property

Parameters:
value - The text value of this element

setSIFValue

public abstract void setSIFValue(SIFSimpleType value)
Sets the SIF strongly-typed value of this element

Parameters:
value - The SIF Value to set

getSIFValue

public abstract SIFSimpleType getSIFValue()
Gets the SIF strongly-typed value of this element

Returns:
The value of this element as a SIFSimpleType

setChanged

public void setChanged()
Sets this DataObject and each of its children to the dirty state. An object in the dirty state will not be written to an XML stream when a SIF message is rendered.


setChanged

public void setChanged(boolean changed)
Sets this DataObject and each of its children to the specified dirty state. An object in the dirty state will not be written to an XML stream when a SIF message is rendered.

Parameters:
changed - true to set the dirty state, false to clear it

setEmpty

public void setEmpty()
Sets this DataObject and each of its children to the empty state. An object in the empty state will be written to an XML stream as an empty element with no attributes and no child elements.


setEmpty

public void setEmpty(boolean empty)
Sets this DataObject and each of its children to the specified empty state. An object in the empty state will be written to an XML stream as an empty element with no attributes and no child elements.

Parameters:
changed - true to set the empty state, false to clear it

isChanged

public boolean isChanged()
Determines if this object is in the changed state.

Returns:
true if this object has been marked changed. The return value assumes all children are in the same state.

isEmpty

public boolean isEmpty()
Determines if this object is in the empty state

Returns:
true if this object has explicitly been marked empty. The return value assumes all children are in the same state.

isDoNotEncode

public boolean isDoNotEncode()
Determines if automatic XML Encoding of character entities should be performed on this element when rendered by the ADK. By default, all elements and attributes are encoded. Use the #setDoNotEncode method to turn off automatic encoding for an element if you will be assigning XML content to its text value (e.g. if you are using SIF_ExtendedElement to exchange raw XML content with another agent).

Returns:
true if automatic XML Encoding is disabled for this element; false if enabled (the default)

setDoNotEncode

public void setDoNotEncode(boolean option)
Determines if automatic XML Encoding of character entities should be performed on this element when rendered by the ADK. By default, all elements and attributes are encoded. Use this method to turn off automatic encoding for an element if you will be assigning XML content to its text value (e.g. if you are using SIF_ExtendedElement to exchange raw XML content with another agent).

Parameters:
option - true if automatic XML Encoding is disabled for this element; false if enabled (the default)

compareTo

public int compareTo(Element target)
Compare the text value of this Element to another Element

Parameters:
target - The Element to be compared
Returns:
the value 0 if the argument's text value is lexicographically equal to this Element's text value; a value less than 0 if the argument's value is lexicographically greater than this Element's text value; and a value greater than 0 if the argument's text value is lexicographically less than this Element's text value. If one Element's text value is null and the others is not, a negative value is returned.

toString

public java.lang.String toString()
Returns the value of getTextValue

Overrides:
toString in class java.lang.Object
Returns:
The text value of this element if applicable

getParent

public Element getParent()
Gets the parent of this Element.

Returns:
this Element's parent or null if it has none
See Also:
setParent(com.edustructures.sifworks.Element)

setParent

public void setParent(Element parent)
Sets the parent of this Element.

See Also:
getParent()

getRoot

public Element getRoot()
Enumerating the ancestry of this object to return the root Element



Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.