com.taursys.xml
Interface Element

All Superinterfaces:
DocumentComponent
All Known Implementing Classes:
AbstractField, Button, DocumentElement, ElementDelegate

public interface Element
extends DocumentComponent

An Element is a type of Component which binds to the Document and can have Attributes.

Version:
2.0
Author:
Marty Phelan

Method Summary
 void addAttribute(Attribute attribute)
          Add the given Attribute to this Element.
 void addTextNode(TextNode t)
          Add the given TextNode to this Element.
 Attribute createAttribute(java.lang.String attributeName)
          Creates and binds an Attribute with the given name to this Element.
 Attribute createAttribute(java.lang.String attributeName, int dataType)
          Creates and binds an Attribute of the given type with the given name to this Element.
 Attribute createAttribute(java.lang.String attributeName, java.lang.String propertyName, ValueHolder holder)
          Creates and binds an Attribute with the given name to this Element.
 Attribute createBoundAttribute(java.lang.String attributeName, java.lang.String propertyName)
          Creates and binds an Attribute with the given name to this Element.
 TextNode createBoundTextNode(java.lang.String propertyName)
          Creates and binds a TextNode with the given name to this Element.
 TextNode createTextNode()
          Creates and binds a TextNode to this Element.
 TextNode createTextNode(int dataType)
          Creates and binds a TextNode of the given type to this Element.
 TextNode createTextNode(java.lang.String propertyName, ValueHolder holder)
          Creates and binds a TextNode with the given name to this Element.
 Attribute getAttribute(java.lang.String attributeName)
          Gets an Attribute by name or null if it does not exist
 java.lang.String getAttributeText(java.lang.String attributeName)
          Gets an Attribute's text value by name or null if it does not exist
 java.lang.Object getAttributeValue(java.lang.String attributeName)
          Gets an Attribute's Object value by name or null if it does not exist
 TextNode getTextNode()
          Gets the TextNode or null if it does not exist
 java.lang.String getTextNodeText()
          Gets the TextNode's text value or null if it does not exist
 java.lang.Object getTextNodeValue()
          Gets the TextNode's Object value or null if it does not exist
 void removeAttribute(Attribute attribute)
          Removes the given Attribute from this Element and sets its parent to null.
 void removeAttribute(java.lang.String attributeName)
          Removes the Attribute with the given name from this Container if found.
 void removeTextNode()
          Removes the TextNode from this Container if exists.
 void removeTextNode(TextNode t)
          Removes the given TextNode from this Element and sets its parent to null.
 void setAttributeText(java.lang.String attributeName, java.lang.String value)
          Sets an Attribute's text value by name or does nothing if it does not exist.
 void setAttributeValue(java.lang.String attributeName, java.lang.Object value)
          Sets an Attribute's Object value by name or does nothing if it does not exist.
 void setTextNodeText(java.lang.String value)
          Sets the TextNode's text value or does nothing if it does not exist.
 void setTextNodeValue(java.lang.Object value)
          Sets the TextNode's Object value or does nothing if it does not exist.
 
Methods inherited from interface com.taursys.xml.DocumentComponent
getId, setId
 

Method Detail

addAttribute

public void addAttribute(Attribute attribute)
Add the given Attribute to this Element. No action is taken if the attribute already belongs to this Element. If the Attribute belongs to another Element as indicated by its parent, it is first removed from the old Element before it is added to this Element. Finally, it is added to this Element and its parent is set to this Element. The Attribute's addNotify method is also invoked so it will be notified of events it is interested in.

Parameters:
attribute - the Attribute to add

removeAttribute

public void removeAttribute(Attribute attribute)
Removes the given Attribute from this Element and sets its parent to null. Also invokes removeNotify on the given Attribute so it will un-register itself with any dispatchers.

Parameters:
attribute - the Attribute to remove

getAttribute

public Attribute getAttribute(java.lang.String attributeName)
Gets an Attribute by name or null if it does not exist

Parameters:
attributeName - the name of the Attribute
Returns:
an Attribute by name or null if it does not exist

getAttributeText

public java.lang.String getAttributeText(java.lang.String attributeName)
                                  throws ModelException
Gets an Attribute's text value by name or null if it does not exist

Parameters:
attributeName - the name of the Attribute
Returns:
an Attribute's text value by name or null if it does not exist
Throws:
ModelException

setAttributeText

public void setAttributeText(java.lang.String attributeName,
                             java.lang.String value)
                      throws ModelException
Sets an Attribute's text value by name or does nothing if it does not exist. Logs a warning if attribute does not exist.

Parameters:
attributeName - the name of the Attribute
value - the new String value for the Attribute
Throws:
ModelException

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String attributeName)
                                   throws ModelException
Gets an Attribute's Object value by name or null if it does not exist

Parameters:
attributeName -
Returns:
Throws:
ModelException

setAttributeValue

public void setAttributeValue(java.lang.String attributeName,
                              java.lang.Object value)
                       throws ModelException
Sets an Attribute's Object value by name or does nothing if it does not exist. Logs a warning if attribute does not exist.

