/** * Returns an iterator over all attributes on this element. */ public Iterator<Attribute> getAttributeIterator() { return getAttributeIterator(null); }
/** * Returns an iterator over all attributes on this element. */ public Iterator<Attribute> getAttributeIterator() { return getAttributeIterator(null); }
/** * Returns an iterator over all attributes on this element. */ public Iterator<Attribute> getAttributeIterator() { return getAttributeIterator(null); }
public Iterator<Attribute> getAttributeIterator(Element element) { return element.getAttributeIterator(this); }
public Iterator<Attribute> getAttributeIterator(Element element) { return element.getAttributeIterator(this); }
public Iterator<Attribute> getAttributeIterator(Element element) { return element.getAttributeIterator(this); }
/** * Get a list of attributes for the given element. */ protected List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<XmlWriter.Attribute> attrs = null; Iterator<Attribute> attributeIterator = e.getAttributeIterator(metadata); if (attributeIterator.hasNext()) { ElementKey<?, ?> key = e.getElementKey(); attrs = new ArrayList<XmlWriter.Attribute>(); while (attributeIterator.hasNext()) { Attribute attribute = attributeIterator.next(); AttributeKey<?> attKey = attribute.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); QName qName = attMeta != null ? attMeta.getName() : attKey.getId(); String alias = (qName.getNs() != null) ? qName.getNs().getAlias() : null; attrs.add(new XmlWriter.Attribute(alias, qName.getLocalName(), attribute.getValue().toString())); } } return attrs; }
/** * Get a list of attributes for the given element. */ protected List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<XmlWriter.Attribute> attrs = null; Iterator<Attribute> attributeIterator = e.getAttributeIterator(metadata); if (attributeIterator.hasNext()) { ElementKey<?, ?> key = e.getElementKey(); attrs = new ArrayList<XmlWriter.Attribute>(); while (attributeIterator.hasNext()) { Attribute attribute = attributeIterator.next(); AttributeKey<?> attKey = attribute.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); QName qName = attMeta != null ? attMeta.getName() : attKey.getId(); String alias = (qName.getNs() != null) ? qName.getNs().getAlias() : null; attrs.add(new XmlWriter.Attribute(alias, qName.getLocalName(), attribute.getValue().toString())); } } return attrs; }
/** * Get a list of attributes for the given element. */ protected List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<XmlWriter.Attribute> attrs = null; Iterator<Attribute> attributeIterator = e.getAttributeIterator(metadata); if (attributeIterator.hasNext()) { ElementKey<?, ?> key = e.getElementKey(); attrs = new ArrayList<XmlWriter.Attribute>(); while (attributeIterator.hasNext()) { Attribute attribute = attributeIterator.next(); AttributeKey<?> attKey = attribute.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); QName qName = attMeta != null ? attMeta.getName() : attKey.getId(); String alias = (qName.getNs() != null) ? qName.getNs().getAlias() : null; attrs.add(new XmlWriter.Attribute(alias, qName.getLocalName(), attribute.getValue().toString())); } } return attrs; }
@Override public String toString() { ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(getElementId() + "@" + Integer.toHexString(hashCode())); Iterator<Attribute> aIter = getAttributeIterator(); while (aIter.hasNext()) { Attribute att = aIter.next(); helper.add(att.getAttributeKey().getId().toString(), att.getValue()); } if (hasTextValue()) { helper.addValue(getTextValue()); } return helper.toString(); } }
@Override public String toString() { ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(getElementId() + "@" + Integer.toHexString(hashCode())); Iterator<Attribute> aIter = getAttributeIterator(); while (aIter.hasNext()) { Attribute att = aIter.next(); helper.add(att.getAttributeKey().getId().toString(), att.getValue()); } if (hasTextValue()) { helper.addValue(getTextValue()); } return helper.toString(); } }
@Override public String toString() { ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(getElementId() + "@" + Integer.toHexString(hashCode())); Iterator<Attribute> aIter = getAttributeIterator(); while (aIter.hasNext()) { Attribute att = aIter.next(); helper.add(att.getAttributeKey().getId().toString(), att.getValue()); } if (hasTextValue()) { helper.addValue(getTextValue()); } return helper.toString(); } }
/** * Calculate the namespaces on an element using the given visitor to store * the namespaces. We cheat by using an attribute visitor for even visiting * the element names, because all we're doing with the visitor is adding a * QName. */ private static void calculateNamespaces(Map<String, XmlNamespace> namespaces, Element e, ElementMetadata<?, ?> metadata) { QName name = (metadata == null) ? e.getElementId() : metadata.getName(); addNamespace(namespaces, name); Iterator<Attribute> attIter = e.getAttributeIterator(metadata); while (attIter.hasNext()) { Attribute att = attIter.next(); AttributeKey<?> attKey = att.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); name = (attMeta == null) ? attKey.getId() : attMeta.getName(); addNamespace(namespaces, name); } Iterator<Element> childIter = e.getElementIterator(metadata); while (childIter.hasNext()) { Element child = childIter.next(); ElementMetadata<?, ?> childMeta = (metadata == null) ? null : metadata.bindElement(child.getElementKey()); calculateNamespaces(namespaces, child, childMeta); } }
/** * Calculate the namespaces on an element using the given visitor to store * the namespaces. We cheat by using an attribute visitor for even visiting * the element names, because all we're doing with the visitor is adding a * QName. */ private static void calculateNamespaces(Map<String, XmlNamespace> namespaces, Element e, ElementMetadata<?, ?> metadata) { QName name = (metadata == null) ? e.getElementId() : metadata.getName(); addNamespace(namespaces, name); Iterator<Attribute> attIter = e.getAttributeIterator(metadata); while (attIter.hasNext()) { Attribute att = attIter.next(); AttributeKey<?> attKey = att.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); name = (attMeta == null) ? attKey.getId() : attMeta.getName(); addNamespace(namespaces, name); } Iterator<Element> childIter = e.getElementIterator(metadata); while (childIter.hasNext()) { Element child = childIter.next(); ElementMetadata<?, ?> childMeta = (metadata == null) ? null : metadata.bindElement(child.getElementKey()); calculateNamespaces(namespaces, child, childMeta); } }
/** * Calculate the namespaces on an element using the given visitor to store * the namespaces. We cheat by using an attribute visitor for even visiting * the element names, because all we're doing with the visitor is adding a * QName. */ private static void calculateNamespaces(Map<String, XmlNamespace> namespaces, Element e, ElementMetadata<?, ?> metadata) { QName name = (metadata == null) ? e.getElementId() : metadata.getName(); addNamespace(namespaces, name); Iterator<Attribute> attIter = e.getAttributeIterator(metadata); while (attIter.hasNext()) { Attribute att = attIter.next(); AttributeKey<?> attKey = att.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); name = (attMeta == null) ? attKey.getId() : attMeta.getName(); addNamespace(namespaces, name); } Iterator<Element> childIter = e.getElementIterator(metadata); while (childIter.hasNext()) { Element child = childIter.next(); ElementMetadata<?, ?> childMeta = (metadata == null) ? null : metadata.bindElement(child.getElementKey()); calculateNamespaces(namespaces, child, childMeta); } }