public class AttributeCollectionImpl extends java.lang.Object implements org.xml.sax.Attributes, AttributeCollection
As well as providing the information required by the SAX2 interface, an
AttributeCollection can hold type information (as needed to support the JAXP 1.3
ValidatorHandler interface), and location information
for debugging. The location information is used in the case of attributes on a result
tree to identify the location in the query or stylesheet from which they were
generated.
| Modifier and Type | Field and Description |
|---|---|
static AttributeCollectionImpl |
EMPTY_ATTRIBUTE_COLLECTION |
| Constructor and Description |
|---|
AttributeCollectionImpl(Configuration config)
Create an empty attribute list.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(NodeName nodeName,
SimpleType type,
java.lang.String value,
Location locationId,
int properties)
Add an attribute to an attribute list.
|
void |
clear()
Clear the attribute list.
|
void |
compact()
Compact the attribute list to avoid wasting memory
|
static AttributeCollectionImpl |
copy(AttributeCollectionImpl atts)
Create an attribute list as a copy of an existing attribute list
|
int |
findByNodeName(NodeName nodeName)
Find an attribute by node name
|
int |
getFingerprint(int index)
Get the fingerprint of an attribute (by position).
|
int |
getIndex(java.lang.String qname)
Get the index of an attribute, from its lexical QName
|
int |
getIndex(java.lang.String uri,
java.lang.String localname)
Get the index of an attribute (by name).
|
int |
getIndexByFingerprint(int fingerprint)
Get the index, given the fingerprint.
|
int |
getLength()
Return the number of attributes in the list.
|
int |
getLineNumber(int index)
Get the line number part of the location of an attribute, at a given index.
|
java.lang.String |
getLocalName(int index)
Get the local name of an attribute (by position).
|
Location |
getLocation(int index)
Get the location of an attribute (by position)
|
NodeName |
getNodeName(int index)
Get the node name of an attribute (by position).
|
java.lang.String |
getPrefix(int index)
Get the prefix of the name of an attribute (by position).
|
int |
getProperties(int index)
Get the properties of an attribute (by position)
|
java.lang.String |
getQName(int index)
Get the lexical QName of an attribute (by position).
|
java.lang.String |
getSystemId(int index)
Get the systemId part of the location of an attribute, at a given index.
|
java.lang.String |
getType(int index)
Get the type of an attribute (by position).
|
java.lang.String |
getType(java.lang.String name)
Get the type of an attribute (by lexical QName).
|
java.lang.String |
getType(java.lang.String uri,
java.lang.String localname)
Get the type of an attribute (by name).
|
SimpleType |
getTypeAnnotation(int index)
Get the type of an attribute (by position).
|
java.lang.String |
getURI(int index)
Get the namespace URI of an attribute (by position).
|
java.lang.String |
getValue(int index)
Get the value of an attribute (by position).
|
java.lang.String |
getValue(java.lang.String name)
Get the value of an attribute (by lexnical QName).
|
java.lang.String |
getValue(java.lang.String uri,
java.lang.String localname)
Get the value of an attribute (by name).
|
java.lang.String |
getValueByFingerprint(int fingerprint)
Get the attribute value using its fingerprint
|
boolean |
hasAttributeInNamespace(java.lang.String uri)
Ask whether the attribute collection contains any attributes
in a specified namespace
|
boolean |
isDeleted(int index)
Test whether the attribute at a given index has been deleted
|
boolean |
isId(int index)
Determine whether a given attribute has the is-ID property set
|
boolean |
isIdref(int index)
Determine whether a given attribute has the is-idref property set
|
void |
removeAttribute(int index)
Delete the attribute at a given index position.
|
void |
renameAttribute(int index,
NodeName newName)
Rename an attribute
|
void |
replaceAttribute(int index,
java.lang.CharSequence newValue)
Replace the value of an attribute
|
void |
setAttribute(int index,
NodeName nodeName,
SimpleType type,
java.lang.String value,
Location locationId,
int properties)
Set (overwrite) an attribute in the attribute list.
|
void |
setTypeAnnotation(int index,
SimpleType type)
Set the type annotation of an attribute
|
void |
swap(int i,
int j)
Swap two attributes (used for sorting)
|
public static AttributeCollectionImpl EMPTY_ATTRIBUTE_COLLECTION
public AttributeCollectionImpl(Configuration config)
config - the Saxon Configurationpublic static AttributeCollectionImpl copy(AttributeCollectionImpl atts)
atts - the existing attribute list to be copiedEMPTY_ATTRIBUTE_COLLECTION;
this case must therefore be handled specially if the returned attribute list is to
be modified.public void addAttribute(NodeName nodeName, SimpleType type, java.lang.String value, Location locationId, int properties)
Receiver.attribute(NodeName, SimpleType, CharSequence, net.sf.saxon.expr.parser.Location, int)
method. There is no check that the name of the attribute is distinct from other attributes
already in the collection: this check must be made by the caller.nodeName - Object representing the attribute name.type - The attribute typevalue - The attribute value (must not be null)locationId - Identifies the attribute location.properties - Attribute propertiespublic void setAttribute(int index,
NodeName nodeName,
SimpleType type,
java.lang.String value,
Location locationId,
int properties)
Receiver.attribute(NodeName, SimpleType, CharSequence, net.sf.saxon.expr.parser.Location, int)
method.index - Identifies the entry to be replaced. Must be in range (nasty things happen if not)nodeName - representing the attribute name.type - The attribute type codevalue - The attribute value (must not be null)locationId - Identifies the attribtue location.properties - Attribute propertiespublic void clear()
public void compact()
public int getLength()
getLength in interface AttributeCollectiongetLength in interface org.xml.sax.Attributespublic int getFingerprint(int index)
getFingerprint in interface AttributeCollectionindex - The position of the attribute in the list.public NodeName getNodeName(int index)
getNodeName in interface AttributeCollectionindex - The position of the attribute in the list.public SimpleType getTypeAnnotation(int index)
getTypeAnnotation in interface AttributeCollectionindex - The position of the attribute in the list.public Location getLocation(int index)
getLocation in interface AttributeCollectionindex - The position of the attribute in the list.public java.lang.String getSystemId(int index)
Attribute location information is not available from a SAX parser, so this method is not useful for getting the location of an attribute in a source document. However, in a Saxon result document, the location information represents the location in the stylesheet of the instruction used to generate this attribute, which is useful for debugging.
getSystemId in interface AttributeCollectionindex - the required attributepublic int getLineNumber(int index)
Attribute location information is not available from a SAX parser, so this method is not useful for getting the location of an attribute in a source document. However, in a Saxon result document, the location information represents the location in the stylesheet of the instruction used to generate this attribute, which is useful for debugging.
getLineNumber in interface AttributeCollectionindex - the required attributepublic int getProperties(int index)
getProperties in interface AttributeCollectionindex - The position of the attribute in the list.ReceiverOptions. The
most interesting of these is {ReceiverOptions.DEFAULTED_ATTRIBUTE,
which indicates an attribute that was added to an element as a result of schema validation.public java.lang.String getPrefix(int index)
getPrefix in interface AttributeCollectionindex - The position of the attribute in the list.public java.lang.String getQName(int index)
getQName in interface AttributeCollectiongetQName in interface org.xml.sax.Attributesindex - The position of the attribute in the list.public java.lang.String getLocalName(int index)
getLocalName in interface AttributeCollectiongetLocalName in interface org.xml.sax.Attributesindex - The position of the attribute in the list.public java.lang.String getURI(int index)
getURI in interface AttributeCollectiongetURI in interface org.xml.sax.Attributesindex - The position of the attribute in the list.public java.lang.String getType(int index)
getType in interface org.xml.sax.Attributesindex - The position of the attribute in the list.public java.lang.String getType(java.lang.String uri,
java.lang.String localname)
getType in interface org.xml.sax.Attributesuri - The namespace uri of the attribute.localname - The local name of the attribute.public java.lang.String getValue(int index)
getValue in interface AttributeCollectiongetValue in interface org.xml.sax.Attributesindex - The position of the attribute in the list.public java.lang.String getValue(java.lang.String uri,
java.lang.String localname)
getValue in interface AttributeCollectiongetValue in interface org.xml.sax.Attributesuri - The namespace uri of the attribute.localname - The local name of the attribute.public java.lang.String getValueByFingerprint(int fingerprint)
getValueByFingerprint in interface AttributeCollectionpublic int getIndex(java.lang.String qname)
getIndex in interface org.xml.sax.Attributesqname - The lexical QName of the attribute. The prefix must match.public int getIndex(java.lang.String uri,
java.lang.String localname)
getIndex in interface AttributeCollectiongetIndex in interface org.xml.sax.Attributesuri - The namespace uri of the attribute.localname - The local name of the attribute.public int getIndexByFingerprint(int fingerprint)
getIndexByFingerprint in interface AttributeCollectionpublic java.lang.String getType(java.lang.String name)
getType in interface org.xml.sax.Attributesname - The lexical QName of the attribute.public java.lang.String getValue(java.lang.String name)
getValue in interface org.xml.sax.Attributesname - The attribute name (a lexical QName).
The prefix must match the prefix originally used. This method is defined in SAX, but is
not recommended except where the prefix is null.public boolean hasAttributeInNamespace(java.lang.String uri)
uri - the specified namespacepublic int findByNodeName(NodeName nodeName)
nodeName - the name of the required attributepublic boolean isId(int index)
isId in interface AttributeCollectionpublic boolean isIdref(int index)
isIdref in interface AttributeCollectionpublic void removeAttribute(int index)
index - The index position of the attribute to be removedpublic boolean isDeleted(int index)
index - the index position of the (ex-) attributepublic void renameAttribute(int index,
NodeName newName)
index - the index position of the attributenewName - the namecode of the new namepublic void replaceAttribute(int index,
java.lang.CharSequence newValue)
index - position of the attributenewValue - the new string value of the attributepublic void setTypeAnnotation(int index,
SimpleType type)
index - the index position of the attribute nodetype - the new type for the attributepublic void swap(int i,
int j)
i - the position of one valuej - the position of the other valueCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.