org.enhydra.shark.xpdl
Class XMLElement

java.lang.Object
  extended by org.enhydra.shark.xpdl.XMLElement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
XMLAttribute, XMLBaseForCollectionAndComplex, XMLComplexChoice, XMLSimpleElement

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

Base class for representing elements from XML schema.

Author:
Sasa Bojanic
See Also:
Serialized Form

Field Summary
protected  boolean isReadOnly
          Indicates if an element is read only.
protected  java.util.List listeners
           
protected  boolean notifyListeners
           
protected  boolean notifyMainListeners
           
protected  java.lang.Integer originalElementHashCode
           
protected  XMLElement parent
          Reference to parent object in DOM tree.
protected  java.lang.String value
          Supposed to contain the value for XML element.
 
Constructor Summary
XMLElement(XMLElement parent, boolean isRequired)
          Creates a new instance of element: sets name to name of concrete class implementation of this abstract class, and parent and isRequired properties to the specified ones.
XMLElement(XMLElement parent, java.lang.String name, boolean isRequired)
          Creates a new instance of element: sets name, parent isRequired properties to specified ones.
 
Method Summary
 void addListener(XMLElementChangeListener listener)
           
 java.lang.Object clone()
          Used to create exact copy of the element.
protected  XMLElementChangeInfo createInfo(java.lang.Object oldVal, java.lang.Object newVal, java.util.List changedSubElements, int action)
           
 boolean equals(java.lang.Object e)
           
 java.util.List getListeners()
           
protected  XMLElement getMainElement()
           
 java.lang.Integer getOriginalElementHashCode()
           
 XMLElement getParent()
          Gets the parent element in DOM tree.
 boolean isEmpty()
          Indicates if element is empty.
protected  boolean isMainElement()
           
 boolean isReadOnly()
          Returns the 'read only' status of element.
 boolean isRequired()
          Returns if the element is required or not, which is defined by XPDL schema.
 void makeAs(XMLElement el)
           
protected  void notifyListeners(XMLElementChangeInfo info)
           
protected  void notifyMainListeners(XMLElementChangeInfo info)
           
 boolean removeListener(XMLElementChangeListener listener)
           
 void setNotifyListeners(boolean notify)
           
 void setNotifyMainListeners(boolean notify)
           
 void setParent(XMLElement el)
          Sets the parent element in DOM tree.
 void setReadOnly(boolean ro)
          Sets 'read only' property of element to specified value.
 void setValue(java.lang.String v)
          Sets the element value.
 java.lang.String toName()
          Returns the name of element.
 java.lang.String toValue()
          Returns the element value.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected transient java.util.List listeners

notifyMainListeners

protected transient boolean notifyMainListeners

notifyListeners

protected transient boolean notifyListeners

originalElementHashCode

protected java.lang.Integer originalElementHashCode

value

protected java.lang.String value
Supposed to contain the value for XML element. This is true for simple elements and attributes, more complex elements uses it as they need.


isReadOnly

protected boolean isReadOnly
Indicates if an element is read only.


parent

protected XMLElement parent
Reference to parent object in DOM tree.

Constructor Detail

XMLElement

public XMLElement(XMLElement parent,
                  boolean isRequired)
Creates a new instance of element: sets name to name of concrete class implementation of this abstract class, and parent and isRequired properties to the specified ones.

It also sets the value of this element to an empty String.


XMLElement

public XMLElement(XMLElement parent,
                  java.lang.String name,
                  boolean isRequired)
Creates a new instance of element: sets name, parent isRequired properties to specified ones.

It also sets the value of this element to an empty String.

Method Detail

makeAs

public void makeAs(XMLElement el)

setReadOnly

public void setReadOnly(boolean ro)
Sets 'read only' property of element to specified value. This enables/disables editing of the element value for the simple elements and attributes, or changes to attributes and elements of complex objects and collections.

If element is read only, and one wants to change its property, the RuntimeException will be thrown.


isReadOnly

public boolean isReadOnly()
Returns the 'read only' status of element.

If element is read only, and one wants to change its property, the RuntimeException will be thrown.


isRequired

public boolean isRequired()
Returns if the element is required or not, which is defined by XPDL schema. If element is required, its value must be defined (In the case of complex elements, all the required subelements must be defined). Otherwise, the whole Package won't be valid by the XPDL schema.


isEmpty

public boolean isEmpty()
Indicates if element is empty.


setValue

public void setValue(java.lang.String v)
Sets the element value. If it is simple element or an non-choice attribute, this sets the actual value of the element. If it is choice attribute, it sets the choosen value. Only some complex elements (Condition, SchemaType, and ExtendedAttribute) allows you to use this method, while others will throw RuntimeException.


toValue

public java.lang.String toValue()
Returns the element value.


toName

public java.lang.String toName()
Returns the name of element.


getParent

public XMLElement getParent()
Gets the parent element in DOM tree.


setParent

public void setParent(XMLElement el)
Sets the parent element in DOM tree.

This method is used when collection, complex element or complex choice is cloned, to set new parent element of the cloned sub-elements.


clone

public java.lang.Object clone()
Used to create exact copy of the element.

Overrides:
clone in class java.lang.Object

getOriginalElementHashCode

public java.lang.Integer getOriginalElementHashCode()

equals

public boolean equals(java.lang.Object e)
Overrides:
equals in class java.lang.Object

getListeners

public java.util.List getListeners()

addListener

public void addListener(XMLElementChangeListener listener)

removeListener

public boolean removeListener(XMLElementChangeListener listener)

notifyListeners

protected void notifyListeners(XMLElementChangeInfo info)

notifyMainListeners

protected void notifyMainListeners(XMLElementChangeInfo info)

getMainElement

protected XMLElement getMainElement()

isMainElement

protected boolean isMainElement()

setNotifyMainListeners

public void setNotifyMainListeners(boolean notify)

setNotifyListeners

public void setNotifyListeners(boolean notify)

createInfo

protected XMLElementChangeInfo createInfo(java.lang.Object oldVal,
                                          java.lang.Object newVal,
                                          java.util.List changedSubElements,
                                          int action)