|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavanet.staxutils.SimpleNamespaceContext
javanet.staxutils.helpers.ElementContext
public class ElementContext
Encapsulates access to contextual element information, such as the element name, attributes, and namespaces. This class is useful for recording element information in a stack to keep track of the current element c[position in a document.
| Field Summary |
|---|
| Fields inherited from class javanet.staxutils.SimpleNamespaceContext |
|---|
namespaces |
| Constructor Summary | |
|---|---|
ElementContext(QName name)
Constructs a new ElementContext with the provided name and no
enclosing context. |
|
ElementContext(QName name,
boolean isEmpty)
Constructs a new ElementContext with the provided name and empty
value, and no enclosing context. |
|
ElementContext(QName name,
ElementContext parent)
Constructs a new ElementContext with the provided name and
enclosing context. |
|
ElementContext(QName name,
ElementContext parent,
boolean isEmpty)
Constructs a new ElementContext with the provided name and
enclosing context. |
|
ElementContext(QName name,
NamespaceContext context)
Constructs a new ElementContext with the provided name and
namespace context. |
|
| Method Summary | |
|---|---|
StringBuffer |
appendPath(StringBuffer buffer)
Appends the current context path to a StringBuffer. |
int |
attributeCount()
Returns the number of attributes defined in this context. |
boolean |
attributeExists(QName name)
Determines if an attribute with the specified name exists in this context. |
Iterator |
attributeNames()
Returns an Iterator over the names of all attributes defined in this
context. |
String |
getAttribute(int idx)
Returns the value of the idxth attribute defined on
the context. |
String |
getAttribute(QName name)
Returns the value of a named attribute. |
QName |
getAttributeName(int idx)
Returns the name of the idxth attribute defined on
the context. |
int |
getDepth()
Determines the number of enclosing contexts. |
QName |
getName()
Returns the qualified name associated with the context. |
String |
getNamespacePrefix(int idx)
Returns the prefix of the idxth namespace declaration
defined in this context. |
String |
getNamespaceURI(int idx)
Returns the URI of the idxth namespace declaration
defined in this context. |
ElementContext |
getParentContext()
Returns a reference to the enclosing ElementContext. |
String |
getPath()
Returns the current context path. |
boolean |
isEmpty()
Whether this context represents an emtpy element. |
boolean |
isReadOnly()
Whether this context may be edited or not. |
boolean |
isRoot()
Determines if this context has an enclosing context or not. |
int |
namespaceCount()
Determines the number of namespaces declared in this context. |
ElementContext |
newSubContext(QName name)
Constructs a new child ElementContext with the specified name. |
ElementContext |
newSubContext(QName name,
boolean isEmpty)
Constructs a new child ElementContext with the specified name
and empty value. |
void |
putAttribute(QName name,
String value)
Adds an attribute to the context with the specified name and value. |
void |
putNamespace(String prefix,
String nsURI)
Adds a namespace declaration to this context with the specified prefix and namespace uri. |
void |
setReadOnly()
Prevents any further additions to this context. |
String |
toString()
|
| Methods inherited from class javanet.staxutils.SimpleNamespaceContext |
|---|
getDeclaredPrefixCount, getDeclaredPrefixes, getNamespaceURI, getParent, getPrefix, getPrefixes, getPrefixes, isPrefixDeclared, isRootContext, setDefaultNamespace, setParent, setPrefix |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ElementContext(QName name)
ElementContext with the provided name and no
enclosing context.
name - The element name.
public ElementContext(QName name,
boolean isEmpty)
ElementContext with the provided name and empty
value, and no enclosing context.
name - The element name.isEmpty - Whether the element is an empty element or not.
public ElementContext(QName name,
NamespaceContext context)
ElementContext with the provided name and
namespace context.
name - The element name.context - The enclosing namespace context.
public ElementContext(QName name,
ElementContext parent)
ElementContext with the provided name and
enclosing context.
name - The element name.parent - The enclosing element context.
public ElementContext(QName name,
ElementContext parent,
boolean isEmpty)
ElementContext with the provided name and
enclosing context.
name - The element name.parent - The enclosing element context.isEmpty - Whether the element is an empty element or not.| Method Detail |
|---|
public ElementContext getParentContext()
ElementContext.
null.public boolean isRoot()
true if this context is the root context and has no
enclosing context, false otherwise.public QName getName()
public String getPath()
public String toString()
toString in class ObjectgetPath()public StringBuffer appendPath(StringBuffer buffer)
StringBuffer.
buffer - The buffer to which to append the context path.
public int getDepth()
public ElementContext newSubContext(QName name)
ElementContext with the specified name.
name - The name associated with the child context.
IllegalStateException - If this context is empty.
public ElementContext newSubContext(QName name,
boolean isEmpty)
ElementContext with the specified name
and empty value.
name - The name associated with the child context.isEmpty - Whether the child context represents an empty element.
IllegalStateException - If this context is empty.
public void putAttribute(QName name,
String value)
name - The attribute name.value - The attribute value.
IllegalStateException - If the context is read-only.
public void putNamespace(String prefix,
String nsURI)
prefix - The namespace prefix.nsURI - The namespace uri.public int attributeCount()
public String getAttribute(int idx)
idxth attribute defined on
the context.
idx - The zero-based index of the attribute value to retrieve.
idxth attribute defined on
the context.
IndexOutOfBoundsException - If the index is out of bounds.public QName getAttributeName(int idx)
idxth attribute defined on
the context.
idx - The zero-based index of the attribute name to retrieve.
idxth attribute defined on
the context.
IndexOutOfBoundsException - If the index is out of bounds.public String getAttribute(QName name)
name - The name of the attribute value to retrieve.
null.public boolean attributeExists(QName name)
name - The name of the attribute.
true if an attribute with the specified name has been
defined in this context, false otherwise.public Iterator attributeNames()
Iterator over the names of all attributes defined in this
context. The returned iterator will not support the Iterator.remove()
operation.
Iterator over the names of all attributes defined in this
context.public int namespaceCount()
public String getNamespaceURI(int idx)
idxth namespace declaration
defined in this context.
idx - The index of the namespace URI to return.
idxth namespace declaration
defined in this context.
IndexOutOfBoundsException - If the index is out of bounds.public String getNamespacePrefix(int idx)
idxth namespace declaration
defined in this context.
idx - The index of the namespace prefix to return.
idxth namespace declaration
defined in this context.
IndexOutOfBoundsException - If the index is out of bounds.public boolean isReadOnly()
true if no additional modifications may be made to this
context, false otherwise.public void setReadOnly()
public boolean isEmpty()
true if this context represents an emtpy element,
false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||