Package net.sf.saxon.om
Interface AttributeMap
-
- All Superinterfaces:
java.lang.Iterable<AttributeInfo>
- All Known Implementing Classes:
AttributeMapWithIdentity,EmptyAttributeMap,LargeAttributeMap,SingletonAttributeMap,SmallAttributeMap,TinyAttributeMap
public interface AttributeMap extends java.lang.Iterable<AttributeInfo>
AttributeMap represents an immutable collection of attributes available on a particular element node. An AttributeMap is an ordered collection of AttributeInfo objects. The order of the object represents document order.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AttributeMapapply(java.util.function.Function<AttributeInfo,AttributeInfo> mapper)default java.util.List<AttributeInfo>asList()Get the contents of the AttributeMap as a list ofAttributeInfoobjects.static AttributeMapfromList(java.util.List<AttributeInfo> list)Construct an AttributeMap given a list ofAttributeInfoobjects representing the individual attributes.default AttributeInfoget(java.lang.String uri, java.lang.String local)Get the attribute with a given name, if it existsdefault AttributeInfoget(NodeName name)Get the attribute with a given name, if it existsdefault AttributeInfogetByFingerprint(int fingerprint, NamePool namePool)default java.lang.StringgetValue(java.lang.String uri, java.lang.String local)Get the value of the attribute with a given name, if it existsdefault AttributeInfoitemAt(int index)Get the AttributeInfo with a given index.default AttributeMapput(AttributeInfo att)Replace or add an attribute, to create a new AttributeMapdefault AttributeMapremove(NodeName name)Remove an existing attribute, to create a new AttributeMapintsize()Return the number of attributes in the map.default voidverify()
-
-
-
Method Detail
-
size
int size()
Return the number of attributes in the map.- Returns:
- The number of attributes in the map.
-
get
default AttributeInfo get(NodeName name)
Get the attribute with a given name, if it exists- Parameters:
name- the name of the required attribute- Returns:
- the required attribute if it exists
-
get
default AttributeInfo get(java.lang.String uri, java.lang.String local)
Get the attribute with a given name, if it exists- Parameters:
uri- the namespace part of the name of the required attributelocal- the local part of the name of the required attribute- Returns:
- the required attribute if it exists
-
getByFingerprint
default AttributeInfo getByFingerprint(int fingerprint, NamePool namePool)
-
getValue
default java.lang.String getValue(java.lang.String uri, java.lang.String local)Get the value of the attribute with a given name, if it exists- Parameters:
uri- the namespace URI part of the name of the required attributelocal- the local part of the name of the required attribute- Returns:
- the value of the required attribute if it exists, or null otherwise
-
put
default AttributeMap put(AttributeInfo att)
Replace or add an attribute, to create a new AttributeMap- Parameters:
att- the attribute to be added or replaced- Returns:
- the new AttributeMap
-
remove
default AttributeMap remove(NodeName name)
Remove an existing attribute, to create a new AttributeMap- Parameters:
name- the name of the attribute to be removed (if it exists)- Returns:
- a new attribute map in which the specified attribute is omitted. If the attribute map contains no attribute with the given name, the input attribute map (or one equivalent to it) is returned unchanged
-
verify
default void verify()
-
apply
default AttributeMap apply(java.util.function.Function<AttributeInfo,AttributeInfo> mapper)
-
asList
default java.util.List<AttributeInfo> asList()
Get the contents of the AttributeMap as a list ofAttributeInfoobjects.The order of the returned list must be consistent with document order, with the order of the attribute axis, and with position-based retrieval of individual
AttributeInfoobjects; multiple calls are not required to return the same list, but they must be consistent in their ordering.Modifying the returned list has no effect on the AttributeMap
- Returns:
- a list of attributes in the AttributeMap
-
itemAt
default AttributeInfo itemAt(int index)
Get the AttributeInfo with a given index.- Parameters:
index- the index position, zero-based. The order of index positions of attributes in an attribute map reflects document order.- Returns:
- the AttributeInfo at the given position. In an immutable tree the result will always
be equivalent to calling
asList().get(index). However, if the tree has been modified, then the index values of the attributes may not be contiguous. - Throws:
java.lang.IndexOutOfBoundsException- if the index is out of range
-
fromList
static AttributeMap fromList(java.util.List<AttributeInfo> list)
Construct an AttributeMap given a list ofAttributeInfoobjects representing the individual attributes.- Parameters:
list- the list of attributes. It is the caller's responsibility to ensure that this list contains no duplicates. The method may detect this, but is not guaranteed to do so. Callingverify()after constructing the attribute map verifies that there are no duplicates. The order of items in the input list is not necessarily preserved.- Returns:
- an AttributeMap containing the specified attributes.
- Throws:
java.lang.IllegalArgumentException- if duplicate attributes are detected
-
-