src/java.xml/share/classes/org/xml/sax/helpers/AttributeListImpl.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 58247 3aef3bccfae3
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
    28 // No warranty; no copyright -- use this as you will.
    28 // No warranty; no copyright -- use this as you will.
    29 // $Id: AttributeListImpl.java,v 1.2 2004/11/03 22:53:08 jsuttor Exp $
    29 // $Id: AttributeListImpl.java,v 1.2 2004/11/03 22:53:08 jsuttor Exp $
    30 
    30 
    31 package org.xml.sax.helpers;
    31 package org.xml.sax.helpers;
    32 
    32 
       
    33 import java.util.ArrayList;
       
    34 import java.util.List;
    33 import org.xml.sax.AttributeList;
    35 import org.xml.sax.AttributeList;
    34 
       
    35 import java.util.Vector;
       
    36 
    36 
    37 
    37 
    38 /**
    38 /**
    39  * Default implementation for AttributeList.
    39  * Default implementation for AttributeList.
    40  *
    40  *
   161      * @see #removeAttribute
   161      * @see #removeAttribute
   162      * @see org.xml.sax.DocumentHandler#startElement
   162      * @see org.xml.sax.DocumentHandler#startElement
   163      */
   163      */
   164     public void addAttribute (String name, String type, String value)
   164     public void addAttribute (String name, String type, String value)
   165     {
   165     {
   166         names.addElement(name);
   166         names.add(name);
   167         types.addElement(type);
   167         types.add(type);
   168         values.addElement(value);
   168         values.add(value);
   169     }
   169     }
   170 
   170 
   171 
   171 
   172     /**
   172     /**
   173      * Remove an attribute from the list.
   173      * Remove an attribute from the list.
   186     public void removeAttribute (String name)
   186     public void removeAttribute (String name)
   187     {
   187     {
   188         int i = names.indexOf(name);
   188         int i = names.indexOf(name);
   189 
   189 
   190         if (i >= 0) {
   190         if (i >= 0) {
   191             names.removeElementAt(i);
   191             names.remove(i);
   192             types.removeElementAt(i);
   192             types.remove(i);
   193             values.removeElementAt(i);
   193             values.remove(i);
   194         }
   194         }
   195     }
   195     }
   196 
   196 
   197 
   197 
   198     /**
   198     /**
   205      *
   205      *
   206      * @see org.xml.sax.DocumentHandler#startElement
   206      * @see org.xml.sax.DocumentHandler#startElement
   207      */
   207      */
   208     public void clear ()
   208     public void clear ()
   209     {
   209     {
   210         names.removeAllElements();
   210         names.clear();
   211         types.removeAllElements();
   211         types.clear();
   212         values.removeAllElements();
   212         values.clear();
   213     }
   213     }
   214 
   214 
   215 
   215 
   216 
   216 
   217     ////////////////////////////////////////////////////////////////////
   217     ////////////////////////////////////////////////////////////////////
   243     {
   243     {
   244         if (i < 0) {
   244         if (i < 0) {
   245             return null;
   245             return null;
   246         }
   246         }
   247         try {
   247         try {
   248             return (String)names.elementAt(i);
   248             return names.get(i);
   249         } catch (ArrayIndexOutOfBoundsException e) {
   249         } catch (IndexOutOfBoundsException e) {
   250             return null;
   250             return null;
   251         }
   251         }
   252     }
   252     }
   253 
   253 
   254 
   254 
   266     {
   266     {
   267         if (i < 0) {
   267         if (i < 0) {
   268             return null;
   268             return null;
   269         }
   269         }
   270         try {
   270         try {
   271             return (String)types.elementAt(i);
   271             return types.get(i);
   272         } catch (ArrayIndexOutOfBoundsException e) {
   272         } catch (IndexOutOfBoundsException e) {
   273             return null;
   273             return null;
   274         }
   274         }
   275     }
   275     }
   276 
   276 
   277 
   277 
   287     {
   287     {
   288         if (i < 0) {
   288         if (i < 0) {
   289             return null;
   289             return null;
   290         }
   290         }
   291         try {
   291         try {
   292             return (String)values.elementAt(i);
   292             return values.get(i);
   293         } catch (ArrayIndexOutOfBoundsException e) {
   293         } catch (IndexOutOfBoundsException e) {
   294             return null;
   294             return null;
   295         }
   295         }
   296     }
   296     }
   297 
   297 
   298 
   298 
   326 
   326 
   327     ////////////////////////////////////////////////////////////////////
   327     ////////////////////////////////////////////////////////////////////
   328     // Internal state.
   328     // Internal state.
   329     ////////////////////////////////////////////////////////////////////
   329     ////////////////////////////////////////////////////////////////////
   330 
   330 
   331     Vector names = new Vector();
   331     List<String> names = new ArrayList<>();
   332     Vector types = new Vector();
   332     List<String> types = new ArrayList<>();
   333     Vector values = new Vector();
   333     List<String> values = new ArrayList<>();
   334 
   334 
   335 }
   335 }
   336 
   336 
   337 // end of AttributeListImpl.java
   337 // end of AttributeListImpl.java