|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.document.LiteXMLElement
public class LiteXMLElement
An element of a StructuredDocument
. StructuredDocument
s
are made up of hierarchies of elements. LiteXMLElement is part of an implementation
while makes use of XML-style document conventions, but without the overhead of a
full parser.
Nested Class Summary | |
---|---|
protected static class |
LiteXMLElement.charRange
Defines a range of characters, probably within a string. |
protected static class |
LiteXMLElement.tagRange
A tagRange is a collection of char ranges useful for describing XML structures. |
Field Summary | |
---|---|
protected LiteXMLDocument |
doc
The document associated with this Element. |
protected LiteXMLElement.tagRange |
loc
The portion of the source XML associated with this node |
protected static boolean |
paranoidConsistencyChecking
If true then every operation which modifies the state of the document will perform a consistency check. |
protected LiteXMLElement |
parent
Identifies the element which is the parent of this element. |
Constructor Summary | |
---|---|
protected |
LiteXMLElement(LiteXMLDocument doc,
LiteXMLElement.tagRange loc)
Creates new LiteXMLElement |
|
LiteXMLElement(LiteXMLDocument doc,
String name,
String val)
Creates new LiteElement |
Method Summary | |
---|---|
String |
addAttribute(Attribute newAttrib)
Adds an attribute with the given name and value. |
String |
addAttribute(String name,
String value)
Adds an attribute with the given name and value. |
protected void |
addChildTags(LiteXMLElement.charRange scanRange,
LiteXMLElement addTo)
Parse a charRange and add any tags found as content as children of a specified element. |
protected void |
adjustLocations(int beginningAt,
int by)
For this element and all its children adjust the location of its ranges by the amount specified. |
void |
appendChild(LiteXMLElement element)
Add a child element to this element. |
protected boolean |
checkConsistency()
|
protected StringBuilder |
decodeEscaped(StringBuilder target)
Given a StringBuilder find all occurrences of escaped characters which must be decoded and convert them back to their non-escaped equivalents. |
protected void |
encodeEscaped(StringBuilder target)
Given a StringBuilder find all occurrences of characters which must be escaped and convert them to their escaped equivalents. |
boolean |
equals(Object element)
|
Attribute |
getAttribute(String name)
Returns a single attribute which matches the name provided. |
protected LiteXMLElement.tagRange |
getAttributeLoc(String name,
LiteXMLElement.charRange inRange)
Returns the tagRange of the next attribute contained in the range provided. |
Enumeration<Attribute> |
getAttributes()
Returns an enumerations of the attributes associated with this object. |
Enumeration<LiteXMLElement> |
getChildren()
Returns an enumeration of the immediate children of this element. |
Enumeration<LiteXMLElement> |
getChildren(Object key)
Returns an enumeration of the immediate children of this element whose name match the specified string. |
Enumeration<LiteXMLElement> |
getChildren(String name)
Returns an enumeration of the immediate children of this element whose name match the specified string. |
(package private) LiteXMLDocument |
getDocument()
The document we are a part of. |
String |
getKey()
Get the name associated with an element. |
String |
getName()
Get the name associated with an element. |
LiteXMLElement |
getParent()
Get the parent element of this element. |
LiteXMLDocument |
getRoot()
Get the root document element of the hierarchy this element belongs to. |
protected LiteXMLElement.tagRange |
getTagRanges(StringBuilder source,
String tag,
LiteXMLElement.charRange range)
Given a source string, an optional tag and a range with in the source find either the tag specified or the next tag. |
String |
getTextValue()
Get the value (if any) associated with an element. |
protected String |
getTextValue(boolean getEncoded,
boolean trim)
Get the value (if any) associated with an element. |
String |
getValue()
Get the value (if any) associated with an element. |
protected void |
printNice(Writer into,
int indent,
boolean recurse)
Write the contents of this element and optionally its children. |
String |
toString()
A toString implementation for debugging purposes. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final transient boolean paranoidConsistencyChecking
protected final transient LiteXMLDocument doc
protected transient LiteXMLElement parent
this.parent == this
then this element is the root of the document.
If null == parent
then this element has not yet been
inserted into the document.
protected transient LiteXMLElement.tagRange loc
Constructor Detail |
---|
protected LiteXMLElement(LiteXMLDocument doc, LiteXMLElement.tagRange loc)
loc
- The location of the element within the document.doc
- The LiteXMLDocument
which is the root of the document.public LiteXMLElement(LiteXMLDocument doc, String name, String val)
doc
- The LiteXMLDocument
which is the root of the document.name
- The name of the element being created.val
- The value of the element being created or null if there is no
content to the element.Method Detail |
---|
public boolean equals(Object element)
equals
in class Object
public String toString()
toString
in class Object
public LiteXMLDocument getRoot()
getRoot
in interface Element<LiteXMLElement>
getRoot
in interface TextElement<LiteXMLElement>
getRoot
in interface XMLElement<LiteXMLElement>
public LiteXMLElement getParent()
null
is returned. If this
element is the root element of the Document then it returns itself. ie.,
this == this.getParent()
.
getParent
in interface Element<LiteXMLElement>
public Enumeration<LiteXMLElement> getChildren()
getChildren
in interface Element<LiteXMLElement>
public String getName()
getName
in interface TextElement<LiteXMLElement>
public String getKey()
getKey
in interface Element<LiteXMLElement>
getKey
in interface TextElement<LiteXMLElement>
public String getValue()
getValue
in interface Element<LiteXMLElement>
getValue
in interface TextElement<LiteXMLElement>
public void appendChild(LiteXMLElement element)
StructuredDocument.createElement(Object)
or
StructuredDocument.createElement(Object, Object)
.
appendChild
in interface Element<LiteXMLElement>
element
- The element to be added as a child.public Enumeration<LiteXMLElement> getChildren(Object key)
getChildren
in interface Element<LiteXMLElement>
key
- The key which will be matched against.
public Enumeration<LiteXMLElement> getChildren(String name)
getChildren
in interface TextElement<LiteXMLElement>
name
- The name which will be matched against.
public String getTextValue()
getTextValue
in interface TextElement<LiteXMLElement>
protected String getTextValue(boolean getEncoded, boolean trim)
getEncoded
- if true then the contents will be encoded such that
the contents will not be interpreted as XML. see
W3C XML 1.0 Specification
ie. < -> < & -> &trim
- if true trims prefix and suffix white space
protected void printNice(Writer into, int indent, boolean recurse) throws IOException
java.io.Writer
. The writing
can optionally be indented.
into
- The java.io.Writer that the output will be sent to.indent
- the number of tabs which will be inserted before each
line.recurse
- if true then also print the children of this element.
IOException
- if an io error occursprotected LiteXMLElement.tagRange getTagRanges(StringBuilder source, String tag, LiteXMLElement.charRange range)
source
- the string to searchtag
- the tag to search for in the source string. If this tag is
empty or null then we will search for the next tag.range
- describes the range of character locations in the source
string to which the search will be limited.
protected void addChildTags(LiteXMLElement.charRange scanRange, LiteXMLElement addTo)
scanRange
- the range to be parsed for sub-tagsaddTo
- the element to add any discovered children to.protected void adjustLocations(int beginningAt, int by)
beginningAt
- adjust all locations which are at or past this
location.by
- amount to adjust all matching locations.protected StringBuilder decodeEscaped(StringBuilder target)
target
- The StringBuilder which will be decoded.
protected void encodeEscaped(StringBuilder target)
target
- The StringBuilder which will be encoded in place.public Enumeration<Attribute> getAttributes()
getAttributes
in interface Attributable
protected LiteXMLElement.tagRange getAttributeLoc(String name, LiteXMLElement.charRange inRange)
name
- Name to match. null means match any name.inRange
- the limits of the locations to scan.
public String addAttribute(String name, String value)
addAttribute
in interface Attributable
name
- name of the attribute.value
- value for the attribute.
public String addAttribute(Attribute newAttrib)
addAttribute
in interface Attributable
newAttrib
- new attribute.
public Attribute getAttribute(String name)
getAttribute
in interface Attributable
name
- the attribute name
protected boolean checkConsistency()
LiteXMLDocument getDocument()
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |