Package net.sf.saxon.om
Class SingletonAttributeMap
java.lang.Object
net.sf.saxon.om.AttributeInfo
net.sf.saxon.om.SingletonAttributeMap
- All Implemented Interfaces:
Iterable<AttributeInfo>
,AttributeMap
An implementation of AttributeMap for use when there is exactly one attribute
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.om.AttributeInfo
AttributeInfo.Deleted
-
Method Summary
Modifier and TypeMethodDescriptionapply
(Function<AttributeInfo, AttributeInfo> mapper) Apply a function to every attribute in an attribute map, returning a new attribute mapasList()
Get the contents of the AttributeMap as a list ofAttributeInfo
objects.get
(NamespaceUri uri, String local) Get the attribute with a given name, if it existsGet the attribute with a given name, if it existsgetByFingerprint
(int fingerprint, NamePool namePool) itemAt
(int index) Get the AttributeInfo with a given index.iterator()
static SingletonAttributeMap
of
(AttributeInfo att) put
(AttributeInfo att) Replace or add an attribute, to create a new AttributeMapRemove an existing attribute, to create a new AttributeMapint
size()
Return the number of attributes in the map.Methods inherited from class net.sf.saxon.om.AttributeInfo
getLocation, getNodeName, getProperties, getType, getValue, getXdmStringValue, isId, withNodeName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.AttributeMap
getValue, getValue, verify
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
of
-
size
public int size()Return the number of attributes in the map.- Specified by:
size
in interfaceAttributeMap
- Returns:
- The number of attributes in the map.
-
get
Description copied from interface:AttributeMap
Get the attribute with a given name, if it exists- Specified by:
get
in interfaceAttributeMap
- Parameters:
name
- the name of the required attribute- Returns:
- the required attribute if it exists
-
get
Description copied from interface:AttributeMap
Get the attribute with a given name, if it exists- Specified by:
get
in interfaceAttributeMap
- 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
- Specified by:
getByFingerprint
in interfaceAttributeMap
-
put
Description copied from interface:AttributeMap
Replace or add an attribute, to create a new AttributeMap- Specified by:
put
in interfaceAttributeMap
- Parameters:
att
- the attribute to be added or replaced- Returns:
- the new AttributeMap
-
remove
Description copied from interface:AttributeMap
Remove an existing attribute, to create a new AttributeMap- Specified by:
remove
in interfaceAttributeMap
- 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
-
iterator
- Specified by:
iterator
in interfaceIterable<AttributeInfo>
-
apply
Description copied from interface:AttributeMap
Apply a function to every attribute in an attribute map, returning a new attribute map- Specified by:
apply
in interfaceAttributeMap
- 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
Description copied from interface:AttributeMap
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
- Specified by:
asList
in interfaceAttributeMap
- Returns:
- a list of attributes in the AttributeMap
-
itemAt
Description copied from interface:AttributeMap
Get the AttributeInfo with a given index.- Specified by:
itemAt
in interfaceAttributeMap
- 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.
-