* AttributesImpl} interface.</p>
*
* <p>This class provides a convenience implementation of the SAX
- * {@link org.xml.sax.AttributeList AttributeList} interface. This
- * implementation is useful both for SAX parser writers, who can use
- * it to provide attributes to the application, and for SAX application
- * writers, who can use it to create a persistent copy of an element's
+ * {@link org.xml.sax.AttributeList AttributeList} interface. This
+ * implementation is useful both for SAX parser writers, who can use
+ * it to provide attributes to the application, and for SAX application
+ * writers, who can use it to create a persistent copy of an element's
* attribute specifications:</p>
*
* <pre>
*
* <p>Please note that SAX parsers are not required to use this
* class to provide an implementation of AttributeList; it is
- * supplied only as an optional convenience. In particular,
+ * supplied only as an optional convenience. In particular,
* parser writers are encouraged to invent more efficient
* implementations.</p>
*
* that interface has been replaced by
* {@link org.xml.sax.Attributes Attributes},
* which is implemented in the
- * {@link org.xml.sax.helpers.AttributesImpl
+ * {@link org.xml.sax.helpers.AttributesImpl
* AttributesImpl} helper class.
* @since SAX 1.0
* @author David Megginson
* @version 2.0.1 (sax2r2)
* @see org.xml.sax.AttributeList
- * @see org.xml.sax.DocumentHandler#startElement
+ * @see org.xml.sax.DocumentHandler#startElement
*/
public class AttributeListImpl implements AttributeList
{
-
+
/**
* Create an empty attribute list.
*
public AttributeListImpl ()
{
}
-
-
+
+
/**
* Construct a persistent copy of an existing attribute list.
*
*/
public AttributeListImpl (AttributeList atts)
{
- setAttributeList(atts);
+ setAttributeList(atts);
}
-
-
-\f
+
+
+
////////////////////////////////////////////////////////////////////
// Methods specific to this class.
////////////////////////////////////////////////////////////////////
-
-
+
+
/**
* Set the attribute list, discarding previous contents.
*
*/
public void setAttributeList (AttributeList atts)
{
- int count = atts.getLength();
-
- clear();
-
- for (int i = 0; i < count; i++) {
- addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
- }
+ int count = atts.getLength();
+
+ clear();
+
+ for (int i = 0; i < count; i++) {
+ addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
+ }
}
-
-
+
+
/**
* Add an attribute to an attribute list.
*
*/
public void addAttribute (String name, String type, String value)
{
- names.addElement(name);
- types.addElement(type);
- values.addElement(value);
+ names.addElement(name);
+ types.addElement(type);
+ values.addElement(value);
}
-
-
+
+
/**
* Remove an attribute from the list.
*
*/
public void removeAttribute (String name)
{
- int i = names.indexOf(name);
-
- if (i >= 0) {
- names.removeElementAt(i);
- types.removeElementAt(i);
- values.removeElementAt(i);
- }
+ int i = names.indexOf(name);
+
+ if (i >= 0) {
+ names.removeElementAt(i);
+ types.removeElementAt(i);
+ values.removeElementAt(i);
+ }
}
-
-
+
+
/**
* Clear the attribute list.
*
*/
public void clear ()
{
- names.removeAllElements();
- types.removeAllElements();
- values.removeAllElements();
+ names.removeAllElements();
+ types.removeAllElements();
+ values.removeAllElements();
}
-
-
-\f
+
+
+
////////////////////////////////////////////////////////////////////
// Implementation of org.xml.sax.AttributeList
////////////////////////////////////////////////////////////////////
-
-
+
+
/**
* Return the number of attributes in the list.
*
*/
public int getLength ()
{
- return names.size();
+ return names.size();
}
-
-
+
+
/**
* Get the name of an attribute (by position).
*
*/
public String getName (int i)
{
- if (i < 0) {
- return null;
- }
- try {
- return (String)names.elementAt(i);
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
+ if (i < 0) {
+ return null;
+ }
+ try {
+ return (String)names.elementAt(i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ }
}
-
-
+
+
/**
* Get the type of an attribute (by position).
*
*/
public String getType (int i)
{
- if (i < 0) {
- return null;
- }
- try {
- return (String)types.elementAt(i);
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
+ if (i < 0) {
+ return null;
+ }
+ try {
+ return (String)types.elementAt(i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ }
}
-
-
+
+
/**
* Get the value of an attribute (by position).
*
*/
public String getValue (int i)
{
- if (i < 0) {
- return null;
- }
- try {
- return (String)values.elementAt(i);
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
+ if (i < 0) {
+ return null;
+ }
+ try {
+ return (String)values.elementAt(i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
+ }
}
-
-
+
+
/**
* Get the type of an attribute (by name).
*
*/
public String getType (String name)
{
- return getType(names.indexOf(name));
+ return getType(names.indexOf(name));
}
-
-
+
+
/**
* Get the value of an attribute (by name).
*
*/
public String getValue (String name)
{
- return getValue(names.indexOf(name));
+ return getValue(names.indexOf(name));
}
-
-
-\f
+
+
+
////////////////////////////////////////////////////////////////////
// Internal state.
////////////////////////////////////////////////////////////////////