| Method from org.apache.axiom.om.impl.dom.ElementImpl Detail: |
public OMAttribute addAttribute(OMAttribute attr) {
OMNamespace namespace = attr.getNamespace();
if (namespace != null && namespace.getNamespaceURI() != null
&& !"".equals(namespace.getNamespaceURI())
&& this.findNamespace(namespace.getNamespaceURI(), namespace
.getPrefix()) == null) {
this.declareNamespace(namespace.getNamespaceURI(), namespace.getPrefix());
}
if (attr.getNamespace() != null) { // If the attr has a namespace
return (AttrImpl) this.setAttributeNode((Attr) attr);
} else {
return (AttrImpl) this.setAttributeNodeNS((Attr) attr);
}
}
|
public OMAttribute addAttribute(String attributeName,
String value,
OMNamespace ns) {
if (ns != null && findNamespace(ns.getNamespaceURI(), ns.getPrefix()) != null) {
declareNamespace(ns);
}
if (ns != null) {
return this.addAttribute(ns.getNamespaceURI(), ns.getPrefix() + ":"
+ attributeName, value);
} else {
return this.addAttribute(null, attributeName, value);
}
}
The behaviour of this is the same as org.w3c.dom.Element#setAttributeNS |
public void buildWithAttachments() {
if (!done) {
this.build();
}
Iterator iterator = getChildren();
while (iterator.hasNext()) {
OMNode node = (OMNode) iterator.next();
node.buildWithAttachments();
}
}
|
public Node cloneNode(boolean deep) {
ElementImpl newnode = (ElementImpl) super.cloneNode(deep);
// Replicate NamedNodeMap rather than sharing it.
if (attributes != null) {
newnode.attributes = (AttributeMap) attributes.cloneMap(newnode);
}
return newnode;
}
|
public OMElement cloneOMElement() {
return (ElementImpl) this.cloneNode(true);
}
Creates a clone which belongs to a new document. |
public OMNamespace declareDefaultNamespace(String uri) {
NamespaceImpl ns = new NamespaceImpl(uri, "");
if (namespaces == null) {
this.namespaces = new HashMap(5);
}
namespaces.put("", ns);
return ns;
}
We use "" to store the default namespace of this element. As one can see user can not give ""
as the prefix, when he declare a usual namespace. |
public OMNamespace declareNamespace(OMNamespace namespace) {
if (namespaces == null) {
this.namespaces = new HashMap(5);
}
if (namespace != null) {
String prefix = namespace.getPrefix();
if ("".equals(prefix)) {
namespace = declareDefaultNamespace(namespace.getNamespaceURI());
} else if (prefix == null) {
prefix = OMSerializerUtil.getNextNSPrefix();
namespace = new NamespaceImpl(namespace.getNamespaceURI(), prefix);
}
if (!namespace.getPrefix().startsWith(OMConstants.XMLNS_NS_PREFIX)) {
namespaces.put(namespace.getPrefix(), namespace);
}
}
return namespace;
}
Allows overriding an existing declaration if the same prefix was used. |
public OMNamespace declareNamespace(String uri,
String prefix) {
if (prefix == null) {
prefix = OMSerializerUtil.getNextNSPrefix();
}
NamespaceImpl ns = new NamespaceImpl(uri, prefix);
return declareNamespace(ns);
}
Allows overriding an existing declaration if the same prefix was used. |
public void discard() throws OMException {
if (done) {
this.detach();
} else {
builder.discard(this);
}
}
|
public OMNamespace findNamespace(String uri,
String prefix) {
// check in the current element
OMNamespace namespace = findDeclaredNamespace(uri, prefix);
if (namespace != null) {
return namespace;
}
// go up to check with ancestors
if (this.parentNode != null) {
// For the OMDocumentImpl there won't be any explicit namespace
// declarations, so going up the parent chain till the document
// element should be enough.
if (parentNode instanceof OMElement) {
namespace = ((ElementImpl) parentNode).findNamespace(uri,
prefix);
}
}
if (namespace == null && uri != null && prefix != null
&& prefix.equals(OMConstants.XMLNS_PREFIX)
&& uri.equals(OMConstants.XMLNS_URI)) {
declareNamespace(OMConstants.XMLNS_URI, OMConstants.XMLNS_PREFIX);
namespace = findNamespace(uri, prefix);
}
return namespace;
}
|
public OMNamespace findNamespaceURI(String prefix) {
OMNamespace ns = this.namespaces == null ?
null :
(OMNamespace) this.namespaces.get(prefix);
if (ns == null && this.parentNode instanceof OMElement) {
// try with the parent
ns = ((OMElement) this.parentNode).findNamespaceURI(prefix);
}
return ns;
}
|
public Iterator getAllAttributes() {
if (attributes == null) {
return EMPTY_ITERATOR;
}
ArrayList list = new ArrayList();
for (int i = 0; i < attributes.getLength(); i++) {
OMAttribute item = (OMAttribute) attributes.getItem(i);
if (item.getNamespace() == null
|| !(item.getNamespace() != null && OMConstants.XMLNS_NS_URI
.equals(item.getNamespace().getNamespaceURI()))) {
list.add(item);
}
}
return list.iterator();
}
|
public Iterator getAllDeclaredNamespaces() throws OMException {
if (namespaces == null) {
return EMPTY_ITERATOR;
}
return namespaces.values().iterator();
}
|
public String getAttribute(String name) {
if (attributes == null) {
return "";
} else {
Attr attr = ((Attr) attributes.getNamedItem(name));
return (attr != null) ? attr.getValue() : "";
}
}
Looks in the local list of attributes and returns if found. If the local list is null,
returns "". |
public OMAttribute getAttribute(QName qname) {
if (this.attributes == null) {
return null;
}
if (qname.getNamespaceURI() == null
|| qname.getNamespaceURI().equals("")) {
return (AttrImpl) this.getAttributeNode(qname.getLocalPart());
} else {
return (AttrImpl) this.getAttributeNodeNS(qname.getNamespaceURI(),
qname.getLocalPart());
}
}
Returns a named attribute if present. |
public String getAttributeNS(String namespaceURI,
String localName) {
if (this.attributes == null) {
return "";
}
Attr attributeNodeNS = this.getAttributeNodeNS(namespaceURI, localName);
return attributeNodeNS == null ? "" : attributeNodeNS.getValue();
}
Retrieves an attribute value by local name and namespace URI. |
public Attr getAttributeNode(String name) {
return (this.attributes == null) ? null : (AttrImpl) this.attributes
.getNamedItem(name);
}
Retrieves an attribute node by name. |
public Attr getAttributeNodeNS(String namespaceURI,
String localName) {
if (OMConstants.XMLNS_NS_URI.equals(namespaceURI)) {
OMNamespace ns = this.findNamespaceURI(localName);
String nsuri = ns != null ? ns.getNamespaceURI() : "";
AttrImpl namespaceAttr = new AttrImpl(this.ownerNode,
localName, nsuri, this.factory);
NamespaceImpl xmlNs = new NamespaceImpl(OMConstants.XMLNS_NS_URI);
namespaceAttr.setOMNamespace(xmlNs);
return namespaceAttr;
}
return (this.attributes == null) ? null : (Attr) this.attributes
.getNamedItemNS(namespaceURI, localName);
}
Retrieves an attribute node by local name and namespace URI. |
public String getAttributeValue(QName qname) {
OMAttribute attr = getAttribute(qname);
return (attr == null) ? null : attr.getAttributeValue();
}
Returns a named attribute's value, if present. |
public NamedNodeMap getAttributes() {
AttributeMap attributeMap = new AttributeMap(this);
// Add the set of existing attrs
for (int i = 0; i < this.attributes.getLength(); i++) {
attributeMap.addItem((Attr) this.attributes.getItem(i));
}
// Add the NS declarations
if (this.namespaces != null) {
Iterator nsDecls = this.namespaces.keySet().iterator();
while (nsDecls.hasNext()) {
String prefix = (String) nsDecls.next();
if (prefix != null && !"".equals(prefix)
&& !prefix.equals(OMConstants.XMLNS_NS_PREFIX)) {
OMNamespace ns = (OMNamespace) this.namespaces.get(prefix);
AttrImpl attr = new AttrImpl(this.ownerNode, prefix, ns
.getNamespaceURI(), this.factory);
attr.setOMNamespace(new NamespaceImpl(
OMConstants.XMLNS_NS_URI,
OMConstants.XMLNS_NS_PREFIX));
attributeMap.addItem(attr);
}
}
// Set the default NS attr if any
if (this.namespace != null
&& (this.namespace.getPrefix() == null || ""
.equals(this.namespace.getPrefix()))
&& this.namespace.getNamespaceURI() != null) {
// check if the parent of this element has the same namespace
// as the default and if NOT add the attr
boolean parentHasSameDefaultNS = this.parentNode != null &&
this.parentNode.getNamespaceURI() != null &&
this.parentNode.getNamespaceURI().equals(this.getNamespaceURI()) &&
(this.parentNode.getPrefix() == null ||
this.parentNode.getPrefix().equals(""));
if (!parentHasSameDefaultNS) {
AttrImpl attr = new AttrImpl(this.ownerNode, "xmlns",
this.namespace.getNamespaceURI(), this.factory);
attr.setOMNamespace(new NamespaceImpl(
OMConstants.XMLNS_NS_URI,
OMConstants.XMLNS_NS_PREFIX));
attributeMap.addItem(attr);
}
}
}
return attributeMap;
}
Returns the set of attributes of this node and the namespace declarations available. |
public OMXMLParserWrapper getBuilder() {
return this.builder;
}
|
public Iterator getChildElements() {
return new OMChildElementIterator(getFirstElement());
}
|
public OMNamespace getDefaultNamespace() {
if (namespaces != null) {
NamespaceImpl defaultNS = (NamespaceImpl) namespaces.get("");
if (defaultNS != null) {
return defaultNS;
}
}
if (parentNode instanceof ElementImpl) {
ElementImpl element = (ElementImpl) parentNode;
element.getDefaultNamespace();
}
return null;
}
|
public NodeList getElementsByTagName(String name) {
if (name.equals("*")) {
return new NodeListImpl() {
protected Iterator getIterator() {
return new OMDescendantsIterator(getFirstOMChild());
}
};
} else {
return new NodeListImpl() {
protected Iterator getIterator() {
return new OMQualifiedNameFilterIterator(
new OMDescendantsIterator(getFirstOMChild()), name);
}
};
}
}
|
public NodeList getElementsByTagNameNS(String namespaceURI,
String localName) {
final QName qname = new QName(namespaceURI, localName);
return new NodeListImpl() {
protected Iterator getIterator() {
return new OMQNameFilterIterator(
new OMDescendantsIterator(getFirstOMChild()), qname);
}
};
}
|
public OMElement getFirstElement() {
OMNode node = getFirstOMChild();
while (node != null) {
if (node.getType() == Node.ELEMENT_NODE) {
return (OMElement) node;
} else {
node = node.getNextOMSibling();
}
}
return null;
}
Returns the first Element node. |
public int getLineNumber() {
return lineNumber;
}
|
public String getLocalName() {
return this.localName;
}
Returns the local name of this element node |
public OMNamespace getNamespace() throws OMException {
return namespace != null ? namespace : getDefaultNamespace();
}
Returns the namespace of this element. |
public String getNamespaceURI() {
if (this.namespace == null) {
return null;
} else {
// If the element has no namespace, the result should be null, not
// an empty string.
String uri = this.namespace.getNamespaceURI();
return uri.length() == 0 ? null : uri.intern();
}
}
Returns the value of the namespace URI. |
public String getNamespaceURI(String prefix) {
OMNamespace ns = this.findNamespaceURI(prefix);
return (ns != null) ? ns.getNamespaceURI() : null;
}
Returns the namespace uri, given the prefix. If it is not found at this element, searches the
parent. |
public OMNode getNextOMSibling() throws OMException {
while (!done) {
int token = builder.next();
if (token == XMLStreamConstants.END_DOCUMENT) {
throw new OMException();
}
}
return super.getNextOMSibling();
}
|
public String getNodeName() {
if (this.namespace != null) {
if (this.namespace.getPrefix() == null
|| "".equals(this.namespace.getPrefix())) {
return this.localName;
} else {
return this.namespace.getPrefix() + ":" + this.localName;
}
} else {
return this.localName;
}
}
|
public short getNodeType() {
return Node.ELEMENT_NODE;
}
|
public String getPrefix() {
return (this.namespace == null) ? null : this.namespace.getPrefix();
}
Returns the namespace prefix of this element node |
public QName getQName() {
QName qName;
if (namespace != null) {
if (namespace.getPrefix() != null) {
qName = new QName(namespace.getNamespaceURI(), this.localName,
namespace.getPrefix());
} else {
qName = new QName(namespace.getNamespaceURI(), this.localName);
}
} else {
qName = new QName(this.localName);
}
return qName;
}
Returns the QName of this element. |
public TypeInfo getSchemaTypeInfo() {
// TODO TODO
throw new UnsupportedOperationException("TODO");
}
|
public String getTagName() {
return this.getNodeName();
}
|
public String getText() {
String childText = "";
OMNode child = this.getFirstOMChild();
OMText textNode;
while (child != null) {
final int type = child.getType();
if (type == OMNode.TEXT_NODE || type == OMNode.CDATA_SECTION_NODE) {
textNode = (OMText) child;
if (textNode.getText() != null
&& !"".equals(textNode.getText())) {
childText += textNode.getText();
}
}
child = child.getNextOMSibling();
}
return childText;
}
Gets all the text children and concatinates them to a single string. |
public QName getTextAsQName() {
String childText = getTrimmedText();
if (childText != null) {
return resolveQName(childText);
}
return null;
}
|
public String getTrimmedText() {
String childText = null;
OMNode child = this.getFirstOMChild();
OMText textNode;
while (child != null) {
if (child.getType() == OMNode.TEXT_NODE) {
textNode = (OMText) child;
String textValue = textNode.getText();
if (textValue != null &&
!"".equals(textValue.trim())) {
if (childText == null) childText = "";
childText += textValue.trim();
}
}
child = child.getNextOMSibling();
}
return childText;
}
|
public int getType() throws OMException {
return OMNode.ELEMENT_NODE;
}
|
public XMLStreamReader getXMLStreamReader() {
return getXMLStreamReader(true);
}
|
public XMLStreamReader getXMLStreamReaderWithoutCaching() {
return getXMLStreamReader(false);
}
|
public boolean hasAttribute(String name) {
return this.getAttributeNode(name) != null;
}
|
public boolean hasAttributeNS(String namespaceURI,
String localName) {
return this.getAttributeNodeNS(namespaceURI, localName) != null;
}
Returns whether the given attribute is available or not. |
public boolean hasAttributes() {
boolean flag;
// TODO : Review. This code doesn't make any sense since it always gets overwritten. WTF?
// if (this.attributes != null) {
// flag = (this.attributes.getLength() > 0);
// }
//The namespaces
flag = this.namespace != null;
if (!flag) {
if (this.namespaces != null) {
flag = !this.namespaces.isEmpty();
}
}
return flag;
}
Returns whether this element contains any attribute or not. |
public void internalSerialize(XMLStreamWriter writer) throws XMLStreamException {
internalSerialize(writer, true);
}
|
protected void internalSerialize(XMLStreamWriter writer,
boolean cache) throws XMLStreamException {
if (!cache) {
// in this case we don't care whether the elements are built or not
// we just call the serializeAndConsume methods
OMSerializerUtil.serializeStartpart(this, writer);
// serilize children
Iterator children = this.getChildren();
while (children.hasNext()) {
((OMNodeEx) children.next()).internalSerialize(writer);
}
OMSerializerUtil.serializeEndpart(writer);
} else {
// Now the caching is supposed to be off. However caching been
// switched off
// has nothing to do if the element is already built!
if (this.done) {
OMSerializerUtil.serializeStartpart(this, writer);
ChildNode child = this.firstChild;
while (child != null
&& ((!(child instanceof OMElement)) || child
.isComplete())) {
child.internalSerializeAndConsume(writer);
child = child.nextSibling;
}
if (child != null) {
OMElement element = (OMElement) child;
element.getBuilder().setCache(false);
OMSerializerUtil.serializeByPullStream(element, writer,
cache);
}
OMSerializerUtil.serializeEndpart(writer);
} else {
// take the XMLStream reader and feed it to the stream
// serilizer.
// todo is this right ?????
OMSerializerUtil.serializeByPullStream(this, writer, cache);
}
}
}
|
public void internalSerializeAndConsume(XMLStreamWriter writer) throws XMLStreamException {
this.internalSerialize(writer, false);
}
|
public void removeAttribute(String name) throws DOMException {
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (name.startsWith(OMConstants.XMLNS_NS_PREFIX)) {
String namespacePrefix = DOMUtil.getLocalName(name);
if (this.findNamespaceURI(namespacePrefix) != null) {
this.removeNamespace(namespacePrefix);
}
}
if (this.attributes != null) {
this.attributes.removeNamedItem(name);
}
}
Removes an attribute by name. |
public void removeAttribute(OMAttribute attr) {
this.removeAttributeNode((AttrImpl) attr);
}
Removes an attribute from the element. |
public void removeAttributeNS(String namespaceURI,
String localName) throws DOMException {
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (OMConstants.XMLNS_NS_URI.equals(namespaceURI)) {
//look in the ns list
if (this.namespaces != null) {
this.namespaces.remove(DOMUtil.getLocalName(localName));
}
} else if (this.attributes != null) {
this.attributes.removeNamedItemNS(namespaceURI, localName);
}
}
|
public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
if (isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (this.attributes == null
|| this.attributes.getNamedItem(oldAttr.getName()) == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
return (AttrImpl) this.attributes.removeNamedItem(oldAttr
.getName());
}
Removes the specified attribute node. |
public boolean removeNamespace(String prefix) {
Object ns = this.namespaces.get(prefix);
if (ns != null) {
this.namespaces.remove(prefix);
return true;
} else {
return false;
}
}
Removes a declared namespace given its prefix. |
public QName resolveQName(String qname) {
ElementHelper helper = new ElementHelper(this);
return helper.resolveQName(qname);
}
Turn a prefix:local qname string into a proper QName, evaluating it in the OMElement context
unprefixed qnames resolve to the local namespace |
public void setAttribute(String name,
String value) throws DOMException {
// Check for invalid charaters
if (!DOMUtil.isQualifiedName(name)) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR",
null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
if (name.startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) {
// This is a ns declaration
this.declareNamespace(value, DOMUtil.getLocalName(name));
} else if (name.equals(OMConstants.XMLNS_NS_PREFIX)) {
this.declareDefaultNamespace(value);
} else {
this.setAttributeNode(new AttrImpl(this.ownerNode, name, value,
this.factory));
}
}
|
public void setAttributeNS(String namespaceURI,
String qualifiedName,
String value) throws DOMException {
if (namespaceURI != null && !"".equals(namespaceURI)) {
if (namespaceURI.equals(OMConstants.XMLNS_NS_URI)) {
this.declareNamespace(value, DOMUtil
.getLocalName(qualifiedName));
} else {
AttrImpl attr = new AttrImpl(this.ownerNode, DOMUtil
.getLocalName(qualifiedName), value, this.factory);
attr.setOMNamespace(new NamespaceImpl(namespaceURI, DOMUtil
.getPrefix(qualifiedName)));
this.setAttributeNodeNS(attr);
}
} else {
// When the namespace is null, the attr name given better not be
// a qualified name
// But anyway check and set it
this.setAttribute(DOMUtil.getLocalName(qualifiedName), value);
}
}
|
public Attr setAttributeNode(Attr attr) throws DOMException {
AttrImpl attrImpl = (AttrImpl) attr;
if (attrImpl.isOwned()) {// check for ownership
if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR",
null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
}
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
// check whether the attr is in use
if (attrImpl.isUsed()) {
String msg = DOMMessageFormatter
.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INUSE_ATTRIBUTE_ERR", null);
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, msg);
}
if (attr.getNodeName().startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) {
// This is a ns declaration
this.declareNamespace(attr.getNodeValue(), DOMUtil
.getLocalName(attr.getName()));
//Don't add this to attr list, since its a namespace
return attr;
} else if (attr.getNodeName().equals(OMConstants.XMLNS_NS_PREFIX)) {
this.declareDefaultNamespace(attr.getValue());
//Don't add this to attr list, since its a namespace
return attr;
}
if (this.attributes == null) {
this.attributes = new AttributeMap(this);
}
return (Attr) this.attributes.setNamedItem(attr);
}
Adds a new attribute node. |
public Attr setAttributeNodeNS(Attr attr) throws DOMException {
// Check whether the attr is a namespace declaration
// if so add a namespace NOT an attribute
if (attr.getNamespaceURI() != null
&& attr.getNamespaceURI().equals(OMConstants.XMLNS_NS_URI)) {
this.declareNamespace(attr.getName(), attr.getValue());
return attr;
} else {
AttrImpl attrImpl = (AttrImpl) attr;
if (attrImpl.isOwned()) {// check for ownership
if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
}
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
// check whether the attr is in use
if (attrImpl.isUsed()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN, "INUSE_ATTRIBUTE_ERR",
null);
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, msg);
}
if (this.attributes == null) {
this.attributes = new AttributeMap(this);
}
// handle the namespaces
if (attr.getNamespaceURI() != null
&& findNamespace(attr.getNamespaceURI(), attr.getPrefix())
== null) {
// TODO checkwhether the same ns is declared with a different
// prefix and remove it
this.declareNamespace(new NamespaceImpl(attr.getNamespaceURI(),
attr.getPrefix()));
}
return (Attr) this.attributes.setNamedItemNS(attr);
}
}
|
public void setBuilder(OMXMLParserWrapper wrapper) {
this.builder = wrapper;
}
|
public void setIdAttribute(String name,
boolean isId) throws DOMException {
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
//find the attr
AttrImpl tempAttr = (AttrImpl) this.getAttributeNode(name);
if (tempAttr == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR,
msg);
}
this.updateIsId(isId, tempAttr);
}
|
public void setIdAttributeNS(String namespaceURI,
String localName,
boolean isId) throws DOMException {
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
//find the attr
AttrImpl tempAttr = (AttrImpl) this.getAttributeNodeNS(namespaceURI, localName);
if (tempAttr == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR,
msg);
}
this.updateIsId(isId, tempAttr);
}
|
public void setIdAttributeNode(Attr idAttr,
boolean isId) throws DOMException {
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
//find the attr
Iterator attrIter = this.getAllAttributes();
AttrImpl tempAttr = null;
while (attrIter.hasNext()) {
AttrImpl attr = (AttrImpl) attrIter.next();
if (attr.equals(idAttr)) {
tempAttr = attr;
break;
}
}
if (tempAttr == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR,
msg);
}
this.updateIsId(isId, tempAttr);
}
|
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
|
public void setLocalName(String localName) {
this.localName = localName;
}
|
public void setNamespace(OMNamespace namespace) {
this.namespace = namespace;
}
|
public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace) {
this.namespace = namespace;
}
|
protected void setOwnerDocument(DocumentImpl document) {
this.ownerNode = document;
this.isOwned(true);
if (document.firstChild == null) {
document.firstChild = this;
}
}
|
public void setText(String text) {
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
// if we already have other text nodes remove them
OMNode child = this.getFirstOMChild();
while (child != null) {
if (child.getType() == OMNode.TEXT_NODE) {
child.detach();
}
child = child.getNextOMSibling();
}
TextImpl textNode = (TextImpl) (this.ownerNode)
.createTextNode(text);
this.addChild(textNode);
}
Creates a text node with the given value and adds it to the element. |
public void setText(QName text) {
throw new UnsupportedOperationException();
}
|
public void setType(int nodeType) throws OMException {
// Do nothing ...
// This is an Eement Node...
}
|
public String toString() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
// this.build();
this.serialize(baos);
} catch (XMLStreamException e) {
throw new RuntimeException("Can not serialize OM Element " + this.getLocalName(), e);
}
return new String(baos.toByteArray());
}
Overridden toString() for ease of debugging. |
public String toStringWithConsume() throws XMLStreamException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.serializeAndConsume(baos);
return new String(baos.toByteArray());
}
|