| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Entity
Defines an XML entity in Java.
Constructor Summary | |
Entity(String name) This will create a new Entity
with the supplied name. |
Method Summary | |
Entity | addChild(Element element) This will add an Element as a child of this
Entity . |
Entity | addChild(String s) This will add a String as a child of this
Entity . |
Entity | addText(String text) This will add text to the content of this Entity . |
Object | clone() This will return a clone of this Entity . |
final boolean | equals(Object ob) This tests for equality of this Entity to the supplied
Object . |
List | getChildren() This will return a List of all the XML
elements nested directly (one level deep) within
this Entity , each in Element
form. |
String | getContent() This will return the actual textual content of this Entity . |
Document | getDocument() This retrieves the owning Document for
this Entity, or null if not a currently a member of a
Document . |
List | getMixedContent() This will return the content of the entity. |
String | getName() This returns the name of the Entity . |
Element | getParent() This will return the parent of this Entity . |
final String | getSerializedForm() This will return the Comment in XML format,
usable in an XML document. |
final int | hashCode() This returns the hash code for this Entity . |
boolean | hasMixedContent() This will indicate whether the entity has mixed content or not. |
Entity | setChildren(List children) This will set the children of this Entity to the
Element s within the supplied :ost . |
Entity | setContent(String textContent) This will set the textual content of the Entity . |
Entity | setMixedContent(List mixedContent) This will return the content of the element. |
String | toString() This returns a String representation of the
Entity , suitable for debugging. |
Constructor Detail |
public Entity(String name)
This will create a new Entity
with the supplied name.
String
name of element.Method Detail |
public Entity addChild(Element element)
This will add an Element
as a child of this
Entity
.
Element
to add as a child.Entity
- this Entity modified.public Entity addChild(String s)
This will add a String
as a child of this
Entity
.
String
to add as a child.Entity
- this Entity modified.public Entity addText(String text)
This will add text to the content of this
Entity
.
String
to add as content.Entity
- this Entity modified.public Object clone()
This will return a clone of this Entity
.
Object
- clone of this Entity
.public final boolean equals(Object ob)
This tests for equality of this Entity
to the supplied
Object
.
Object
to compare to.boolean
- whether the Entity
is
equal to the supplied Object
.public List getChildren()
This will return a List
of all the XML
elements nested directly (one level deep) within
this Entity
, each in Element
form. If the Wntity
has no nested elements,
an empty list will be returned.
This performs no recursion, so an elements nested two levels deep would have to be obtained with:
List nestedElements = currentEntity.getChildren();
for (int i=0; i<nestedElements.size(); i++) {
Element oneLevelDeep = (Element)nestedElements.get(i);
List twoLevelsDeep = oneLevelDeep.getChildren();
// Do something with these children
}
List
- list of nested
Element
instances for this entity.public String getContent()
This will return the actual textual content of this
Entity
. This will include all text within
this single element, including CDATA
sections
if they exist. If no textual value exists for the
Entity
, an empty String
is returned.
String
- value for this element.public Document getDocument()
This retrieves the owning Document
for
this Entity, or null if not a currently a member of a
Document
.
Document
owning this Entity, or null.public List getMixedContent()
This will return the content of the entity. This should be
used when the hasMixedContent()
evaluates to true
. When there is no mixed
content, it returns a List
with a single
String
(when only data is present) or a
List
with only elements (when only nested
elements are present).
List
- the mixed content of the
Element
: contains String
,
Element
, and Comment
,
objects.public String getName()
This returns the name of the
Entity
.
String
- entity name.public Element getParent()
This will return the parent of this Entity
.
If there is no parent, then this returns null
.
Entity
public final String getSerializedForm()
This will return the Comment
in XML format,
usable in an XML document.
String
- the serialized form of the
Comment
.public final int hashCode()
This returns the hash code for this Entity
.
int
- hash code.public boolean hasMixedContent()
This will indicate whether the entity has mixed content or not.
Mixed content is when an element contains both textual and
element data within it. When this evaluates to true
,
getMixedContent()
should be used for getting
element data.
Note:I think there's a better way to do this, maybe store a member variable, but I'm too tired to really think of what it is... (brett).
boolean
- indicating whether there
is mixed content (both textual data and elements).public Entity setChildren(List children)
This will set the children of this Entity
to the
Element
s within the supplied :ost
.
All existing children of this Entity
are replaced.
List
of Element
s to add.Entity
- this element modified.public Entity setContent(String textContent)
This will set the textual content of the Entity
.
If this Entity
will have both textual content
and nested elements, setMixedContent(java.util.List)
should be used instead,
String
content for Entity
.Entity
- this element modified.public Entity setMixedContent(List mixedContent)
This will return the content of the element. This should be
used when the hasMixedContent()
evaluates to true
. When there is no mixed
content, it returns a List
with a single
String
(when only data is present) or a
List
with only elements (when only nested
elements are present).
Entity
- this entity modified.public String toString()
This returns a String
representation of the
Entity
, suitable for debugging. If the XML
representation of the Entity
is desired,
getSerializedForm()
should be used.
String
- information about the
Entity
Association Links |
Entity
to Class java.util.List
Entity
to Class org.jdom.Element
to Class org.jdom.Document
| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |