48 /* *** TabularData specific information methods *** */ |
48 /* *** TabularData specific information methods *** */ |
49 |
49 |
50 |
50 |
51 /** |
51 /** |
52 * Returns the <i>tabular type</i> describing this |
52 * Returns the <i>tabular type</i> describing this |
53 * <tt>TabularData</tt> instance. |
53 * {@code TabularData} instance. |
54 * |
54 * |
55 * @return the tabular type. |
55 * @return the tabular type. |
56 */ |
56 */ |
57 public TabularType getTabularType(); |
57 public TabularType getTabularType(); |
58 |
58 |
59 |
59 |
60 /** |
60 /** |
61 * Calculates the index that would be used in this <tt>TabularData</tt> instance to refer to the specified |
61 * Calculates the index that would be used in this {@code TabularData} instance to refer to the specified |
62 * composite data <var>value</var> parameter if it were added to this instance. |
62 * composite data <var>value</var> parameter if it were added to this instance. |
63 * This method checks for the type validity of the specified <var>value</var>, |
63 * This method checks for the type validity of the specified <var>value</var>, |
64 * but does not check if the calculated index is already used to refer to a value in this <tt>TabularData</tt> instance. |
64 * but does not check if the calculated index is already used to refer to a value in this {@code TabularData} instance. |
65 * |
65 * |
66 * @param value the composite data value whose index in this |
66 * @param value the composite data value whose index in this |
67 * <tt>TabularData</tt> instance is to be calculated; |
67 * {@code TabularData} instance is to be calculated; |
68 * must be of the same composite type as this instance's row type; |
68 * must be of the same composite type as this instance's row type; |
69 * must not be null. |
69 * must not be null. |
70 * |
70 * |
71 * @return the index that the specified <var>value</var> would have in this <tt>TabularData</tt> instance. |
71 * @return the index that the specified <var>value</var> would have in this {@code TabularData} instance. |
72 * |
72 * |
73 * @throws NullPointerException if <var>value</var> is <tt>null</tt> |
73 * @throws NullPointerException if <var>value</var> is {@code null} |
74 * |
74 * |
75 * @throws InvalidOpenTypeException if <var>value</var> does not conform to this <tt>TabularData</tt> instance's |
75 * @throws InvalidOpenTypeException if <var>value</var> does not conform to this {@code TabularData} instance's |
76 * row type definition. |
76 * row type definition. |
77 */ |
77 */ |
78 public Object[] calculateIndex(CompositeData value) ; |
78 public Object[] calculateIndex(CompositeData value) ; |
79 |
79 |
80 |
80 |
81 |
81 |
82 |
82 |
83 /* *** Content information query methods *** */ |
83 /* *** Content information query methods *** */ |
84 |
84 |
85 /** |
85 /** |
86 * Returns the number of <tt>CompositeData</tt> values (ie the |
86 * Returns the number of {@code CompositeData} values (ie the |
87 * number of rows) contained in this <tt>TabularData</tt> |
87 * number of rows) contained in this {@code TabularData} |
88 * instance. |
88 * instance. |
89 * |
89 * |
90 * @return the number of values contained. |
90 * @return the number of values contained. |
91 */ |
91 */ |
92 public int size() ; |
92 public int size() ; |
93 |
93 |
94 /** |
94 /** |
95 * Returns <tt>true</tt> if the number of <tt>CompositeData</tt> |
95 * Returns {@code true} if the number of {@code CompositeData} |
96 * values (ie the number of rows) contained in this |
96 * values (ie the number of rows) contained in this |
97 * <tt>TabularData</tt> instance is zero. |
97 * {@code TabularData} instance is zero. |
98 * |
98 * |
99 * @return true if this <tt>TabularData</tt> is empty. |
99 * @return true if this {@code TabularData} is empty. |
100 */ |
100 */ |
101 public boolean isEmpty() ; |
101 public boolean isEmpty() ; |
102 |
102 |
103 /** |
103 /** |
104 * Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains a <tt>CompositeData</tt> value |
104 * Returns {@code true} if and only if this {@code TabularData} instance contains a {@code CompositeData} value |
105 * (ie a row) whose index is the specified <var>key</var>. If <var>key</var> is <tt>null</tt> or does not conform to |
105 * (ie a row) whose index is the specified <var>key</var>. If <var>key</var> is {@code null} or does not conform to |
106 * this <tt>TabularData</tt> instance's <tt>TabularType</tt> definition, this method simply returns <tt>false</tt>. |
106 * this {@code TabularData} instance's {@code TabularType} definition, this method simply returns {@code false}. |
107 * |
107 * |
108 * @param key the index value whose presence in this <tt>TabularData</tt> instance is to be tested. |
108 * @param key the index value whose presence in this {@code TabularData} instance is to be tested. |
109 * |
109 * |
110 * @return <tt>true</tt> if this <tt>TabularData</tt> indexes a row value with the specified key. |
110 * @return {@code true} if this {@code TabularData} indexes a row value with the specified key. |
111 */ |
111 */ |
112 public boolean containsKey(Object[] key) ; |
112 public boolean containsKey(Object[] key) ; |
113 |
113 |
114 /** |
114 /** |
115 * Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains the specified |
115 * Returns {@code true} if and only if this {@code TabularData} instance contains the specified |
116 * <tt>CompositeData</tt> value. If <var>value</var> is <tt>null</tt> or does not conform to |
116 * {@code CompositeData} value. If <var>value</var> is {@code null} or does not conform to |
117 * this <tt>TabularData</tt> instance's row type definition, this method simply returns <tt>false</tt>. |
117 * this {@code TabularData} instance's row type definition, this method simply returns {@code false}. |
118 * |
118 * |
119 * @param value the row value whose presence in this <tt>TabularData</tt> instance is to be tested. |
119 * @param value the row value whose presence in this {@code TabularData} instance is to be tested. |
120 * |
120 * |
121 * @return <tt>true</tt> if this <tt>TabularData</tt> instance contains the specified row value. |
121 * @return {@code true} if this {@code TabularData} instance contains the specified row value. |
122 */ |
122 */ |
123 public boolean containsValue(CompositeData value) ; |
123 public boolean containsValue(CompositeData value) ; |
124 |
124 |
125 /** |
125 /** |
126 * Returns the <tt>CompositeData</tt> value whose index is |
126 * Returns the {@code CompositeData} value whose index is |
127 * <var>key</var>, or <tt>null</tt> if there is no value mapping |
127 * <var>key</var>, or {@code null} if there is no value mapping |
128 * to <var>key</var>, in this <tt>TabularData</tt> instance. |
128 * to <var>key</var>, in this {@code TabularData} instance. |
129 * |
129 * |
130 * @param key the key of the row to return. |
130 * @param key the key of the row to return. |
131 * |
131 * |
132 * @return the value corresponding to <var>key</var>. |
132 * @return the value corresponding to <var>key</var>. |
133 * |
133 * |
134 * @throws NullPointerException if the <var>key</var> is |
134 * @throws NullPointerException if the <var>key</var> is |
135 * <tt>null</tt> |
135 * {@code null} |
136 * @throws InvalidKeyException if the <var>key</var> does not |
136 * @throws InvalidKeyException if the <var>key</var> does not |
137 * conform to this <tt>TabularData</tt> instance's * |
137 * conform to this {@code TabularData} instance's * |
138 * <tt>TabularType</tt> definition |
138 * {@code TabularType} definition |
139 */ |
139 */ |
140 public CompositeData get(Object[] key) ; |
140 public CompositeData get(Object[] key) ; |
141 |
141 |
142 |
142 |
143 |
143 |
144 |
144 |
145 /* *** Content modification operations (one element at a time) *** */ |
145 /* *** Content modification operations (one element at a time) *** */ |
146 |
146 |
147 |
147 |
148 /** |
148 /** |
149 * Adds <var>value</var> to this <tt>TabularData</tt> instance. |
149 * Adds <var>value</var> to this {@code TabularData} instance. |
150 * The composite type of <var>value</var> must be the same as this |
150 * The composite type of <var>value</var> must be the same as this |
151 * instance's row type (ie the composite type returned by |
151 * instance's row type (ie the composite type returned by |
152 * <tt>this.getTabularType().{@link TabularType#getRowType |
152 * <code>this.getTabularType().{@link TabularType#getRowType |
153 * getRowType()}</tt>), and there must not already be an existing |
153 * getRowType()}</code>), and there must not already be an existing |
154 * value in this <tt>TabularData</tt> instance whose index is the |
154 * value in this {@code TabularData} instance whose index is the |
155 * same as the one calculated for the <var>value</var> to be |
155 * same as the one calculated for the <var>value</var> to be |
156 * added. The index for <var>value</var> is calculated according |
156 * added. The index for <var>value</var> is calculated according |
157 * to this <tt>TabularData</tt> instance's <tt>TabularType</tt> |
157 * to this {@code TabularData} instance's {@code TabularType} |
158 * definition (see <tt>TabularType.{@link |
158 * definition (see <code>TabularType.{@link |
159 * TabularType#getIndexNames getIndexNames()}</tt>). |
159 * TabularType#getIndexNames getIndexNames()}</code>). |
160 * |
160 * |
161 * @param value the composite data value to be added as a new row to this <tt>TabularData</tt> instance; |
161 * @param value the composite data value to be added as a new row to this {@code TabularData} instance; |
162 * must be of the same composite type as this instance's row type; |
162 * must be of the same composite type as this instance's row type; |
163 * must not be null. |
163 * must not be null. |
164 * |
164 * |
165 * @throws NullPointerException if <var>value</var> is <tt>null</tt> |
165 * @throws NullPointerException if <var>value</var> is {@code null} |
166 * @throws InvalidOpenTypeException if <var>value</var> does not conform to this <tt>TabularData</tt> instance's |
166 * @throws InvalidOpenTypeException if <var>value</var> does not conform to this {@code TabularData} instance's |
167 * row type definition. |
167 * row type definition. |
168 * @throws KeyAlreadyExistsException if the index for <var>value</var>, calculated according to |
168 * @throws KeyAlreadyExistsException if the index for <var>value</var>, calculated according to |
169 * this <tt>TabularData</tt> instance's <tt>TabularType</tt> definition |
169 * this {@code TabularData} instance's {@code TabularType} definition |
170 * already maps to an existing value in the underlying HashMap. |
170 * already maps to an existing value in the underlying HashMap. |
171 */ |
171 */ |
172 public void put(CompositeData value) ; |
172 public void put(CompositeData value) ; |
173 |
173 |
174 /** |
174 /** |
175 * Removes the <tt>CompositeData</tt> value whose index is <var>key</var> from this <tt>TabularData</tt> instance, |
175 * Removes the {@code CompositeData} value whose index is <var>key</var> from this {@code TabularData} instance, |
176 * and returns the removed value, or returns <tt>null</tt> if there is no value whose index is <var>key</var>. |
176 * and returns the removed value, or returns {@code null} if there is no value whose index is <var>key</var>. |
177 * |
177 * |
178 * @param key the index of the value to get in this <tt>TabularData</tt> instance; |
178 * @param key the index of the value to get in this {@code TabularData} instance; |
179 * must be valid with this <tt>TabularData</tt> instance's row type definition; |
179 * must be valid with this {@code TabularData} instance's row type definition; |
180 * must not be null. |
180 * must not be null. |
181 * |
181 * |
182 * @return previous value associated with specified key, or <tt>null</tt> |
182 * @return previous value associated with specified key, or {@code null} |
183 * if there was no mapping for key. |
183 * if there was no mapping for key. |
184 * |
184 * |
185 * @throws NullPointerException if the <var>key</var> is <tt>null</tt> |
185 * @throws NullPointerException if the <var>key</var> is {@code null} |
186 * @throws InvalidKeyException if the <var>key</var> does not conform to this <tt>TabularData</tt> instance's |
186 * @throws InvalidKeyException if the <var>key</var> does not conform to this {@code TabularData} instance's |
187 * <tt>TabularType</tt> definition |
187 * {@code TabularType} definition |
188 */ |
188 */ |
189 public CompositeData remove(Object[] key) ; |
189 public CompositeData remove(Object[] key) ; |
190 |
190 |
191 |
191 |
192 |
192 |
193 |
193 |
194 /* *** Content modification bulk operations *** */ |
194 /* *** Content modification bulk operations *** */ |
195 |
195 |
196 |
196 |
197 /** |
197 /** |
198 * Add all the elements in <var>values</var> to this <tt>TabularData</tt> instance. |
198 * Add all the elements in <var>values</var> to this {@code TabularData} instance. |
199 * If any element in <var>values</var> does not satisfy the constraints defined in {@link #put(CompositeData) <tt>put</tt>}, |
199 * If any element in <var>values</var> does not satisfy the constraints defined in {@link #put(CompositeData) put}, |
200 * or if any two elements in <var>values</var> have the same index calculated according to this <tt>TabularData</tt> |
200 * or if any two elements in <var>values</var> have the same index calculated according to this {@code TabularData} |
201 * instance's <tt>TabularType</tt> definition, then an exception describing the failure is thrown |
201 * instance's {@code TabularType} definition, then an exception describing the failure is thrown |
202 * and no element of <var>values</var> is added, thus leaving this <tt>TabularData</tt> instance unchanged. |
202 * and no element of <var>values</var> is added, thus leaving this {@code TabularData} instance unchanged. |
203 * |
203 * |
204 * @param values the array of composite data values to be added as new rows to this <tt>TabularData</tt> instance; |
204 * @param values the array of composite data values to be added as new rows to this {@code TabularData} instance; |
205 * if <var>values</var> is <tt>null</tt> or empty, this method returns without doing anything. |
205 * if <var>values</var> is {@code null} or empty, this method returns without doing anything. |
206 * |
206 * |
207 * @throws NullPointerException if an element of <var>values</var> is <tt>null</tt> |
207 * @throws NullPointerException if an element of <var>values</var> is {@code null} |
208 * @throws InvalidOpenTypeException if an element of <var>values</var> does not conform to |
208 * @throws InvalidOpenTypeException if an element of <var>values</var> does not conform to |
209 * this <tt>TabularData</tt> instance's row type definition |
209 * this {@code TabularData} instance's row type definition |
210 * @throws KeyAlreadyExistsException if the index for an element of <var>values</var>, calculated according to |
210 * @throws KeyAlreadyExistsException if the index for an element of <var>values</var>, calculated according to |
211 * this <tt>TabularData</tt> instance's <tt>TabularType</tt> definition |
211 * this {@code TabularData} instance's {@code TabularType} definition |
212 * already maps to an existing value in this instance, |
212 * already maps to an existing value in this instance, |
213 * or two elements of <var>values</var> have the same index. |
213 * or two elements of <var>values</var> have the same index. |
214 */ |
214 */ |
215 public void putAll(CompositeData[] values) ; |
215 public void putAll(CompositeData[] values) ; |
216 |
216 |
217 /** |
217 /** |
218 * Removes all <tt>CompositeData</tt> values (ie rows) from this <tt>TabularData</tt> instance. |
218 * Removes all {@code CompositeData} values (ie rows) from this {@code TabularData} instance. |
219 */ |
219 */ |
220 public void clear(); |
220 public void clear(); |
221 |
221 |
222 |
222 |
223 |
223 |
255 |
255 |
256 /* *** Commodity methods from java.lang.Object *** */ |
256 /* *** Commodity methods from java.lang.Object *** */ |
257 |
257 |
258 |
258 |
259 /** |
259 /** |
260 * Compares the specified <var>obj</var> parameter with this <code>TabularData</code> instance for equality. |
260 * Compares the specified <var>obj</var> parameter with this {@code TabularData} instance for equality. |
261 * <p> |
261 * <p> |
262 * Returns <tt>true</tt> if and only if all of the following statements are true: |
262 * Returns {@code true} if and only if all of the following statements are true: |
263 * <ul> |
263 * <ul> |
264 * <li><var>obj</var> is non null,</li> |
264 * <li><var>obj</var> is non null,</li> |
265 * <li><var>obj</var> also implements the <code>TabularData</code> interface,</li> |
265 * <li><var>obj</var> also implements the {@code TabularData} interface,</li> |
266 * <li>their row types are equal</li> |
266 * <li>their row types are equal</li> |
267 * <li>their contents (ie index to value mappings) are equal</li> |
267 * <li>their contents (ie index to value mappings) are equal</li> |
268 * </ul> |
268 * </ul> |
269 * This ensures that this <tt>equals</tt> method works properly for <var>obj</var> parameters which are |
269 * This ensures that this {@code equals} method works properly for <var>obj</var> parameters which are |
270 * different implementations of the <code>TabularData</code> interface. |
270 * different implementations of the {@code TabularData} interface. |
271 * <br> |
271 * <br> |
272 * @param obj the object to be compared for equality with this <code>TabularData</code> instance; |
272 * @param obj the object to be compared for equality with this {@code TabularData} instance; |
273 * |
273 * |
274 * @return <code>true</code> if the specified object is equal to this <code>TabularData</code> instance. |
274 * @return {@code true} if the specified object is equal to this {@code TabularData} instance. |
275 */ |
275 */ |
276 public boolean equals(Object obj); |
276 public boolean equals(Object obj); |
277 |
277 |
278 /** |
278 /** |
279 * Returns the hash code value for this <code>TabularData</code> instance. |
279 * Returns the hash code value for this {@code TabularData} instance. |
280 * <p> |
280 * <p> |
281 * The hash code of a <code>TabularData</code> instance is the sum of the hash codes |
281 * The hash code of a {@code TabularData} instance is the sum of the hash codes |
282 * of all elements of information used in <code>equals</code> comparisons |
282 * of all elements of information used in {@code equals} comparisons |
283 * (ie: its <i>tabular type</i> and its content, where the content is defined as all the index to value mappings). |
283 * (ie: its <i>tabular type</i> and its content, where the content is defined as all the index to value mappings). |
284 * <p> |
284 * <p> |
285 * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code> |
285 * This ensures that {@code t1.equals(t2)} implies that {@code t1.hashCode()==t2.hashCode()} |
286 * for any two <code>TabularDataSupport</code> instances <code>t1</code> and <code>t2</code>, |
286 * for any two {@code TabularDataSupport} instances {@code t1} and {@code t2}, |
287 * as required by the general contract of the method |
287 * as required by the general contract of the method |
288 * {@link Object#hashCode() Object.hashCode()}. |
288 * {@link Object#hashCode() Object.hashCode()}. |
289 * |
289 * |
290 * @return the hash code value for this <code>TabularDataSupport</code> instance |
290 * @return the hash code value for this {@code TabularDataSupport} instance |
291 */ |
291 */ |
292 public int hashCode(); |
292 public int hashCode(); |
293 |
293 |
294 /** |
294 /** |
295 * Returns a string representation of this <code>TabularData</code> instance. |
295 * Returns a string representation of this {@code TabularData} instance. |
296 * <p> |
296 * <p> |
297 * The string representation consists of the name of the implementing class, |
297 * The string representation consists of the name of the implementing class, |
298 * and the tabular type of this instance. |
298 * and the tabular type of this instance. |
299 * |
299 * |
300 * @return a string representation of this <code>TabularData</code> instance |
300 * @return a string representation of this {@code TabularData} instance |
301 */ |
301 */ |
302 public String toString(); |
302 public String toString(); |
303 |
303 |
304 } |
304 } |