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: Set.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  
23  /***
24   * This class implements the Collection interface to hide its backing.
25   * It is a unordered set of {@link Value}. A set can appear on 
26   * the right hand side of an {@link AttributeStatement}.
27   * @author pramirez
28   * @version $Revision: 2606 $
29   * 
30   */
31  public class Set implements Collection, Value {
32      private List values;
33      
34      public Set() {
35          values = new ArrayList();
36      }
37      
38      public Set(Collection values) {
39          values = new ArrayList(values);
40      }
41  
42      /* (non-Javadoc)
43       * @see java.util.Collection#size()
44       */
45      public int size() {
46          return values.size();
47      }
48  
49      /* (non-Javadoc)
50       * @see java.util.Collection#isEmpty()
51       */
52      public boolean isEmpty() {
53          return values.isEmpty();
54      }
55  
56      /* (non-Javadoc)
57       * @see java.util.Collection#contains(java.lang.Object)
58       */
59      public boolean contains(Object object) {
60          return values.contains(object);
61      }
62  
63      /* (non-Javadoc)
64       * @see java.util.Collection#iterator()
65       */
66      public Iterator iterator() {
67          return values.iterator();
68      }
69  
70      /* (non-Javadoc)
71       * @see java.util.Collection#toArray()
72       */
73      public Object[] toArray() {
74          return values.toArray();
75      }
76  
77      /* (non-Javadoc)
78       * @see java.util.Collection#toArray(java.lang.Object[])
79       */
80      public Object[] toArray(Object[] objects) {
81          return values.toArray(objects);
82      }
83  
84      /* (non-Javadoc)
85       * @see java.util.Collection#add(java.lang.Object)
86       */
87      public boolean add(Object object) {
88          return values.add(object);
89      }
90  
91      /* (non-Javadoc)
92       * @see java.util.Collection#remove(java.lang.Object)
93       */
94      public boolean remove(Object object) {
95          return values.remove(object);
96      }
97  
98      /* (non-Javadoc)
99       * @see java.util.Collection#containsAll(java.util.Collection)
100      */
101     public boolean containsAll(Collection values) {
102         return this.values.containsAll(values);
103     }
104 
105     /* (non-Javadoc)
106      * @see java.util.Collection#addAll(java.util.Collection)
107      */
108     public boolean addAll(Collection values) {
109         return this.values.addAll(values);
110     }
111 
112     /* (non-Javadoc)
113      * @see java.util.Collection#removeAll(java.util.Collection)
114      */
115     public boolean removeAll(Collection values) {
116         return this.values.removeAll(values);
117     }
118 
119     /* (non-Javadoc)
120      * @see java.util.Collection#retainAll(java.util.Collection)
121      */
122     public boolean retainAll(Collection values) {
123         return this.values.retainAll(values);
124     }
125 
126     /* (non-Javadoc)
127      * @see java.util.Collection#clear()
128      */
129     public void clear() {
130         values.clear();
131     }
132 
133 }