com.cysols.iodef
Class IElement

java.lang.Object
  extended by com.cysols.iodef.IElement
Direct Known Subclasses:
AdditionalData, Address, AlternativeID, Application, Assessment, Classification, Contact, EventData, Expectation, Flow, History, HistoryItem, Impact, Incident, IncidentSource, IODEFDocument, IPPacket, Method, Node, NPPath, OperatingSystem, Process, Record, RecordData, RelatedActivity, RID, RIDPolicy, Service, System, TraceStatus

public class IElement
extends Object

The Element represents an element in an XML document.

Author:
cysol

Field Summary
protected  List<IAttribute> attributeList
           
protected  ElementCreator elementcreator
           
protected  OrderlyMap elementsMap
           
 String myName
          element name
 
Constructor Summary
protected IElement(String name, ElementCreator creator)
          Instantiates with the specified name.
protected IElement(String uri, String name)
          Instantiates with the specified name spece and name.
 
Method Summary
 void addElement(IElement element)
          Adds the element to the end of the list of children of this element.
protected  IElement addElementValue(String key, String value)
           
protected  IAttribute createAttribute(String name)
           
protected  Element createDomElement(Document doc)
           
protected  IElement createrElement(String name)
           
protected  IAttribute getAttribute(String namespece, String name)
           
 String[] getAttributeNames()
          Returns array of name containing the attributes of this node.
protected  IAttribute[] getAttributes()
           
 String getAttributeValue(String name)
          Returns the one of attribute value for specified name.
 String getAttributeValue(String namespece, String name)
          Returns the attribute value for specified namespece and name.
 String getAttributeValueINS(String name)
          Returns The first attribute value found that matches for specified name, this method ignores name spece.
 String[] getAttributeValuesINS(String name)
          Returns the attribute values for specified name, this method ignores name spece.
protected  List getElementList(String key)
           
 String getElementName()
          Returns the element name.
 IElement[] getElements()
          Returns array of element containing the list of children.
 IElement[] getElements(String name)
          Returns the children elements that matched the specified name and null namespace in this element.
 IElement[] getElements(String namespece, String name)
          Returns the children elements that matched the specified name and namespace in this element.
 IElement[] getElementsINS(String name)
          Returns the children elements that matched the specified name in this element.
protected  String[] getElementsValue(String key)
           
protected  String getElementValue(String key)
           
 String getNameSpace()
          Returns the name spece.
 String getValue()
          Returns the node value.
 void removeAttribute(String name)
          Removes the attribute by the specified name.
 void removeAttribute(String namespece, String name)
          Removes the attribute by the specified namespece and name.
 void removeElements(String namespece, String name)
          Removes the elements by the specified namespece and name.
 void setAttribute(IAttribute attr)
          Sets the attribute node in this element.
 void setAttribute(String name, String value)
          Sets the attribute with the specified name and null namespace.
 void setAttribute(String namespece, String name, String value)
          Sets the attribute with the specified namespece and name
 void setAttributeINS(String name, String value)
          Sets the attribute with the specified name and the namespace resolved by creator.
 void setElementINS(IElement element)
          Adds the element to the end of the list of children of this element if elements with same name doesn't exist, else replaces the element to the existing elements.
 void setElementsINS(IElement[] elements)
          Adds the elements to the end of the list of children of this element if elements with same name doesn't exist, else replaces the elements to the existing elements.
protected  IElement setElementValue(String key, String value)
           
 void setNameSpace(String namespace)
          Sets the namespace in this element.
 void setValue(String value)
          Sets the node value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myName

public String myName
element name


elementsMap

protected OrderlyMap elementsMap

attributeList

protected List<IAttribute> attributeList

elementcreator

protected ElementCreator elementcreator
Constructor Detail

IElement

protected IElement(String name,
                   ElementCreator creator)
Instantiates with the specified name.

Parameters:
name - element name
creator - a instance of ElementCreator class

IElement

protected IElement(String uri,
                   String name)
Instantiates with the specified name spece and name.

Parameters:
uri - the name spec
name - the element name
Method Detail

getElementName

public String getElementName()
Returns the element name.

Returns:
the element name

setNameSpace

public void setNameSpace(String namespace)
Sets the namespace in this element.

Parameters:
namespace - the namespace uri

getNameSpace

public String getNameSpace()
Returns the name spece.

