src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * reserved comment block
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT REMOVE OR ALTER!
     3  * @LastModified: Oct 2017
     4  */
     4  */
     5 /*
     5 /*
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  * contributor license agreements.  See the NOTICE file distributed with
     7  * contributor license agreements.  See the NOTICE file distributed with
     8  * this work for additional information regarding copyright ownership.
     8  * this work for additional information regarding copyright ownership.
    19  * limitations under the License.
    19  * limitations under the License.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.xerces.internal.impl.xs.util;
    22 package com.sun.org.apache.xerces.internal.impl.xs.util;
    23 
    23 
       
    24 import com.sun.org.apache.xerces.internal.xs.LSInputList;
    24 import java.lang.reflect.Array;
    25 import java.lang.reflect.Array;
    25 import java.util.AbstractList;
    26 import java.util.AbstractList;
    26 
       
    27 import com.sun.org.apache.xerces.internal.xs.LSInputList;
       
    28 import org.w3c.dom.ls.LSInput;
    27 import org.w3c.dom.ls.LSInput;
    29 
    28 
    30 /**
    29 /**
    31  * Contains a list of LSInputs.
    30  * Contains a list of LSInputs.
    32  *
    31  *
    33  * @xerces.internal
    32  * @xerces.internal
    34  *
    33  *
    35  * @author Michael Glavassevich, IBM
    34  * @author Michael Glavassevich, IBM
    36  *
    35  *
    37  */
    36  */
    38 public final class LSInputListImpl extends AbstractList implements LSInputList {
    37 @SuppressWarnings("unchecked") // method <T>toArray(T[])
       
    38 public final class LSInputListImpl extends AbstractList<LSInput> implements LSInputList {
    39 
    39 
    40     /**
    40     /**
    41      * An immutable empty list.
    41      * An immutable empty list.
    42      */
    42      */
    43     public static final LSInputListImpl EMPTY_LIST = new LSInputListImpl(new LSInput[0], 0);
    43     public static final LSInputListImpl EMPTY_LIST = new LSInputListImpl(new LSInput[0], 0);
    84 
    84 
    85     /*
    85     /*
    86      * List methods
    86      * List methods
    87      */
    87      */
    88 
    88 
    89     public Object get(int index) {
    89     public LSInput get(int index) {
    90         if (index >= 0 && index < fLength) {
    90         if (index >= 0 && index < fLength) {
    91             return fArray[index];
    91             return fArray[index];
    92         }
    92         }
    93         throw new IndexOutOfBoundsException("Index: " + index);
    93         throw new IndexOutOfBoundsException("Index: " + index);
    94     }
    94     }
   103         return a;
   103         return a;
   104     }
   104     }
   105 
   105 
   106     public Object[] toArray(Object[] a) {
   106     public Object[] toArray(Object[] a) {
   107         if (a.length < fLength) {
   107         if (a.length < fLength) {
   108             Class arrayClass = a.getClass();
   108             Class<?> arrayClass = a.getClass();
   109             Class componentType = arrayClass.getComponentType();
   109             Class<?> componentType = arrayClass.getComponentType();
   110             a = (Object[]) Array.newInstance(componentType, fLength);
   110             a = (Object[]) Array.newInstance(componentType, fLength);
   111         }
   111         }
   112         toArray0(a);
   112         toArray0(a);
   113         if (a.length > fLength) {
   113         if (a.length > fLength) {
   114             a[fLength] = null;
   114             a[fLength] = null;