DOMStringListImpl

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements. See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  *
  9.  * http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17.  
  18. package org.apache.xerces.dom;
  19.  
  20. import java.util.ArrayList;
  21. import java.util.Vector;
  22.  
  23. import org.w3c.dom.DOMStringList;
  24.  
  25. /**
  26.  * DOM Level 3
  27.  *
  28.  * This class implements the DOM Level 3 Core interface DOMStringList.
  29.  *
  30.  * @xerces.internal
  31.  *
  32.  * @author Neil Delima, IBM
  33.  */
  34. public class DOMStringListImpl implements DOMStringList {
  35.  
  36. // A collection of DOMString values
  37. private final ArrayList fStrings;
  38.  
  39. /**
  40.   * Construct an empty list of DOMStringListImpl
  41.   */
  42. public DOMStringListImpl() {
  43. fStrings = new ArrayList();
  44. }
  45.  
  46. /**
  47.   * Construct a DOMStringListImpl from an ArrayList
  48.   */
  49. public DOMStringListImpl(ArrayList params) {
  50. fStrings = params;
  51. }
  52.  
  53. /**
  54.   * Construct a DOMStringListImpl from a Vector
  55.   */
  56. public DOMStringListImpl(Vector params) {
  57. fStrings = new ArrayList(params);
  58. }
  59.  
  60. /**
  61.   * @see org.w3c.dom.DOMStringList#item(int)
  62.   */
  63. public String item(int index) {
  64. final int length = getLength();
  65. if (index >= 0 && index < length) {
  66. return (String) fStrings.get(index);
  67. }
  68. return null;
  69. }
  70.  
  71. /**
  72.   * @see org.w3c.dom.DOMStringList#getLength()
  73.   */
  74. public int getLength() {
  75. return fStrings.size();
  76. }
  77.  
  78. /**
  79.   * @see org.w3c.dom.DOMStringList#contains(String)
  80.   */
  81. public boolean contains(String param) {
  82. return fStrings.contains(param);
  83. }
  84.  
  85. /**
  86.   * DOM Internal:
  87.   * Add a <code>DOMString</code> to the list.
  88.   *
  89.   * @param param A string to add to the list
  90.   */
  91. public void add(String param) {
  92. fStrings.add(param);
  93. }
  94.  
  95. }
  96.  
Programming language: 
Java