Class EncodingAlgorithmAttributesImpl
- java.lang.Object
-
- org.jvnet.fastinfoset.sax.helpers.EncodingAlgorithmAttributesImpl
-
- All Implemented Interfaces:
EncodingAlgorithmAttributes
,org.xml.sax.Attributes
public class EncodingAlgorithmAttributesImpl extends java.lang.Object implements EncodingAlgorithmAttributes
Default implementation of theEncodingAlgorithmAttributes
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
Fields Modifier and Type Field Description private java.lang.Object[]
_algorithmData
private int[]
_algorithmIds
private java.lang.String[]
_alphabets
private java.lang.String[]
_data
private int
_length
private java.util.Map
_registeredEncodingAlgorithms
private boolean[]
_toIndex
private static int
ALGORITHMURI_OFFSET
private static int
DEFAULT_CAPACITY
private static int
LOCALNAME_OFFSET
private static int
QNAME_OFFSET
private static int
SIZE
private static int
TYPE_OFFSET
private static int
URI_OFFSET
private static int
VALUE_OFFSET
-
Constructor Summary
Constructors Constructor Description EncodingAlgorithmAttributesImpl()
Construct a new, empty EncodingAlgorithmAttributesImpl object.EncodingAlgorithmAttributesImpl(java.util.Map registeredEncodingAlgorithms, org.xml.sax.Attributes attributes)
Use registered encoding algorithms and copy an existing Attributes object.EncodingAlgorithmAttributesImpl(org.xml.sax.Attributes attributes)
Copy an existing Attributes object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(java.lang.String URI, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value)
Add an attribute to the end of the list.void
addAttribute(java.lang.String URI, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value, boolean index, java.lang.String alphabet)
Add an attribute to the end of the list.void
addAttributeWithAlgorithmData(java.lang.String URI, java.lang.String localName, java.lang.String qName, java.lang.String algorithmURI, int algorithmID, java.lang.Object algorithmData)
Add an attribute with algorithm data to the end of the list.void
addAttributeWithBuiltInAlgorithmData(java.lang.String URI, java.lang.String localName, java.lang.String qName, int builtInAlgorithmID, java.lang.Object algorithmData)
Add an attribute with built in algorithm data to the end of the list.void
clear()
Clear the attribute list for reuse.private java.lang.StringBuffer
convertEncodingAlgorithmDataToString(int identifier, java.lang.String URI, java.lang.Object data)
java.lang.Object
getAlgorithmData(int index)
Return the data of the encoding algorithm.int
getAlgorithmIndex(int index)
Return the index of the encoding algorithm.java.lang.String
getAlgorithmURI(int index)
Return the URI of the encoding algorithm.java.lang.String
getAlpababet(int index)
Return the alphabet associated with the attribute value.int
getIndex(java.lang.String qName)
int
getIndex(java.lang.String uri, java.lang.String localName)
int
getLength()
java.lang.String
getLocalName(int index)
java.lang.String
getQName(int index)
boolean
getToIndex(int index)
Return the whether the attribute value should be indexed or not.java.lang.String
getType(int index)
java.lang.String
getType(java.lang.String qName)
java.lang.String
getType(java.lang.String uri, java.lang.String localName)
java.lang.String
getURI(int index)
java.lang.String
getValue(int index)
java.lang.String
getValue(java.lang.String qName)
java.lang.String
getValue(java.lang.String uri, java.lang.String localName)
private java.lang.String
replaceNull(java.lang.String s)
void
replaceWithAttributeAlgorithmData(int index, java.lang.String algorithmURI, int algorithmID, java.lang.Object algorithmData)
Replace an attribute value with algorithm data.private void
resize()
private void
resizeNoCopy()
void
setAttributes(EncodingAlgorithmAttributes atts)
Copy an entire EncodingAlgorithmAttributes object.void
setAttributes(org.xml.sax.Attributes atts)
Copy an entire Attributes object.
-
-
-
Field Detail
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
-
URI_OFFSET
private static final int URI_OFFSET
- See Also:
- Constant Field Values
-
LOCALNAME_OFFSET
private static final int LOCALNAME_OFFSET
- See Also:
- Constant Field Values
-
QNAME_OFFSET
private static final int QNAME_OFFSET
- See Also:
- Constant Field Values
-
TYPE_OFFSET
private static final int TYPE_OFFSET
- See Also:
- Constant Field Values
-
VALUE_OFFSET
private static final int VALUE_OFFSET
- See Also:
- Constant Field Values
-
ALGORITHMURI_OFFSET
private static final int ALGORITHMURI_OFFSET
- See Also:
- Constant Field Values
-
SIZE
private static final int SIZE
- See Also:
- Constant Field Values
-
_registeredEncodingAlgorithms
private java.util.Map _registeredEncodingAlgorithms
-
_length
private int _length
-
_data
private java.lang.String[] _data
-
_algorithmIds
private int[] _algorithmIds
-
_algorithmData
private java.lang.Object[] _algorithmData
-
_alphabets
private java.lang.String[] _alphabets
-
_toIndex
private boolean[] _toIndex
-
-
Constructor Detail
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl()
Construct a new, empty EncodingAlgorithmAttributesImpl object.
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl(org.xml.sax.Attributes attributes)
Copy an existing Attributes object.This constructor is especially useful inside a
startElement
event.- Parameters:
attributes
- The existing Attributes object.
-
EncodingAlgorithmAttributesImpl
public EncodingAlgorithmAttributesImpl(java.util.Map registeredEncodingAlgorithms, org.xml.sax.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 Detail
-
clear
public final void clear()
Clear the attribute list for reuse.
-
addAttribute
public void addAttribute(java.lang.String URI, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.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(java.lang.String URI, java.lang.String localName, java.lang.String qName, java.lang.String type, java.lang.String value, boolean index, java.lang.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(java.lang.String URI, java.lang.String localName, java.lang.String qName, int builtInAlgorithmID, java.lang.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(java.lang.String URI, java.lang.String localName, java.lang.String qName, java.lang.String algorithmURI, int algorithmID, java.lang.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, java.lang.String algorithmURI, int algorithmID, java.lang.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(org.xml.sax.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:
getLength
in interfaceorg.xml.sax.Attributes
-
getLocalName
public final java.lang.String getLocalName(int index)
- Specified by:
getLocalName
in interfaceorg.xml.sax.Attributes
-
getQName
public final java.lang.String getQName(int index)
- Specified by:
getQName
in interfaceorg.xml.sax.Attributes
-
getType
public final java.lang.String getType(int index)
- Specified by:
getType
in interfaceorg.xml.sax.Attributes
-
getURI
public final java.lang.String getURI(int index)
- Specified by:
getURI
in interfaceorg.xml.sax.Attributes
-
getValue
public final java.lang.String getValue(int index)
- Specified by:
getValue
in interfaceorg.xml.sax.Attributes
-
getIndex
public final int getIndex(java.lang.String qName)
- Specified by:
getIndex
in interfaceorg.xml.sax.Attributes
-
getType
public final java.lang.String getType(java.lang.String qName)
- Specified by:
getType
in interfaceorg.xml.sax.Attributes
-
getValue
public final java.lang.String getValue(java.lang.String qName)
- Specified by:
getValue
in interfaceorg.xml.sax.Attributes
-
getIndex
public final int getIndex(java.lang.String uri, java.lang.String localName)
- Specified by:
getIndex
in interfaceorg.xml.sax.Attributes
-
getType
public final java.lang.String getType(java.lang.String uri, java.lang.String localName)
- Specified by:
getType
in interfaceorg.xml.sax.Attributes
-
getValue
public final java.lang.String getValue(java.lang.String uri, java.lang.String localName)
- Specified by:
getValue
in interfaceorg.xml.sax.Attributes
-
getAlgorithmURI
public final java.lang.String getAlgorithmURI(int index)
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:
EncodingAlgorithmIndexes
-
getAlgorithmData
public final java.lang.Object getAlgorithmData(int index)
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
public final java.lang.String getAlpababet(int index)
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
private final java.lang.String replaceNull(java.lang.String s)
-
resizeNoCopy
private final void resizeNoCopy()
-
resize
private final void resize()
-
convertEncodingAlgorithmDataToString
private final java.lang.StringBuffer convertEncodingAlgorithmDataToString(int identifier, java.lang.String URI, java.lang.Object data) throws FastInfosetException, java.io.IOException
- Throws:
FastInfosetException
java.io.IOException
-
-