Class EncodingAlgorithmAttributesImpl
- All Implemented Interfaces:
EncodingAlgorithmAttributes
,Attributes
EncodingAlgorithmAttributes
interface.
This class provides a default implementation of the SAX2
EncodingAlgorithmAttributes
interface, 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
startElement
event; or - to construct or modify an EncodingAlgorithmAttributes object in a SAX2 driver or filter.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Object[]
private int[]
private String[]
private String[]
private int
private Map
<String, EncodingAlgorithm> private boolean[]
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new, empty EncodingAlgorithmAttributesImpl object.EncodingAlgorithmAttributesImpl
(Map<String, EncodingAlgorithm> registeredEncodingAlgorithms, Attributes attributes) Use registered encoding algorithms and copy an existing Attributes object.EncodingAlgorithmAttributesImpl
(Attributes attributes) Copy an existing Attributes object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an attribute to the end of the list.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.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.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.final void
clear()
Clear the attribute list for reuse.private StringBuilder
convertEncodingAlgorithmDataToString
(int identifier, String URI, Object data) final Object
getAlgorithmData
(int index) Return the data of the encoding algorithm.final int
getAlgorithmIndex
(int index) Return the index of the encoding algorithm.final String
getAlgorithmURI
(int index) Return the URI of the encoding algorithm.final String
getAlpababet
(int index) Return the alphabet associated with the attribute value.final int
final int
final int
final String
getLocalName
(int index) final String
getQName
(int index) final boolean
getToIndex
(int index) Return the whether the attribute value should be indexed or not.final String
getType
(int index) final String
final String
final String
getURI
(int index) final String
getValue
(int index) final String
final String
private String
void
replaceWithAttributeAlgorithmData
(int index, String algorithmURI, int algorithmID, Object algorithmData) Replace an attribute value with algorithm data.private void
resize()
private void
final void
Copy an entire EncodingAlgorithmAttributes object.final void
setAttributes
(Attributes atts) Copy an entire Attributes object.
-
Field Details
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY- See Also:
-
URI_OFFSET
private static final int URI_OFFSET- See Also:
-
LOCALNAME_OFFSET
private static final int LOCALNAME_OFFSET- See Also:
-
QNAME_OFFSET
private static final int QNAME_OFFSET- See Also:
-
TYPE_OFFSET
private static final int TYPE_OFFSET- See Also:
-
VALUE_OFFSET
private static final int VALUE_OFFSET- See Also:
-
ALGORITHMURI_OFFSET
private static final int ALGORITHMURI_OFFSET- See Also:
-
SIZE
private static final int SIZE- See Also:
-
_registeredEncodingAlgorithms
-
_length
private int _length -
_data
-
_algorithmIds
private int[] _algorithmIds -
_algorithmData
-
_alphabets
-
_toIndex
private boolean[] _toIndex
-
-
Constructor Details
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl()Construct a new, empty EncodingAlgorithmAttributesImpl object. -
EncodingAlgorithmAttributesImpl
Copy an existing Attributes object.This constructor is especially useful inside a
startElement
event.- Parameters:
attributes
- The existing Attributes object.
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl(Map<String, EncodingAlgorithm> registeredEncodingAlgorithms, Attributes attributes) Use registered encoding algorithms and copy an existing Attributes object.This constructor is especially useful inside a
startElement
event.- Parameters:
registeredEncodingAlgorithms
- The registeredEncodingAlgorithms encoding algorithms.attributes
- The existing Attributes object.
-
-
Method Details
-
clear
public final void clear()Clear the attribute list for reuse. -
addAttribute
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
Copy an entire Attributes object.- Parameters:
atts
- The attributes to copy.
-
setAttributes
Copy an entire EncodingAlgorithmAttributes object.- Parameters:
atts
- The attributes to copy.
-
getLength
public final int getLength()- Specified by:
getLength
in interfaceAttributes
-
getLocalName
- Specified by:
getLocalName
in interfaceAttributes
-
getQName
- Specified by:
getQName
in interfaceAttributes
-
getType
- Specified by:
getType
in interfaceAttributes
-
getURI
- Specified by:
getURI
in interfaceAttributes
-
getValue
- Specified by:
getValue
in interfaceAttributes
-
getIndex
- Specified by:
getIndex
in interfaceAttributes
-
getType
- Specified by:
getType
in interfaceAttributes
-
getValue
- Specified by:
getValue
in interfaceAttributes
-
getIndex
- Specified by:
getIndex
in interfaceAttributes
-
getType
- Specified by:
getType
in interfaceAttributes
-
getValue
- Specified by:
getValue
in interfaceAttributes
-
getAlgorithmURI
Description copied from interface:EncodingAlgorithmAttributes
Return 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:
getAlgorithmURI
in 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:EncodingAlgorithmAttributes
Return the index of the encoding algorithm.If
EncodingAlgorithmAttributes.getAlgorithmData(int)
returns null then the result of this method is undefined.- Specified by:
getAlgorithmIndex
in interfaceEncodingAlgorithmAttributes
- Parameters:
index
- The attribute index (zero-based).- Returns:
- The algorithm index. If index is out of range then -1 is returned.
- See Also:
-
getAlgorithmData
Description copied from interface:EncodingAlgorithmAttributes
Return 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
null
is returned.- Specified by:
getAlgorithmData
in interfaceEncodingAlgorithmAttributes
- Parameters:
index
- The attribute index (zero-based).- Returns:
- The data. If the index is out of range then null is returned.
-
getAlpababet
Description copied from interface:EncodingAlgorithmAttributes
Return the alphabet associated with the attribute value.- Specified by:
getAlpababet
in 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:EncodingAlgorithmAttributes
Return the whether the attribute value should be indexed or not.- Specified by:
getToIndex
in interfaceEncodingAlgorithmAttributes
- Parameters:
index
- The attribute index (zero-based).- Returns:
- True if attribute value should be indexed, otherwise false.
-
replaceNull
-
resizeNoCopy
private void resizeNoCopy() -
resize
private void resize() -
convertEncodingAlgorithmDataToString
private StringBuilder convertEncodingAlgorithmDataToString(int identifier, String URI, Object data) throws FastInfosetException, IOException - Throws:
FastInfosetException
IOException
-