Package net.sf.saxon.om
Interface AttributeMap
- All Superinterfaces:
Iterable<AttributeInfo>
- All Known Implementing Classes:
AttributeMapWithIdentity
,EmptyAttributeMap
,LargeAttributeMap
,SingletonAttributeMap
,SmallAttributeMap
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
Modifier and TypeMethodDescriptiondefault AttributeMap
apply
(Function<AttributeInfo, AttributeInfo> mapper) Apply a function to every attribute in an attribute map, returning a new attribute mapdefault ArrayList
<AttributeInfo> asList()
Get the contents of the AttributeMap as a list ofAttributeInfo
objects.default AttributeInfo
get
(NamespaceUri uri, String local) Get the attribute with a given name, if it existsdefault AttributeInfo
Get the attribute with a given name, if it existsdefault AttributeInfo
getByFingerprint
(int fingerprint, NamePool namePool) default String
Get the value of a no-namespace attribute with a given local name, if it existsdefault String
getValue
(NamespaceUri uri, String local) Get the value of the attribute with a given name, if it existsdefault AttributeInfo
itemAt
(int index) Get the AttributeInfo with a given index.default AttributeMap
put
(AttributeInfo att) Replace or add an attribute, to create a new AttributeMapdefault AttributeMap
Remove an existing attribute, to create a new AttributeMapint
size()
Return the number of attributes in the map.default void
verify()
Verify the consistency of the attribute map.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Return the number of attributes in the map.- Returns:
- The number of attributes in the map.
-
get
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
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
-
getValue
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
-
getValue
Get the value of a no-namespace attribute with a given local name, if it exists- Parameters:
local
- the local part of the name of the required attribute; the attribute must be in no namespace- Returns:
- the value of the required attribute if it exists, or null otherwise
-
put
Replace or add an attribute, to create a new AttributeMap- Parameters:
att
- the attribute to be added or replaced- Returns:
- the new AttributeMap
-
remove
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()Verify the consistency of the attribute map. This performs an implementation-defined set of checks that might include checking for duplicates, checking that names are well-formed, checking for inappropriate use of the xml and xmlns namespaces, and checking the constraint that attributes in a namespace have a prefix, and vice versa. The default implementation does nothing.- Throws:
IllegalStateException
- if the attribute map is invalid.
-
apply
Apply a function to every attribute in an attribute map, returning a new attribute map- Parameters:
mapper
- the mapping function to be applied to each attribute in the attribute map- Returns:
- the attribute containing the attributes after the mapping function has been applied
-
asList
Get the contents of the AttributeMap as a list ofAttributeInfo
objects.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
AttributeInfo
objects; 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
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:
IndexOutOfBoundsException
- if the index is out of range
-