Top Description Fields Constructors Methods
org.jvnet.fastinfoset.sax.helpers

public Class EncodingAlgorithmAttributesImpl

extends Object
implements EncodingAlgorithmAttributes
Class Inheritance
All Implemented Interfaces
org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes, org.xml.sax.Attributes
Imports
com.sun.xml.fastinfoset.CommonResourceBundle, .EncodingConstants, com.sun.xml.fastinfoset.algorithm.BuiltInEncodingAlgorithmFactory, java.io.IOException, java.util.Map, org.jvnet.fastinfoset.EncodingAlgorithm, .EncodingAlgorithmException, .EncodingAlgorithmIndexes, .FastInfosetException, org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes, org.xml.sax.Attributes

Default implementation of the 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:

  1. to take a persistent snapshot of an EncodingAlgorithmAttributes object in a startElement event; or
  2. to construct or modify an EncodingAlgorithmAttributes object in a SAX2 driver or filter.

Field Summary

Modifier and TypeField and Description
private 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

AccessConstructor and Description
public
EncodingAlgorithmAttributesImpl()

Construct a new, empty EncodingAlgorithmAttributesImpl object.

public
EncodingAlgorithmAttributesImpl(Attributes
The existing Attributes object.
attributes
)

Copy an existing Attributes object.

public
EncodingAlgorithmAttributesImpl(Map<String, EncodingAlgorithm>
The registeredEncodingAlgorithms encoding algorithms.
registeredEncodingAlgorithms
,
Attributes
The existing Attributes object.
attributes
)

Use registered encoding algorithms and copy an existing Attributes object.

Method Summary

Modifier and TypeMethod and Description
public void
addAttribute(String
The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
URI
,
String
The local name, or the empty string if Namespace processing is not being performed.
localName
,
String
The qualified (prefixed) name, or the empty string if qualified names are not available.
qName
,
String
The attribute type as a string.
type
,
String
The attribute value.
value
)

Add an attribute to the end of the list.

public void
addAttribute(String
The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
URI
,
String
The local name, or the empty string if Namespace processing is not being performed.
localName
,
String
The qualified (prefixed) name, or the empty string if qualified names are not available.
qName
,
String
The attribute type as a string.
type
,
String
The attribute value.
value
,
boolean
True if attribute should be indexed.
index
,
String
The alphabet associated with the attribute value, may be null if there is no associated alphabet.
alphabet
)

Add an attribute to the end of the list.

public void
addAttributeWithAlgorithmData(String
The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
URI
,
String
The local name, or the empty string if Namespace processing is not being performed.
localName
,
String
The qualified (prefixed) name, or the empty string if qualified names are not available.
qName
,
String
The algorithm URI, or null if a built in algorithm
algorithmURI
,
int
The algorithm ID.
algorithmID
,
Object
The algorithm data.
algorithmData
)

Add an attribute with algorithm data to the end of the list.

public void
addAttributeWithBuiltInAlgorithmData(String
The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
URI
,
String
The local name, or the empty string if Namespace processing is not being performed.
localName
,
String
The qualified (prefixed) name, or the empty string if qualified names are not available.
qName
,
int
The built in algorithm ID.
builtInAlgorithmID
,
Object
The built in algorithm data.
algorithmData
)

Add an attribute with built in algorithm data to the end of the list.

public final void
clear()

Clear the attribute list for reuse.

