Class EncodingAlgorithmAttributesImpl
- java.lang.Object
-
- org.jvnet.fastinfoset.sax.helpers.EncodingAlgorithmAttributesImpl
-
- All Implemented Interfaces:
EncodingAlgorithmAttributes,Attributes
public class EncodingAlgorithmAttributesImpl extends Object implements EncodingAlgorithmAttributes
Default implementation of theEncodingAlgorithmAttributesinterface.This class provides a default implementation of the SAX2
EncodingAlgorithmAttributesinterface, with the addition of manipulators so that the list can be modified or reused.There are two typical uses of this class:
- to take a persistent snapshot of an EncodingAlgorithmAttributes object
in a
startElementevent; or - to construct or modify an EncodingAlgorithmAttributes object in a SAX2 driver or filter.
-
-
Constructor Summary
Constructors Constructor Description EncodingAlgorithmAttributesImpl()Construct a new, empty EncodingAlgorithmAttributesImpl object.EncodingAlgorithmAttributesImpl(Map registeredEncodingAlgorithms, Attributes attributes)Use registered encoding algorithms and copy an existing Attributes object.EncodingAlgorithmAttributesImpl(Attributes attributes)Copy an existing Attributes object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String URI, String localName, String qName, String type, String value)Add an attribute to the end of the list.voidaddAttribute(String URI, String localName, String qName, String type, String value, boolean index, String alphabet)Add an attribute to the end of the list.voidaddAttributeWithAlgorithmData(String URI, String localName, String qName, String algorithmURI, int algorithmID, Object algorithmData)Add an attribute with algorithm data to the end of the list.voidaddAttributeWithBuiltInAlgorithmData(String URI, String localName, String qName, int builtInAlgorithmID, Object algorithmData)Add an attribute with built in algorithm data to the end of the list.voidclear()Clear the attribute list for reuse.ObjectgetAlgorithmData(int index)Return the data of the encoding algorithm.intgetAlgorithmIndex(int index)Return the index of the encoding algorithm.StringgetAlgorithmURI(int index)Return the URI of the encoding algorithm.StringgetAlpababet(int index)Return the alphabet associated with the attribute value.intgetIndex(String qName)intgetIndex(String uri, String localName)intgetLength()StringgetLocalName(int index)StringgetQName(int index)booleangetToIndex(int index)Return the whether the attribute value should be indexed or not.StringgetType(int index)StringgetType(String qName)StringgetType(String uri, String localName)StringgetURI(int index)StringgetValue(int index)StringgetValue(String qName)StringgetValue(String uri, String localName)voidreplaceWithAttributeAlgorithmData(int index, String algorithmURI, int algorithmID, Object algorithmData)Replace an attribute value with algorithm data.voidsetAttributes(EncodingAlgorithmAttributes atts)Copy an entire EncodingAlgorithmAttributes object.voidsetAttributes(Attributes atts)Copy an entire Attributes object.
-
-
-
Constructor Detail
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl()
Construct a new, empty EncodingAlgorithmAttributesImpl object.
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl(Attributes attributes)
Copy an existing Attributes object.This constructor is especially useful inside a
startElementevent.- Parameters:
attributes- The existing Attributes object.
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl(Map registeredEncodingAlgorithms, Attributes attributes)
Use registered encoding algorithms and copy an existing Attributes object.This constructor is especially useful inside a
startElementevent.- Parameters:
registeredEncodingAlgorithms- The registeredEncodingAlgorithms encoding algorithms.attributes- The existing Attributes object.
-
-
Method Detail
-
clear
public final void clear()
Clear the attribute list for reuse.
-
addAttribute
public void addAttribute(String URI, String localName, String qName, String type, String value)
Add an attribute to the end of the list.For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
- Parameters:
URI- The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.localName- The local name, or the empty string if Namespace processing is not being performed.qName- The qualified (prefixed) name, or the empty string if qualified names are not available.type- The attribute type as a string.value- The attribute value.
-
addAttribute
public void addAttribute(String URI, String localName, String qName, String type, String value, boolean index, String alphabet)
Add an attribute to the end of the list.For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
- Parameters:
URI- The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.localName- The local name, or the empty string if Namespace processing is not being performed.qName- The qualified (prefixed) name, or the empty string if qualified names are not available.type- The attribute type as a string.value- The attribute value.index- True if attribute should be indexed.alphabet- The alphabet associated with the attribute value, may be null if there is no associated alphabet.
-
addAttributeWithBuiltInAlgorithmData
public void addAttributeWithBuiltInAlgorithmData(String URI, String localName, String qName, int builtInAlgorithmID, Object algorithmData)
Add an attribute with built in algorithm data to the end of the list.For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
- Parameters:
URI- The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.localName- The local name, or the empty string if Namespace processing is not being performed.qName- The qualified (prefixed) name, or the empty string if qualified names are not available.builtInAlgorithmID- The built in algorithm ID.algorithmData- The built in algorithm data.
-
addAttributeWithAlgorithmData
public void addAttributeWithAlgorithmData(String URI, String localName, String qName, String algorithmURI, int algorithmID, Object algorithmData)
Add an attribute with algorithm data to the end of the list.For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
- Parameters:
URI- The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.localName- The local name, or the empty string if Namespace processing is not being performed.qName- The qualified (prefixed) name, or the empty string if qualified names are not available.algorithmURI- The algorithm URI, or null if a built in algorithmalgorithmID- The algorithm ID.algorithmData- The algorithm data.
-
replaceWithAttributeAlgorithmData
public void replaceWithAttributeAlgorithmData(int index, String algorithmURI, int algorithmID, Object algorithmData)Replace an attribute value with algorithm data.For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
- Parameters:
index- The index of the attribute whose value is to be replacedalgorithmURI- The algorithm URI, or null if a built in algorithmalgorithmID- The algorithm ID.algorithmData- The algorithm data.
-
setAttributes
public void setAttributes(Attributes atts)
Copy an entire Attributes object.- Parameters:
atts- The attributes to copy.
-
setAttributes
public void setAttributes(EncodingAlgorithmAttributes atts)
Copy an entire EncodingAlgorithmAttributes object.- Parameters:
atts- The attributes to copy.
-
getLength
public final int getLength()
- Specified by:
getLengthin interfaceAttributes
-
getLocalName
public final String getLocalName(int index)
- Specified by:
getLocalNamein interfaceAttributes
-
getQName
public final String getQName(int index)
- Specified by:
getQNamein interfaceAttributes
-
getType
public final String getType(int index)
- Specified by:
getTypein interfaceAttributes
-
getURI
public final String getURI(int index)
- Specified by:
getURIin interfaceAttributes
-
getValue
public final String getValue(int index)
- Specified by:
getValuein interfaceAttributes
-
getIndex
public final int getIndex(String qName)
- Specified by:
getIndexin interfaceAttributes
-
getType
public final String getType(String qName)
- Specified by:
getTypein interfaceAttributes
-
getValue
public final String getValue(String qName)
- Specified by:
getValuein interfaceAttributes
-
getIndex
public final int getIndex(String uri, String localName)
- Specified by:
getIndexin interfaceAttributes
-
getType
public final String getType(String uri, String localName)
- Specified by:
getTypein interfaceAttributes
-
getValue
public final String getValue(String uri, String localName)
- Specified by:
getValuein interfaceAttributes
-
getAlgorithmURI
public final String getAlgorithmURI(int index)
Description copied from interface:EncodingAlgorithmAttributesReturn the URI of the encoding algorithm.If the algorithm data corresponds to a built-in encoding algorithm then the null is returned.
If the algorithm data corresponds to an application-defined encoding algorithm then the URI of the algorithm is returned.
If
EncodingAlgorithmAttributes.getAlgorithmData(int)returns null then the result of this method is undefined.- Specified by:
getAlgorithmURIin interfaceEncodingAlgorithmAttributes- Parameters:
index- The attribute index (zero-based).- Returns:
- The URI. If the index is out of range then null is returned.
-
getAlgorithmIndex
public final int getAlgorithmIndex(int index)
Description copied from interface:EncodingAlgorithmAttributesReturn the index of the encoding algorithm.If
EncodingAlgorithmAttributes.getAlgorithmData(int)returns null then the result of this method is undefined.- Specified by:
getAlgorithmIndexin interfaceEncodingAlgorithmAttributes- Parameters:
index- The attribute index (zero-based).- Returns:
- The algorithm index. If index is out of range then -1 is returned.
- See Also:
EncodingAlgorithmIndexes
-
getAlgorithmData
public final Object getAlgorithmData(int index)
Description copied from interface:EncodingAlgorithmAttributesReturn the data of the encoding algorithm.If the algorithm data corresponds to a built-in encoding algorithm then an Object corresponding to the Java primitive type is returned.
If the algorithm data corresponds to an application-defined encoding algorithm then an Object that is an instance of
byte[]is returned if there is no EncodingAlgorithm registered for the application-defined encoding algorithm URI. Otherwise, an Object produced from the registeredEncodingAlgorithm is returned.If there no encoding algorithm data associated an attribute then
nullis returned.- Specified by:
getAlgorithmDatain interfaceEncodingAlgorithmAttributes- Parameters:
index- The attribute index (zero-based).- Returns:
- The data. If the index is out of range then null is returned.
-
getAlpababet
public final String getAlpababet(int index)
Description copied from interface:EncodingAlgorithmAttributesReturn the alphabet associated with the attribute value.- Specified by:
getAlpababetin interfaceEncodingAlgorithmAttributes- Parameters:
index- The attribute index (zero-based).- Returns:
- The alphabet. If the index is out of range then null is returned. If there is is no alphabet then null is returned.
-
getToIndex
public final boolean getToIndex(int index)
Description copied from interface:EncodingAlgorithmAttributesReturn the whether the attribute value should be indexed or not.- Specified by:
getToIndexin interfaceEncodingAlgorithmAttributes- Parameters:
index- The attribute index (zero-based).- Returns:
- True if attribute value should be indexed, otherwise false.
-
-