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