View Javadoc

1   // Copyright 2006-2007, by the California Institute of Technology.
2   // ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
3   // Any commercial use must be negotiated with the Office of Technology Transfer
4   // at the California Institute of Technology.
5   //
6   // This software is subject to U. S. export control laws and regulations
7   // (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
8   // is subject to U.S. export control laws and regulations, the recipient has
9   // the responsibility to obtain export licenses or other export authority as
10  // may be required before exporting such information to foreign countries or
11  // providing access to foreign nationals.
12  //
13  // $Id: Sequence.java 2606 2007-04-18 19:35:09Z pramirez $ 
14  //
15  
16  package gov.nasa.pds.tools.label;
17  
18  import java.util.Collection;
19  import java.util.Iterator;
20  import java.util.List;
21  import java.util.ArrayList;
22  import java.util.ListIterator;
23  
24  /***
25   * This class implements the List interface to hide its backing.
26   * It is a ordered set of {@link Value}. A sequence can appear on 
27   * the right hand side of an {@link AttributeStatement}.
28   * @author pramirez
29   * @version $Revision: 2606 $
30   * 
31   */
32  public class Sequence implements List, Value {
33      private List values;
34  
35      /***
36       * Constructs an empty sequence of values.
37       */
38      public Sequence() {
39          values = new ArrayList();
40      }
41      
42      /***
43       * Constructs a sequence with the ordered value
44       * @param values to load into sequence
45       */
46      public Sequence(List values) {
47          this.values = new ArrayList(values);
48      }
49  
50      /* (non-Javadoc)
51       * @see java.util.List#containsAll(java.util.Collection)
52       */
53      public boolean containsAll(Collection values) {
54          return this.values.containsAll(values);
55      }
56  
57      /* (non-Javadoc)
58       * @see java.util.List#addAll(java.util.Collection)
59       */
60      public boolean addAll(Collection values) {
61          return this.values.addAll(values);
62      }
63  
64      /* (non-Javadoc)
65       * @see java.util.List#addAll(int, java.util.Collection)
66       */
67      public boolean addAll(int index, Collection values) {
68          return this.values.addAll(index, values);
69      }
70  
71      /* (non-Javadoc)
72       * @see java.util.List#removeAll(java.util.Collection)
73       */
74      public boolean removeAll(Collection values) {
75          return this.values.removeAll(values);
76      }
77  
78      /* (non-Javadoc)
79       * @see java.util.List#retainAll(java.util.Collection)
80       */
81      public boolean retainAll(Collection values) {
82          return this.values.retainAll(values);
83      }
84  
85      /* (non-Javadoc)
86       * @see java.util.List#clear()
87       */
88      public void clear() {
89          values.clear();
90      }
91  
92      /* (non-Javadoc)
93       * @see java.util.List#get(int)
94       */
95      public Value getValue(int index) {
96          return (Value) values.get(index);
97      }
98  
99      /* (non-Javadoc)
100      * @see java.util.List#set(int, java.lang.Object)
101      */
102     public Value set(int index, Value value) {
103         return (Value) values.set(index, value);
104     }
105 
106     /* (non-Javadoc)
107      * @see java.util.List#remove(int)
108      */
109     public Scalar removeScalar(int index) {
110         return (Scalar) values.remove(index);
111     }
112 
113     /* (non-Javadoc)
114      * @see java.util.List#listIterator()
115      */
116     public ListIterator listIterator() {
117         return values.listIterator();
118     }
119 
120     /* (non-Javadoc)
121      * @see java.util.List#listIterator(int)
122      */
123     public ListIterator listIterator(int index) {
124         return values.listIterator(index);
125     }
126 
127     /* (non-Javadoc)
128      * @see java.util.List#subList(int, int)
129      */
130     public List subList(int fromIndex, int toIndex) {
131         return values.subList(fromIndex, toIndex);
132     }
133 
134     /* (non-Javadoc)
135      * @see java.util.List#contains(java.lang.Object)
136      */
137     public boolean contains(Object object) {
138         return values.contains(object);
139     }
140 
141     /* (non-Javadoc)
142      * @see java.util.List#toArray(java.lang.Object[])
143      */
144     public Object[] toArray(Object[] objects) {
145         return values.toArray(objects);
146     }
147 
148     /* (non-Javadoc)
149      * @see java.util.List#add(java.lang.Object)
150      */
151     public boolean add(Object object) {
152         return values.add(object);
153     }
154 
155     /* (non-Javadoc)
156      * @see java.util.List#remove(java.lang.Object)
157      */
158     public boolean remove(Object object) {
159         return values.remove(object);
160     }
161 
162     /* (non-Javadoc)
163      * @see java.util.List#set(int, java.lang.Object)
164      */
165     public Object set(int index, Object object) {
166         return values.set(index, object);
167     }
168 
169     /* (non-Javadoc)
170      * @see java.util.List#add(int, java.lang.Object)
171      */
172     public void add(int index, Object object) {
173          values.add(index, object);
174     }
175 
176     /* (non-Javadoc)
177      * @see java.util.List#indexOf(java.lang.Object)
178      */
179     public int indexOf(Object object) {
180        return values.indexOf(object);
181     }
182 
183     /* (non-Javadoc)
184      * @see java.util.List#lastIndexOf(java.lang.Object)
185      */
186     public int lastIndexOf(Object object) {
187         return values.lastIndexOf(object);
188     }
189 
190     /* (non-Javadoc)
191      * @see java.util.List#toArray()
192      */
193     public Object[] toArray() {
194         return values.toArray();
195     }
196 
197     /* (non-Javadoc)
198      * @see java.util.List#get(int)
199      */
200     public Object get(int index) {
201         return values.get(index);
202     }
203 
204     /* (non-Javadoc)
205      * @see java.util.List#remove(int)
206      */
207     public Object remove(int index) {
208         return values.remove(index);
209     }
210 
211 
212     /* (non-Javadoc)
213      * @see java.util.List#size()
214      */
215     public int size() {
216         return values.size();
217     }
218 
219 
220     /* (non-Javadoc)
221      * @see java.util.List#isEmpty()
222      */
223     public boolean isEmpty() {
224         return values.isEmpty();
225     }
226 
227 
228     /* (non-Javadoc)
229      * @see java.util.List#iterator()
230      */
231     public Iterator iterator() {
232         return values.iterator();
233     }
234 }