|
Open SiteSearch 4.1.1 Final |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface implements an Element object. Each XML tag in a document is represented by an Element object in the XML parse tree. The elements are named with a string, have attributes, and can contain child nodes.
There are seven types of elements, DOCUMENT, ELEMENT, PCDATA, PI, META, COMMENT, and CDATA.
Field Summary | |
static int |
CDATA
Raw character data specified with special CDATA construct: <![CDATA[...]]> where ... |
static int |
COMMENT
An XML comment ( <!-- ... |
static int |
DOCUMENT
Reserved for use by the Document node only. |
static int |
DTD
Reserved for use by the DTD node only. |
static int |
ELEMENT
A general container element having optional attributes and optional child elements. |
static int |
ELEMENTDECL
An element declaration node. |
static int |
ENTITY
An entity node. |
static int |
ENTITYREF
Entity reference nodes. |
static int |
IGNORESECTION
IGNORE conditional section |
static int |
INCLUDESECTION
INCLUDE conditional section |
static int |
NAMESPACE
A namespace node that declares new namespaces in the element tree. |
static int |
NOTATION
A notation node. |
static int |
PCDATA
A text element that has no children or attributes and that contains parsed character data. |
static int |
PI
A processing instruction node ( <? ... |
static int |
WHITESPACE
Ignorable white space between elements. |
Method Summary | |
void |
addChild(Element elem,
Element after)
Adds a child to this element. |
void |
addChild(Element elem,
int pos,
int reserved)
Adds a child to this element. |
Object |
getAttribute(Name n)
Retrieves an attribute's value given its name. |
Object |
getAttribute(String name)
Retrieves an attribute's value given its name. |
Enumeration |
getAttributes()
Retrieves an enumeration for the element attributes. |
Element |
getChild(int index)
Retrieves the child element by index. |
ElementCollection |
getChildren()
Returns an element collection of the children of this element. |
Enumeration |
getElements()
Returns an enumeration of the children of this element. |
Element |
getParent()
Retrieves the parent of this element. |
Name |
getTagName()
Retrieves the name of the tag as a string. |
String |
getText()
Returns the non-marked-up text contained by this element. |
int |
getType()
Retrieves the type of the element. |
int |
numAttributes()
Retrieves the number of attributes. |
int |
numElements()
Retrieves the number of child elements. |
void |
removeAttribute(Name name)
Deletes an attribute from an element. |
void |
removeAttribute(String name)
Deletes an attribute from an element. |
void |
removeChild(Element elem)
Removes a child element from the tree. |
void |
save(XMLOutputStream o)
Saves this element. |
void |
setAttribute(Name name,
Object value)
Sets the attribute of this element. |
void |
setAttribute(String name,
Object value)
Sets the attribute of this element. |
void |
setParent(Element parent)
Sets the parent of this element. |
void |
setText(String text)
Sets the text for this element. |
Element |
toSchema()
Returns the XML-DATA specification for the DTD element. |
Field Detail |
public static final int ELEMENT
public static final int PCDATA
public static final int COMMENT
public static final int DOCUMENT
public static final int DTD
public static final int PI
public static final int CDATA
public static final int ENTITY
public static final int NOTATION
public static final int ELEMENTDECL
public static final int NAMESPACE
public static final int ENTITYREF
public static final int WHITESPACE
public static final int INCLUDESECTION
public static final int IGNORESECTION
Method Detail |
public Name getTagName()
public int getType()
DOCUMENT
, ELEMENT
, PCDATA
, PI
,
META
, COMMENT
, or CDATA
.public String getText()
Document.getText
returns "William Shakespeare".
public void setText(String text)
CDATA
, PCDATA
, and COMMENT
nodes.text
- The text to set.public Element getParent()
public Enumeration getElements()
Enumeration.nextElement
returns Element
objects.EnumWrapper
for an easy way to return an empty enumeration.public ElementCollection getChildren()
EnumWrapper
for an emptyEnumeration.public int numElements()
public void addChild(Element elem, Element after)
elem
- The element to add.
The child element becomes the last element if after is null.
The child is added to the beginning of the list if after is this object.after
- The element after which to add it.public void addChild(Element elem, int pos, int reserved)
elem
- The element to add.pos
- The position to add this element (calling getChild(pos)
will return this element). If pos is less than 0, elem becomes
the new last element.reserved
- The reserved parameter.public Element getChild(int index)
index
- The index of the child element.public void removeChild(Element elem)
elem
- The element to remove.public Enumeration getAttributes()
Attribute
objects.EnumWrapper
for returning empty enumerations).Attribute
public int numAttributes()
public Object getAttribute(String name)
name
- The name of the attribute.public Object getAttribute(Name n)
name
- The name of the attribute.public void setAttribute(String name, Object value)
name
- The attribute name.value
- The attribute value.public void setAttribute(Name name, Object value)
name
- The attribute name.value
- The attribute value.public void removeAttribute(String name)
name
- The attribute to delete.public void removeAttribute(Name name)
name
- The attribute to delete.public void setParent(Element parent)
parent
- The element to set as parent.public Element toSchema()
public void save(XMLOutputStream o) throws IOException
o
- The output stream to save to.
|
Open SiteSearch 4.1.1 Final |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |