public int getLength(){ return(fAttributes != null)?fAttributes.getLength():0; }
public String getValue(int index) { return (fAttributes !=null)?fAttributes.item(index).getNodeValue():""; }
/** * NON-DOM * Returns the xml:base attribute. */ protected Attr getXMLBaseAttribute() { return (Attr) attributes.getNamedItemNS("http://www.w3.org/XML/1998/namespace", "base"); } // getXMLBaseAttribute():Attr
/** * Cloning a NamedNodeMap is a DEEP OPERATION; it always clones * all the nodes contained in the map. */ public NamedNodeMapImpl cloneMap(NodeImpl ownerNode) { AttributeMap newmap = new AttributeMap((ElementImpl) ownerNode, null); newmap.hasDefaults(hasDefaults()); newmap.cloneContent(this); return newmap; } // cloneMap():AttributeMap
/** Constructs a named node map. */ protected AttributeMap(ElementImpl ownerNode, NamedNodeMapImpl defaults) { super(ownerNode); if (defaults != null) { // initialize map with the defaults cloneContent(defaults); if (nodes != null) { hasDefaults(true); } } }
/** * NON-DOM: sets attribute node for this element */ protected int setXercesAttributeNode (Attr attr){ if (needsSyncData()) { synchronizeData(); } if (attributes == null) { attributes = new AttributeMap(this, null); } return attributes.addItem(attr); }
@Override public Node cloneNode(boolean deep) { OdfElement cloneElement = ((OdfFileDom) this.ownerDocument).newOdfElement(this.getClass()); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); String qname = null; String prefix = item.getPrefix(); if (prefix == null) { qname = item.getLocalName(); } else { qname = prefix + ":" + item.getLocalName(); } cloneElement.setAttributeNS(item.getNamespaceURI(), qname, item.getNodeValue()); } } if (deep) { Node childNode = getFirstChild(); while (childNode != null) { cloneElement.appendChild(childNode.cloneNode(true)); childNode = childNode.getNextSibling(); } } return cloneElement; }
AttrImpl attr = (AttrImpl) nodes.get(i); if (!attr.isSpecified()) { remove(attr, i, false); cloneContent(defaults); for (int n = 0; n < dsize; ++n) { AttrImpl d = (AttrImpl) defaults.nodes.get(n); int i = findNamePoint(d.getNodeName(), 0); if (i < 0) { i = -1 - i;
for (int k = 0; k < attributes.getLength(); ++k) { Attr attr = (Attr)attributes.getItem(k); uri = attr.getNamespaceURI(); if (uri != null && uri.equals(NamespaceContext.XMLNS_URI)) { attributes.cloneMap(fAttributeList); for (int i = 0; i < fAttributeList.size(); i++) { Attr attr = (Attr) fAttributeList.get(i);
attributes = new AttributeMap(this, null); return (Attr) attributes.setNamedItem(newAttr);
qualifiedName); if (attributes == null) { attributes = new AttributeMap(this, null); attributes.setNamedItemNS(newAttr); attributes.setNamedItemNS(newAttr);
void moveSpecifiedAttributes(ElementImpl el) { if (needsSyncData()) { synchronizeData(); } if (el.hasAttributes()) { if (attributes == null) { attributes = new AttributeMap(this, null); } attributes.moveSpecifiedAttributes(el.attributes); } }
/** Setup the default attributes. */ protected void setupDefaultAttributes() { NamedNodeMapImpl defaults = getDefaultAttributes(); if (defaults != null) { attributes = new AttributeMap(this, defaults); } }
/** * Return a duplicate copy of this Element. Note that its children * will not be copied unless the "deep" flag is true, but Attributes * are <i>always</i> replicated. * * @see org.w3c.dom.Node#cloneNode(boolean) */ 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; } // cloneNode(boolean):Node
attributes = new AttributeMap(this, null); attributes.setNamedItem(newAttr);
attributes = new AttributeMap(this, null); return (Attr) attributes.setNamedItemNS(newAttr);
/** * Retrieve all the Attributes as a set. Note that this API is inherited * from Node rather than specified on Element; in fact only Elements will * ever have Attributes, but they want to allow folks to "blindly" operate * on the tree as a set of Nodes. */ public NamedNodeMap getAttributes() { if (needsSyncData()) { synchronizeData(); } if (attributes == null) { attributes = new AttributeMap(this, null); } return attributes; } // getAttributes():NamedNodeMap
@Override public Node cloneNode(boolean deep) { OdfElement cloneElement = this.cloneOdfElement(); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); String qname = null; String prefix = item.getPrefix(); if (prefix == null) { qname = item.getLocalName(); cloneElement.setAttribute(qname, item.getNodeValue()); } else { qname = prefix + ":" + item.getLocalName(); cloneElement.setAttributeNS(item.getNamespaceURI(), qname, item.getNodeValue()); } } } if (deep) { Node childNode = getFirstChild(); while (childNode != null) { cloneElement.appendChild(childNode.cloneNode(true)); childNode = childNode.getNextSibling(); } } return cloneElement; }