001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: DOMStringListImpl.java 1225426 2011-12-29 04:13:08Z mrglavas $
020     */
021    package org.apache.xml.serializer.dom3;
022    
023    import java.util.Vector;
024    
025    //import org.apache.xerces.dom3.DOMStringList;
026    import org.w3c.dom.DOMStringList;
027    
028    /**
029     * This class implemets the DOM Level 3 Core interface DOMStringList.
030     * 
031     * @xsl.usage internal
032     */
033    final class DOMStringListImpl implements DOMStringList {
034        
035        //A collection of DOMString values
036        private Vector fStrings;
037        
038        /** 
039         * Construct an empty list of DOMStringListImpl
040         */ 
041        DOMStringListImpl() {
042            fStrings = new Vector();    
043        }
044        
045        /** 
046         * Construct an empty list of DOMStringListImpl
047         */ 
048        DOMStringListImpl(Vector params) {
049            fStrings = params;    
050        }
051        
052        /** 
053         * Construct an empty list of DOMStringListImpl
054         */ 
055        DOMStringListImpl(String[] params ) {
056            fStrings = new Vector();
057            if (params != null) {
058                for (int i=0; i < params.length; i++) {
059                    fStrings.add(params[i]);    
060                }
061            }
062        }
063        
064        /**
065         * @see org.apache.xerces.dom3.DOMStringList#item(int)
066         */
067        public String item(int index) {
068            try {
069                return (String) fStrings.elementAt(index);
070            } catch (ArrayIndexOutOfBoundsException e) {
071                return null;
072            }
073        }
074        
075        /**
076         * @see org.apache.xerces.dom3.DOMStringList#getLength()
077         */
078        public int getLength() {
079            return fStrings.size();
080        }
081        
082        /**
083         * @see org.apache.xerces.dom3.DOMStringList#contains(String)
084         */
085        public boolean contains(String param) {
086            return fStrings.contains(param) ;
087        }
088        
089        /**
090         * DOM Internal:
091         * Add a <code>DOMString</code> to the list.
092         * 
093         * @param domString A string to add to the list
094         */
095        public void add(String param) {
096            fStrings.add(param);
097        }
098        
099    }