/** * Returns an iterator over the attributes of this element with a well-defined * iteration order based on the metadata. All declared attributes are * returned first, in the order of declaration, followed by undeclared * attributes in the order in which they were added to this element. If the * metadata declares virtual attributes, those attributes will be included in * the iterator, likewise any attributes which are hidden will be excluded. * * @param metadata the element metadata to use for iteration * @return an iterator over the attributes of this element */ public Iterator<Attribute> getAttributeIterator( ElementMetadata<?, ?> metadata) { return new AttributeIterator(this, metadata, state.attributes); }
public Attribute next() { if (nextAttribute == null) { throw new NoSuchElementException("No remaining attributes"); } Attribute retVal = nextAttribute; nextAttribute = findNextAttribute(); return retVal; }
/** * Returns the next attribute in the iteration order or {@code null} if there * are no remaining attributes. */ private Attribute findNextAttribute() { Attribute next = null; while (next == null && mode != Mode.DONE) { switch(mode) { case DECLARED: next = findNextDeclaredAttribute(); break; case UNDECLARED: next = findNextUndeclaredAttribute(); break; default: break; } } return next; }
/** * Finds the next valid undeclared attribute in the map. */ private Attribute findNextUndeclaredAttribute() { if (attributeIterator != null) { while (attributeIterator.hasNext()) { Entry<QName, Attribute> entry = attributeIterator.next(); Attribute attribute = entry.getValue(); if (isUndeclared(attribute.getAttributeKey())) { return entry.getValue(); } } // No more attributes, turn the iterator off. attributeIterator = null; } // Go back and check for any remaining declared attributes if needed. mode = metadataIterator != null && metadataIterator.hasNext() ? Mode.DECLARED : Mode.DONE; return null; }
/** * Finds the next valid undeclared attribute in the map. */ private Attribute findNextUndeclaredAttribute() { if (attributeIterator != null) { while (attributeIterator.hasNext()) { Entry<QName, Attribute> entry = attributeIterator.next(); Attribute attribute = entry.getValue(); if (isUndeclared(attribute.getAttributeKey())) { return entry.getValue(); } } // No more attributes, turn the iterator off. attributeIterator = null; } // Go back and check for any remaining declared attributes if needed. mode = metadataIterator != null && metadataIterator.hasNext() ? Mode.DECLARED : Mode.DONE; return null; }
/** * Returns the next attribute in the iteration order or {@code null} if there * are no remaining attributes. */ private Attribute findNextAttribute() { Attribute next = null; while (next == null && mode != Mode.DONE) { switch(mode) { case DECLARED: next = findNextDeclaredAttribute(); break; case UNDECLARED: next = findNextUndeclaredAttribute(); break; default: break; } } return next; }
public Attribute next() { if (nextAttribute == null) { throw new NoSuchElementException("No remaining attributes"); } Attribute retVal = nextAttribute; nextAttribute = findNextAttribute(); return retVal; }
/** * Returns an iterator over the attributes of this element with a well-defined * iteration order based on the metadata. All declared attributes are * returned first, in the order of declaration, followed by undeclared * attributes in the order in which they were added to this element. If the * metadata declares virtual attributes, those attributes will be included in * the iterator, likewise any attributes which are hidden will be excluded. * * @param metadata the element metadata to use for iteration * @return an iterator over the attributes of this element */ public Iterator<Attribute> getAttributeIterator( ElementMetadata<?, ?> metadata) { return new AttributeIterator(this, metadata, state.attributes); }
/** * Finds the next valid undeclared attribute in the map. */ private Attribute findNextUndeclaredAttribute() { if (attributeIterator != null) { while (attributeIterator.hasNext()) { Entry<QName, Attribute> entry = attributeIterator.next(); Attribute attribute = entry.getValue(); if (isUndeclared(attribute.getAttributeKey())) { return entry.getValue(); } } // No more attributes, turn the iterator off. attributeIterator = null; } // Go back and check for any remaining declared attributes if needed. mode = metadataIterator != null && metadataIterator.hasNext() ? Mode.DECLARED : Mode.DONE; return null; }
/** * Returns the next attribute in the iteration order or {@code null} if there * are no remaining attributes. */ private Attribute findNextAttribute() { Attribute next = null; while (next == null && mode != Mode.DONE) { switch(mode) { case DECLARED: next = findNextDeclaredAttribute(); break; case UNDECLARED: next = findNextUndeclaredAttribute(); break; default: break; } } return next; }
public Attribute next() { if (nextAttribute == null) { throw new NoSuchElementException("No remaining attributes"); } Attribute retVal = nextAttribute; nextAttribute = findNextAttribute(); return retVal; }
/** * Returns an iterator over the attributes of this element with a well-defined * iteration order based on the metadata. All declared attributes are * returned first, in the order of declaration, followed by undeclared * attributes in the order in which they were added to this element. If the * metadata declares virtual attributes, those attributes will be included in * the iterator, likewise any attributes which are hidden will be excluded. * * @param metadata the element metadata to use for iteration * @return an iterator over the attributes of this element */ public Iterator<Attribute> getAttributeIterator( ElementMetadata<?, ?> metadata) { return new AttributeIterator(this, metadata, state.attributes); }
AttributeIterator(Element element, ElementMetadata<?, ?> metadata, Map<QName, Attribute> attributes) { this.element = element; this.metadata = metadata; this.metadataIterator = (metadata == null) ? null : metadata.getAttributes().iterator(); this.attributeIterator = (attributes == null) ? null : attributes.entrySet().iterator(); nextAttribute = findNextAttribute(); }
AttributeIterator(Element element, ElementMetadata<?, ?> metadata, Map<QName, Attribute> attributes) { this.element = element; this.metadata = metadata; this.metadataIterator = (metadata == null) ? null : metadata.getAttributes().iterator(); this.attributeIterator = (attributes == null) ? null : attributes.entrySet().iterator(); nextAttribute = findNextAttribute(); }
AttributeIterator(Element element, ElementMetadata<?, ?> metadata, Map<QName, Attribute> attributes) { this.element = element; this.metadata = metadata; this.metadataIterator = (metadata == null) ? null : metadata.getAttributes().iterator(); this.attributeIterator = (attributes == null) ? null : attributes.entrySet().iterator(); nextAttribute = findNextAttribute(); }