Returns:
the namespece uri

getAttributeValue

public String getAttributeValue(String name)
Returns the one of attribute value for specified name.

Parameters:
name - - defined attribute name to XML schema
Returns:
the attribute value for specified name.

getAttributeValuesINS

public String[] getAttributeValuesINS(String name)
Returns the attribute values for specified name, this method ignores name spece.

Parameters:
name - - defined attribute name to XML schema
Returns:
the attribute values for specified name.

getAttributeValueINS

public String getAttributeValueINS(String name)
Returns The first attribute value found that matches for specified name, this method ignores name spece.

Parameters:
name - - defined attribute name to XML schema
Returns:
The first attribute value for specified name.

getAttributeValue

public String getAttributeValue(String namespece,
                                String name)
Returns the attribute value for specified namespece and name.

Parameters:
namespece - - defined attribute name spece.
name - - defined attribute name.
Returns:
the attribute value for specified namespce and name.

getValue

public String getValue()
Returns the node value.

Returns:
the node value

setValue

public void setValue(String value)
Sets the node value.

Parameters:
value - node value

setAttribute

public void setAttribute(String name,
                         String value)
Sets the attribute with the specified name and null namespace.

Parameters:
name - name of attribute
value - value of attribute

setAttributeINS

public void setAttributeINS(String name,
                            String value)
Sets the attribute with the specified name and the namespace resolved by creator.

Parameters:
name - name of attribute
value - value of attribute

setAttribute

public void setAttribute(IAttribute attr)
Sets the attribute node in this element.

Parameters:
attr - the attribute node

setAttribute

public void setAttribute(String namespece,
                         String name,
                         String value)
Sets the attribute with the specified namespece and name

Parameters:
namespece - namespece of attribute
name - name of attribute
value - value of attribute

addElement

public void addElement(IElement element)
Adds the element to the end of the list of children of this element.

Parameters:
element - the element to add.

getElements

public IElement[] getElements(String namespece,
                              String name)
Returns the children elements that matched the specified name and namespace in this element. returns null if there are no children.

Parameters:
namespece - the namespace uri
name - element name
Returns:
array of element that matched the specified name and namespace, returns null if there are no children.

getElementsINS

public IElement[] getElementsINS(String name)
Returns the children elements that matched the specified name in this element. returns null if there are no children.

Parameters:
name - element name
Returns:
array of element that matched the specified name returns null if there are no children.

getElements

public IElement[] getElements(String name)
Returns the children elements that matched the specified name and null namespace in this element. returns null if there are no children.

Parameters:
name - element name
Returns:
array of element that matched the specified name and null namespace, returns null if there are no children.

setElementINS

public void setElementINS(IElement element)
Adds the element to the end of the list of children of this element if elements with same name doesn't exist, else replaces the element to the existing elements.

Parameters:
element - the element to add.

setElementsINS

public void setElementsINS(IElement[] elements)
Adds the elements to the end of the list of children of this element if elements with same name doesn't exist, else replaces the elements to the existing elements.

Parameters:
elements - the elements to add.

removeAttribute

public void removeAttribute(String name)
Removes the attribute by the specified name.

Parameters:
name - attribute name

removeAttribute

public void removeAttribute(String namespece,
                            String name)
Removes the attribute by the specified namespece and name.

Parameters:
namespece - name spece of attribute
name - name of attribute

removeElements

public void removeElements(String namespece,
                           String name)
Removes the elements by the specified namespece and name.

Parameters:
namespece - name spece of element
name - name of element

getAttributeNames

public String[] getAttributeNames()
Returns array of name containing the attributes of this node.

Returns:
array of name of attribute nodes.

getElements

public IElement[] getElements()
Returns array of element containing the list of children.

Returns:
array of element containing the list of children.

createDomElement

protected Element createDomElement(Document doc)

getElementValue

protected String getElementValue(String key)

setElementValue

protected IElement setElementValue(String key,
                                   String value)

getElementsValue

protected String[] getElementsValue(String key)

addElementValue

protected IElement addElementValue(String key,
                                   String value)

getElementList

protected List getElementList(String key)

createrElement

protected IElement createrElement(String name)

createAttribute

protected IAttribute createAttribute(String name)

getAttributes

protected IAttribute[] getAttributes()

getAttribute

protected IAttribute getAttribute(String namespece,
                                  String name)