/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
* THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
*/
/**
* Default implementation of the {@link EncodingAlgorithmAttributes} interface.
*
* <p>This class provides a default implementation of the SAX2
* {@link EncodingAlgorithmAttributes} interface, with the
* addition of manipulators so that the list can be modified or
* reused.</p>
*
* <p>There are two typical uses of this class:</p>
*
* <ol>
* <li>to take a persistent snapshot of an EncodingAlgorithmAttributes object
* in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or</li>
* <li>to construct or modify an EncodingAlgorithmAttributes object in a SAX2
* driver or filter.</li>
* </ol>
*/
private int _length;
private int[] _algorithmIds;
private boolean[] _toIndex;
/**
* Construct a new, empty EncodingAlgorithmAttributesImpl object.
*/
public EncodingAlgorithmAttributesImpl() {
}
/**
* Copy an existing Attributes object.
*
* <p>This constructor is especially useful inside a
* {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
*
* @param attributes The existing Attributes object.
*/
this(null, attributes);
}
/**
* Use registered encoding algorithms and copy an existing Attributes object.
*
* <p>This constructor is especially useful inside a
* {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
*
* @param registeredEncodingAlgorithms
* The registeredEncodingAlgorithms encoding algorithms.
* @param attributes The existing Attributes object.
*/
_algorithmIds = new int[DEFAULT_CAPACITY];
_toIndex = new boolean[DEFAULT_CAPACITY];
if (attributes != null) {
if (attributes instanceof EncodingAlgorithmAttributes) {
} else {
}
}
}
/**
* Clear the attribute list for reuse.
*
*/
public final void clear() {
for (int i = 0; i < _length; i++) {
_algorithmData[i] = null;
}
_length = 0;
}
/**
* Add an attribute to the end of the list.
*
* <p>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.</p>
*
* @param URI The Namespace URI, or the empty string if
* none is available or Namespace processing is not
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
* @param qName The qualified (prefixed) name, or the empty string
* if qualified names are not available.
* @param type The attribute type as a string.
* @param value The attribute value.
*/
resize();
}
_length++;
}
/**
* Add an attribute to the end of the list.
*
* <p>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.</p>
*
* @param URI The Namespace URI, or the empty string if
* none is available or Namespace processing is not
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
* @param qName The qualified (prefixed) name, or the empty string
* if qualified names are not available.
* @param type The attribute type as a string.
* @param value The attribute value.
* @param index True if attribute should be indexed.
* @param alphabet The alphabet associated with the attribute value,
* may be null if there is no associated alphabet.
*/
resize();
}
_length++;
}
/**
* Add an attribute with built in algorithm data to the end of the list.
*
* <p>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.</p>
*
* @param URI The Namespace URI, or the empty string if
* none is available or Namespace processing is not
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
* @param qName The qualified (prefixed) name, or the empty string
* if qualified names are not available.
* @param builtInAlgorithmID The built in algorithm ID.
* @param algorithmData The built in algorithm data.
*/
resize();
}
_data[i++] = "CDATA";
_data[i++] = "";
_length++;
}
/**
* Add an attribute with algorithm data to the end of the list.
*
* <p>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.</p>
*
* @param URI The Namespace URI, or the empty string if
* none is available or Namespace processing is not
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
* @param qName The qualified (prefixed) name, or the empty string
* if qualified names are not available.
* @param algorithmURI The algorithm URI, or null if a built in algorithm
* @param algorithmID The algorithm ID.
* @param algorithmData The algorithm data.
*/
resize();
}
_data[i++] = "CDATA";
_data[i++] = "";
_data[i++] = algorithmURI;
_length++;
}
/**
* Replace an attribute value with algorithm data.
*
* <p>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.</p>
*
* @param index The index of the attribute whose value is to be replaced
* @param algorithmURI The algorithm URI, or null if a built in algorithm
* @param algorithmID The algorithm ID.
* @param algorithmData The algorithm data.
*/
}
/**
* Copy an entire Attributes object.
*
* @param atts The attributes to copy.
*/
if (_length > 0) {
resizeNoCopy();
}
int index = 0;
for (int i = 0; i < _length; i++) {
index++;
_toIndex[i] = false;
_alphabets[i] = null;
}
}
}
/**
* Copy an entire EncodingAlgorithmAttributes object.
*
* @param atts The attributes to copy.
*/
if (_length > 0) {
resizeNoCopy();
}
int index = 0;
for (int i = 0; i < _length; i++) {
_toIndex[i] = false;
_alphabets[i] = null;
}
}
}
// org.xml.sax.Attributes
public final int getLength() {
return _length;
}
} else {
return null;
}
}
} else {
return null;
}
}
} else {
return null;
}
}
} else {
return null;
}
}
} else {
return null;
}
return null;
}
try {
} catch (IOException e) {
return null;
} catch (FastInfosetException e) {
return null;
}
}
return index;
}
}
return -1;
}
if (index >= 0) {
} else {
return null;
}
}
if (index >= 0) {
} else {
return null;
}
}
return index;
}
}
return -1;
}
if (index >= 0) {
} else {
return null;
}
}
if (index >= 0) {
} else {
return null;
}
}
// EncodingAlgorithmAttributes
} else {
return null;
}
}
return _algorithmIds[index];
} else {
return -1;
}
}
return _algorithmData[index];
} else {
return null;
}
}
// ExtendedAttributes
return _alphabets[index];
} else {
return null;
}
}
} else {
return false;
}
}
// -----
return (s != null) ? s : "";
}
private final void resizeNoCopy() {
_algorithmIds = new int[newLength];
}
private final void resize() {
int[] algorithmIds = new int[newLength];
}
throw new EncodingAlgorithmException(
throw new EncodingAlgorithmException(
}
throw new EncodingAlgorithmException(
}
} else {
// Reserved built-in algorithms for future use
// TODO should use sax property to decide if event will be
// reported, allows for support through handler if required.
throw new EncodingAlgorithmException(
}
return sb;
}
}