|
Open SiteSearch 4.1.1 Final |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ORG.oclc.xml.om.ElementImpl
This class represents the default implementation of the Element
interface.
These are
created by the XML parser when using the default element factory.
Element
,
Parser
,
ElementFactory
,
ElementFactoryImpl
Field Summary | |
protected Attributes |
attrlist
The attribute list. |
Constructor Summary | |
ElementImpl()
|
|
ElementImpl(Name tag,
int type)
|
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 attrName)
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. |
boolean |
isAttributeQualified(Name attr,
DTD dtd)
Determines if the attribute is qualified. |
int |
numAttributes()
Retrieves the number of attributes. |
int |
numElements()
Retrieves the number of child elements. |
Name |
qualifyName(String string)
This is a useful method for creating a qualified Name object from the given string. |
void |
removeAttribute(Name attrName)
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 the element in XML format. |
void |
saveAttributes(Atom ns,
XMLOutputStream o)
Save the element attributes in XML format |
void |
setAttribute(Name attrName,
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. |
String |
toString()
Retrieves the string representation of this element. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected Attributes attrlist
Constructor Detail |
public ElementImpl()
public ElementImpl(Name tag, int type)
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.The
- text to set.public Element getParent()
public void setParent(Element parent)
parent
- The element to set as the parent.public Enumeration getElements()
Enumeration.nextElement
returns Element
objects.EnumWrapper for an easy way to return an empty enumeration.
getChildren
public ElementCollection getChildren()
- Returns an element collection of the children of this element.
This method must not return null.
See
EnumWrapper
for an empty enumeration.
- Specified by:
- getChildren in interface Element
- Returns:
- element collection of child objects.
numAttributes
public int numAttributes()
- Retrieves the number of attributes.
- Specified by:
- numAttributes in interface Element
- Returns:
- the number of attributes.
numElements
public int numElements()
- Retrieves the number of child elements.
- Specified by:
- numElements in interface Element
- Returns:
- the number of child elements.
addChild
public void addChild(Element elem,
Element after)
- Adds a child to this element. Any element can only
have one parent element, and so the previous parent will lose this child
from its subtree.
- Specified by:
- addChild in interface Element
- Parameters:
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.- Returns:
- No return value.
addChild
public void addChild(Element elem,
int pos,
int reserved)
- Adds a child to this element.
- Specified by:
- addChild in interface Element
- Parameters:
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.- Returns:
- No return value.
getChild
public Element getChild(int index)
- Retrieves the child element by index.
- Specified by:
- getChild in interface Element
- Parameters:
index
- The index of the child element.- Returns:
- null if there is no child by that index.
removeChild
public void removeChild(Element elem)
- Removes a child element from the tree.
- Specified by:
- removeChild in interface Element
- Parameters:
elem
- The element to remove.- Returns:
- No return value.
getAttributes
public Enumeration getAttributes()
- Retrieves an enumeration for the element attributes.
The enumeration returns
Attribute
objects.
- Specified by:
- getAttributes in interface Element
- Returns:
- the enumeration.
This method must not return null (see
EnumWrapper
for returning empty enumerations). - See Also:
Attribute
getAttribute
public Object getAttribute(String name)
- Retrieves an attribute's value given its name.
- Specified by:
- getAttribute in interface Element
- Parameters:
name
- The name of the attribute.- Returns:
- the value of the attribute; returns
null if the attribute is not found.
getAttribute
public Object getAttribute(Name attrName)
- Retrieves an attribute's value given its name.
- Specified by:
- getAttribute in interface Element
- Parameters:
name
- The name of the attribute.- Returns:
- the value of the attribute; returns
null if the attribute is not found.
setAttribute
public void setAttribute(String name,
Object value)
- Sets the attribute of this element.
- Specified by:
- setAttribute in interface Element
- Parameters:
name
- The attribute name.value
- The attribute value.- Returns:
- any previous value, if any.
removeAttribute
public void removeAttribute(String name)
- Deletes an attribute from an element.
- Specified by:
- removeAttribute in interface Element
- Parameters:
name
- The attribute to delete.- Returns:
- No return value.
removeAttribute
public void removeAttribute(Name attrName)
- Deletes an attribute from an element.
- Specified by:
- removeAttribute in interface Element
- Parameters:
attrName
- The attribute name to delete.
toString
public String toString()
- Retrieves the string representation of this element.
- Returns:
- a string representing the element.
- Overrides:
- toString in class Object
setAttribute
public void setAttribute(Name attrName,
Object value)
- Sets the attribute of this element.
- Specified by:
- setAttribute in interface Element
- Parameters:
attrName
- The attribute name.value
- The attribute value.
saveAttributes
public void saveAttributes(Atom ns,
XMLOutputStream o)
throws IOException
- Save the element attributes in XML format
isAttributeQualified
public boolean isAttributeQualified(Name attr,
DTD dtd)
- Determines if the attribute is qualified.
- Parameters:
attr
- The name of the attribute.dtd
- The Document Definition Type (DTD) in which the attribute
is found.- Returns:
- true if the attribute is qualified; otherwise, returns false.
toSchema
public Element toSchema()
- Returns the XML-DATA specification for the DTD element.
(Only applies to ElementDecl and Entity nodes).
This is DTD information represented in an XML Object Model.
See Specification for XML-Data for details.
- Specified by:
- toSchema in interface Element
save
public void save(XMLOutputStream o)
throws IOException
- Saves the element in XML format.
- Specified by:
- save in interface Element
- Parameters:
o
- The output stream to save to.- Returns:
- No return value.
- Throws:
- IOException - if an error occurs when writing to the output
stream.
qualifyName
public Name qualifyName(String string)
- This is a useful method for creating a qualified Name object
from the given string. This will parse the string and lookup
the namespace, if specified, and create the fully qualified
name. If no namespace is given, it will inherit the namespace
from this element.
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
Open SiteSearch 4.1.1
Final
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD