proper.xml
Class Element

java.lang.Object
  extended by proper.xml.Node
      extended by proper.xml.Element
All Implemented Interfaces:
javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class Element
extends Node

This class represents an XML node.

Version:
$Revision: 1.2 $
Author:
FracPete

Constructor Summary
Element(Node parent, java.lang.String name)
          initializes the object with the given parent and name
Element(Node parent, java.lang.String name, java.lang.String content)
          initializes the object with the given parent, name and content
Element(java.lang.String name)
          initializes the object with the given name and NO parent
Element(java.lang.String name, java.lang.String content)
          initializes the object with the given name and content, but NO parent
 
Method Summary
 void add(javax.swing.tree.MutableTreeNode child)
          adds the given child to its own
 void addAttribute(Attribute attr)
          adds the given attribute to its own list
 java.util.Enumeration attributes()
          returns the attributes
 java.util.Enumeration children()
          returns the children
 boolean getAllowsChildren()
          whether we can add children
 Attribute getAttribute(java.lang.String name)
          returns the attribute with the given index, can be NULL
 Attribute getAttributeAt(int attIndex)
          returns the attribute at the given index
 int getAttributeCount()
          returns the number of attributes of this element
 javax.swing.tree.TreeNode getChildAt(int childIndex)
          returns the child at the given index
 int getChildCount()
          returns the number of children this element has
 java.lang.String getContent()
          returns the content of this element, can be NULL
 int getIndex(javax.swing.tree.TreeNode node)
          returns the index of the given node in its children, -1 if not found
 java.lang.String getName()
          the name of this element
 void insert(javax.swing.tree.MutableTreeNode child, int index)
          inserts the given child at the specified index
 void insertAttribute(Attribute attr, int index)
          inserts the given attribute at the specified index
 boolean isEmpty()
          checks whether we have content or not
 boolean isLeaf()
          returns whether this element is a leaf
static void main(java.lang.String[] args)
          for testing only
 void remove(int index)
          removes the element at the specified index
 void remove(javax.swing.tree.MutableTreeNode node)
          removes the given node from the elements
 void removeAll()
          removes all the children
 void removeAllAttributes()
          removes all the attributes
 void removeAttribute(Attribute attr)
          removes the given attribute from the attributes
 void removeAttribute(int index)
          removes the attribute at the specified index
 void setContent(java.lang.String content)
          sets the content of the element
 java.lang.String toString()
          returns the element as a string
 
Methods inherited from class proper.xml.Node
getDepth, getIndention, getParent, getRoot, isContainer, removeFromParent, setIndention, setIsContainer, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element(java.lang.String name)
initializes the object with the given name and NO parent


Element

public Element(java.lang.String name,
               java.lang.String content)
initializes the object with the given name and content, but NO parent


Element

public Element(Node parent,
               java.lang.String name)
initializes the object with the given parent and name


Element

public Element(Node parent,
               java.lang.String name,
               java.lang.String content)
initializes the object with the given parent, name and content

Method Detail

attributes

public java.util.Enumeration attributes()
returns the attributes


children

public java.util.Enumeration children()
returns the children

Specified by:
children in interface javax.swing.tree.TreeNode
Specified by:
children in class Node

getAllowsChildren

public boolean getAllowsChildren()
whether we can add children

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode
Specified by:
getAllowsChildren in class Node

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
returns the child at the given index

Specified by:
getChildAt in interface javax.swing.tree.TreeNode
Specified by:
getChildAt in class Node

getChildCount

public int getChildCount()
returns the number of children this element has

Specified by:
getChildCount in interface javax.swing.tree.TreeNode
Specified by:
getChildCount in class Node

getAttributeAt

public Attribute getAttributeAt(int attIndex)
returns the attribute at the given index


getAttribute

public Attribute getAttribute(java.lang.String name)
returns the attribute with the given index, can be NULL


getAttributeCount

public int getAttributeCount()
returns the number of attributes of this element


getIndex

public int getIndex(javax.swing.tree.TreeNode node)
returns the index of the given node in its children, -1 if not found

Specified by:
getIndex in interface javax.swing.tree.TreeNode
Specified by:
getIndex in class Node

isLeaf

public boolean isLeaf()
returns whether this element is a leaf

Specified by:
isLeaf in interface javax.swing.tree.TreeNode
Specified by:
isLeaf in class Node

add

public void add(javax.swing.tree.MutableTreeNode child)
adds the given child to its own


addAttribute

public void addAttribute(Attribute attr)
adds the given attribute to its own list


insert

public void insert(javax.swing.tree.MutableTreeNode child,
                   int index)
inserts the given child at the specified index

Specified by:
insert in interface javax.swing.tree.MutableTreeNode
Specified by:
insert in class Node

insertAttribute

public void insertAttribute(Attribute attr,
                            int index)
inserts the given attribute at the specified index


remove

public void remove(int index)
removes the element at the specified index

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Specified by:
remove in class Node

removeAttribute

public void removeAttribute(int index)
removes the attribute at the specified index


remove

public void remove(javax.swing.tree.MutableTreeNode node)
removes the given node from the elements

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Specified by:
remove in class Node

removeAttribute

public void removeAttribute(Attribute attr)
removes the given attribute from the attributes


removeAll

public void removeAll()
removes all the children


removeAllAttributes

public void removeAllAttributes()
removes all the attributes


getName

public java.lang.String getName()
the name of this element


setContent

public void setContent(java.lang.String content)
sets the content of the element


getContent

public java.lang.String getContent()
returns the content of this element, can be NULL


isEmpty

public boolean isEmpty()
checks whether we have content or not


toString

public java.lang.String toString()
returns the element as a string

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
for testing only