Parameters:
attributeName -
value -
Throws:
ModelException

createAttribute

public Attribute createAttribute(java.lang.String attributeName)
Creates and binds an Attribute with the given name to this Element. If the Attribute already exists, the existing one is returned.

Parameters:
attributeName - name of the new Attribute
Returns:
the newly created and bound Attribute

createAttribute

public Attribute createAttribute(java.lang.String attributeName,
                                 int dataType)
Creates and binds an Attribute of the given type with the given name to this Element. If the Attribute already exists, the existing one is returned.

Parameters:
attributeName - name of the new Attribute
dataType - the data type for the new Attribute
Returns:
the newly created and bound Attribute
See Also:
DataTypes

createBoundAttribute

public Attribute createBoundAttribute(java.lang.String attributeName,
                                      java.lang.String propertyName)
Creates and binds an Attribute with the given name to this Element. The Attribute is bound to this Element's valueHolder with the given propertyName. If the Attribute already exists, the propertyName is changed and the existing Attribute is returned.

Parameters:
attributeName - name of the new Attribute
propertyName - for the new Attribute
Returns:
the newly created and bound Attribute

createAttribute

public Attribute createAttribute(java.lang.String attributeName,
                                 java.lang.String propertyName,
                                 ValueHolder holder)
Creates and binds an Attribute with the given name to this Element. The Attribute is bound to the given valueHolder with the given propertyName. If the Attribute already exists, the valueHolder and propertyName are changed and the existing Attribute is returned. The Attribute is also un-bound from this Element's valueHolder.

Parameters:
attributeName - name of the new Attribute
propertyName - for the new Attribute
holder - ValueHolder for the new Attribute
Returns:
the newly created and bound Attribute

removeAttribute

public void removeAttribute(java.lang.String attributeName)
Removes the Attribute with the given name from this Container if found. It does NOT alter the properties of the Attribute in any way.

Parameters:
attributeName - to remove

addTextNode

public void addTextNode(TextNode t)
Add the given TextNode to this Element. No action is taken if a textNode already belongs to this Element. If the TextNode belongs to another Element as indicated by its parent, it is first removed from the old Element before it is added to this Element. Finally, it is added to this Element and its parent is set to this Element. The TextNode's addNotify method is also invoked so it will be notified of events it is interested in.


removeTextNode

public void removeTextNode(TextNode t)
Removes the given TextNode from this Element and sets its parent to null. Also invokes removeNotify on the given TextNode so it will un-register itself with any dispatchers.


removeTextNode

public void removeTextNode()
Removes the TextNode from this Container if exists. It does NOT alter the properties of the TextNode in any way.


getTextNode

public TextNode getTextNode()
Gets the TextNode or null if it does not exist

Returns:
the TextNode or null if it does not exist

getTextNodeText

public java.lang.String getTextNodeText()
                                 throws ModelException
Gets the TextNode's text value or null if it does not exist

Returns:
the TextNode's text value or null if it does not exist
Throws:
ModelException

setTextNodeText

public void setTextNodeText(java.lang.String value)
                     throws ModelException
Sets the TextNode's text value or does nothing if it does not exist.

Parameters:
value - the new String value for the TextNode
Throws:
ModelException

getTextNodeValue

public java.lang.Object getTextNodeValue()
                                  throws ModelException
Gets the TextNode's Object value or null if it does not exist

Returns:
the TextNode's Object value or null if it does not exist
Throws:
ModelException

setTextNodeValue

public void setTextNodeValue(java.lang.Object value)
                      throws ModelException
Sets the TextNode's Object value or does nothing if it does not exist.

Parameters:
value - the new Object value for the TextNode
Throws:
ModelException

createTextNode

public TextNode createTextNode()
Creates and binds a TextNode to this Element. If the TextNode already exists, the existing one is returned.

Returns:
the newly created and bound TextNode

createTextNode

public TextNode createTextNode(int dataType)
Creates and binds a TextNode of the given type to this Element. If the TextNode already exists, the existing one is returned.

Parameters:
dataType - the data type for the new TextNode
Returns:
the newly created and bound TextNode
See Also:
DataTypes

createBoundTextNode

public TextNode createBoundTextNode(java.lang.String propertyName)
Creates and binds a TextNode with the given name to this Element. The TextNode is bound to this Element's valueHolder with the given propertyName. If the TextNode already exists, the propertyName is changed and the existing TextNode is returned.

Parameters:
propertyName - for the new TextNode
Returns:
the newly created and bound TextNode

createTextNode

public TextNode createTextNode(java.lang.String propertyName,
                               ValueHolder holder)
Creates and binds a TextNode with the given name to this Element. The TextNode is bound to the given valueHolder with the given propertyName. If the TextNode already exists, the valueHolder and propertyName are changed and the existing TextNode is returned. The TextNode is also un-bound from this Element's valueHolder.

Parameters:
propertyName - for the new TextNode
holder - ValueHolder for the new TextNode
Returns:
the newly created and bound TextNode


Copyright © 2007 Martin T Phelan. All Rights Reserved.