Package net.sf.saxon.tree.linked
Class AttributeMapWithIdentity
- java.lang.Object
-
- net.sf.saxon.tree.linked.AttributeMapWithIdentity
-
- All Implemented Interfaces:
java.lang.Iterable<AttributeInfo>
,AttributeMap
public class AttributeMapWithIdentity extends java.lang.Object implements AttributeMap
An implementation of AttributeMap suitable for representing attributes on a mutable tree. Unlike an ordinary AttributeMap, each AttributeInfo has a persistent index value, which remains unchanged when attributes are added or removed or renamed. New attributes are allocated an index value greater than any previously-allocated index value.However, an
AttributeMapWithIdentity
, like any otherAttributeMap
, is an immutable object.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeMapWithIdentity
add(AttributeInfo info)
java.util.ArrayList<AttributeInfo>
asList()
Get the contents of the AttributeMap as a list ofAttributeInfo
objects.AttributeInfo
get(java.lang.String uri, java.lang.String local)
Get the attribute with a given name, if it existsAttributeInfo
get(NodeName name)
Get the attribute with a given name, if it existsAttributeInfo
getByFingerprint(int fingerprint, NamePool namePool)
int
getIndex(java.lang.String uri, java.lang.String local)
AttributeInfo
itemAt(int index)
Get the AttributeInfo with a given index.AxisIterator
iterateAttributes(ElementImpl owner)
java.util.Iterator<AttributeInfo>
iterator()
AttributeMapWithIdentity
remove(int index)
Remove an existing attribute, to create a new AttributeMapAttributeMapWithIdentity
set(int index, AttributeInfo info)
int
size()
Return the number of attributes in the map.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
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.
-
iterateAttributes
public AxisIterator iterateAttributes(ElementImpl owner)
-
get
public AttributeInfo get(NodeName name)
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
public AttributeInfo get(java.lang.String uri, java.lang.String local)
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
-
getIndex
public int getIndex(java.lang.String uri, java.lang.String local)
-
set
public AttributeMapWithIdentity set(int index, AttributeInfo info)
-
add
public AttributeMapWithIdentity add(AttributeInfo info)
-
remove
public AttributeMapWithIdentity remove(int index)
Remove an existing attribute, to create a new AttributeMap- Parameters:
index
- the index of the attribute to be removed (if it exists)- Returns:
- a new attribute map in which the specified attribute is marked as deleted.
-
getByFingerprint
public AttributeInfo getByFingerprint(int fingerprint, NamePool namePool)
- Specified by:
getByFingerprint
in interfaceAttributeMap
-
iterator
public java.util.Iterator<AttributeInfo> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<AttributeInfo>
-
asList
public java.util.ArrayList<AttributeInfo> 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
public AttributeInfo itemAt(int index)
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.
-
-