private StringBuilder
public final Object
getAlgorithmData(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmData.

Return the data of the encoding algorithm.

public final int
getAlgorithmIndex(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmIndex.

Return the index of the encoding algorithm.

public final String
getAlgorithmURI(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmURI.

Return the URI of the encoding algorithm.

public final String
getAlpababet(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlpababet.

Return the alphabet associated with the attribute value.

public final int
getIndex(String qName)

Implements org.xml.sax.Attributes.getIndex.

Look up the index of an attribute by XML qualified (prefixed) name.

public final int
getIndex(String uri, String localName)

Implements org.xml.sax.Attributes.getIndex.

Look up the index of an attribute by Namespace name.

public final int
getLength()

Implements org.xml.sax.Attributes.getLength.

Return the number of attributes in the list.

public final String
getLocalName(int index)

Implements org.xml.sax.Attributes.getLocalName.

Look up an attribute's local name by index.

public final String
getQName(int index)

Implements org.xml.sax.Attributes.getQName.

Look up an attribute's XML qualified (prefixed) name by index.

public final boolean
getToIndex(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getToIndex.

Return the whether the attribute value should be indexed or not.

public final String
getType(int index)

Implements org.xml.sax.Attributes.getType.

Look up an attribute's type by index.

public final String
getType(String qName)

Implements org.xml.sax.Attributes.getType.

Look up an attribute's type by XML qualified (prefixed) name.

public final String
getType(String uri, String localName)

Implements org.xml.sax.Attributes.getType.

Look up an attribute's type by Namespace name.

public final String
getURI(int index)

Implements org.xml.sax.Attributes.getURI.

Look up an attribute's Namespace URI by index.

public final String
getValue(int index)

Implements org.xml.sax.Attributes.getValue.

Look up an attribute's value by index.

public final String
getValue(String qName)

Implements org.xml.sax.Attributes.getValue.

Look up an attribute's value by XML qualified (prefixed) name.

public final String
getValue(String uri, String localName)

Implements org.xml.sax.Attributes.getValue.

Look up an attribute's value by Namespace name.

private String
public void
replaceWithAttributeAlgorithmData(int
The index of the attribute whose value is to be replaced
index
,
String
The algorithm URI, or null if a built in algorithm
algorithmURI
,
int
The algorithm ID.
algorithmID
,
Object
The algorithm data.
algorithmData
)

Replace an attribute value with algorithm data.

private void
private void
public final void
setAttributes(Attributes
The attributes to copy.
atts
)

Copy an entire Attributes object.

public final void
setAttributes(EncodingAlgorithmAttributes
The attributes to copy.
atts
)

Copy an entire EncodingAlgorithmAttributes object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_algorithmDataback to summary
private Object[] _algorithmData
_algorithmIdsback to summary
private int[] _algorithmIds
_alphabetsback to summary
private String[] _alphabets
_databack to summary
private String[] _data
_lengthback to summary
private int _length
_registeredEncodingAlgorithmsback to summary
private Map<String, EncodingAlgorithm> _registeredEncodingAlgorithms
_toIndexback to summary
private boolean[] _toIndex
ALGORITHMURI_OFFSETback to summary
private static final int ALGORITHMURI_OFFSET
DEFAULT_CAPACITYback to summary
private static final int DEFAULT_CAPACITY
LOCALNAME_OFFSETback to summary
private static final int LOCALNAME_OFFSET
QNAME_OFFSETback to summary
private static final int QNAME_OFFSET
SIZEback to summary
private static final int SIZE
TYPE_OFFSETback to summary
private static final int TYPE_OFFSET
URI_OFFSETback to summary
private static final int URI_OFFSET
VALUE_OFFSETback to summary
private static final int VALUE_OFFSET

Constructor Detail

EncodingAlgorithmAttributesImplback to summary
public EncodingAlgorithmAttributesImpl()

Construct a new, empty EncodingAlgorithmAttributesImpl object.

EncodingAlgorithmAttributesImplback to summary
public EncodingAlgorithmAttributesImpl(Attributes attributes)

Copy an existing Attributes object.

This constructor is especially useful inside a startElement event.

Parameters
attributes:Attributes

The existing Attributes object.

EncodingAlgorithmAttributesImplback to summary
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:Map<String, EncodingAlgorithm>

The registeredEncodingAlgorithms encoding algorithms.

attributes:Attributes

The existing Attributes object.

Method Detail

addAttributeback to summary
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:String

The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.

localName:String

The local name, or the empty string if Namespace processing is not being performed.

qName:String

The qualified (prefixed) name, or the empty string if qualified names are not available.

type:String

The attribute type as a string.

value:String

The attribute value.

addAttributeback to summary
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:String

The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.

localName:String

The local name, or the empty string if Namespace processing is not being performed.

qName:String

The qualified (prefixed) name, or the empty string if qualified names are not available.

type:String

The attribute type as a string.

value:String

The attribute value.

index:boolean

True if attribute should be indexed.

alphabet:String

The alphabet associated with the attribute value, may be null if there is no associated alphabet.

addAttributeWithAlgorithmDataback to summary
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:String

The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.

localName:String

The local name, or the empty string if Namespace processing is not being performed.

qName:String

The qualified (prefixed) name, or the empty string if qualified names are not available.

algorithmURI:String

The algorithm URI, or null if a built in algorithm

algorithmID:int

The algorithm ID.

algorithmData:Object

The algorithm data.

addAttributeWithBuiltInAlgorithmDataback to summary
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:String

The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.

localName:String

The local name, or the empty string if Namespace processing is not being performed.

qName:String

The qualified (prefixed) name, or the empty string if qualified names are not available.

builtInAlgorithmID:int

The built in algorithm ID.

algorithmData:Object

The built in algorithm data.

clearback to summary
public final void clear()

Clear the attribute list for reuse.

convertEncodingAlgorithmDataToStringback to summary
private StringBuilder convertEncodingAlgorithmDataToString(int identifier, String URI, Object data) throws FastInfosetException, IOException
getAlgorithmDataback to summary
public final Object getAlgorithmData(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmData.

Doc from org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmData.

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.

Annotations
@Override
getAlgorithmIndexback to summary
public final int getAlgorithmIndex(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmIndex.

Doc from org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmIndex.

Return the index of the encoding algorithm.

If getAlgorithmData(int) returns null then the result of this method is undefined.

Annotations
@Override
getAlgorithmURIback to summary
public final String getAlgorithmURI(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmURI.

Doc from org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlgorithmURI.

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 getAlgorithmData(int) returns null then the result of this method is undefined.

Annotations
@Override
getAlpababetback to summary
public final String getAlpababet(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlpababet.

Doc from org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getAlpababet.

Return the alphabet associated with the attribute value.

Annotations
@Override
getIndexback to summary
public final int getIndex(String qName)

Implements org.xml.sax.Attributes.getIndex.

Doc from org.xml.sax.Attributes.getIndex.

Look up the index of an attribute by XML qualified (prefixed) name.

Annotations
@Override
getIndexback to summary
public final int getIndex(String uri, String localName)

Implements org.xml.sax.Attributes.getIndex.

Doc from org.xml.sax.Attributes.getIndex.

Look up the index of an attribute by Namespace name.

Annotations
@Override
getLengthback to summary
public final int getLength()

Implements org.xml.sax.Attributes.getLength.

Doc from org.xml.sax.Attributes.getLength.

Return the number of attributes in the list.

Once you know the number of attributes, you can iterate through the list.

Annotations
@Override
getLocalNameback to summary
public final String getLocalName(int index)

Implements org.xml.sax.Attributes.getLocalName.

Doc from org.xml.sax.Attributes.getLocalName.

Look up an attribute's local name by index.

Annotations
@Override
getQNameback to summary
public final String getQName(int index)

Implements org.xml.sax.Attributes.getQName.

Doc from org.xml.sax.Attributes.getQName.

Look up an attribute's XML qualified (prefixed) name by index.

Annotations
@Override
getToIndexback to summary
public final boolean getToIndex(int index)

Implements org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getToIndex.

Doc from org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes.getToIndex.

Return the whether the attribute value should be indexed or not.

Annotations
@Override
getTypeback to summary
public final String getType(int index)

Implements org.xml.sax.Attributes.getType.

Doc from org.xml.sax.Attributes.getType.

Look up an attribute's type by index.

The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case).

If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 Recommendation (clause 3.3.3, "Attribute-Value Normalization").

For an enumerated attribute that is not a notation, the parser will report the type as "NMTOKEN".

Annotations
@Override
getTypeback to summary
public final String getType(String qName)

Implements org.xml.sax.Attributes.getType.

Doc from org.xml.sax.Attributes.getType.

Look up an attribute's type by XML qualified (prefixed) name.

See getType(int) for a description of the possible types.

Annotations
@Override
getTypeback to summary
public final String getType(String uri, String localName)

Implements org.xml.sax.Attributes.getType.

Doc from org.xml.sax.Attributes.getType.

Look up an attribute's type by Namespace name.

See getType(int) for a description of the possible types.

Annotations
@Override
getURIback to summary
public final String getURI(int index)

Implements org.xml.sax.Attributes.getURI.

Doc from org.xml.sax.Attributes.getURI.

Look up an attribute's Namespace URI by index.

Annotations
@Override
getValueback to summary
public final String getValue(int index)

Implements org.xml.sax.Attributes.getValue.

Doc from org.xml.sax.Attributes.getValue.

Look up an attribute's value by index.

If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will be concatenated into a single string with each token separated by a single space.

Annotations
@Override
getValueback to summary
public final String getValue(String qName)

Implements org.xml.sax.Attributes.getValue.

Doc from org.xml.sax.Attributes.getValue.

Look up an attribute's value by XML qualified (prefixed) name.

See getValue(int) for a description of the possible values.

Annotations
@Override
getValueback to summary
public final String getValue(String uri, String localName)

Implements org.xml.sax.Attributes.getValue.

Doc from org.xml.sax.Attributes.getValue.

Look up an attribute's value by Namespace name.

See getValue(int) for a description of the possible values.

Annotations
@Override
replaceNullback to summary
private String replaceNull(String s)
replaceWithAttributeAlgorithmDataback to summary
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:int

The index of the attribute whose value is to be replaced

algorithmURI:String

The algorithm URI, or null if a built in algorithm

algorithmID:int

The algorithm ID.

algorithmData:Object

The algorithm data.

resizeback to summary
private void resize()
resizeNoCopyback to summary
private void resizeNoCopy()
setAttributesback to summary
public final void setAttributes(Attributes atts)

Copy an entire Attributes object.

Parameters
atts:Attributes

The attributes to copy.

setAttributesback to summary
public final void setAttributes(EncodingAlgorithmAttributes atts)

Copy an entire EncodingAlgorithmAttributes object.

Parameters
atts:EncodingAlgorithmAttributes

The attributes to copy.