public class ElementContext extends SimpleNamespaceContext
namespaces
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
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
idx th 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
idx th 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
idx th namespace declaration
defined in this context. |
String |
getNamespaceURI(int idx)
Returns the URI of the
idx th 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() |
getDeclaredPrefixCount, getDeclaredPrefixes, getNamespaceURI, getParent, getPrefix, getPrefixes, getPrefixes, isPrefixDeclared, isRootContext, setDefaultNamespace, setParent, setPrefix
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.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 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)
idx
th attribute defined on
the context.idx
- The zero-based index of the attribute value to retrieve.idx
th attribute defined on
the context.IndexOutOfBoundsException
- If the index is out of bounds.public QName getAttributeName(int idx)
idx
th attribute defined on
the context.idx
- The zero-based index of the attribute name to retrieve.idx
th 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)
idx
th namespace declaration
defined in this context.idx
- The index of the namespace URI to return.idx
th namespace declaration
defined in this context.IndexOutOfBoundsException
- If the index is out of bounds.public String getNamespacePrefix(int idx)
idx
th namespace declaration
defined in this context.idx
- The index of the namespace prefix to return.idx
th 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.