View Javadoc

1   /*
2    * Copyright 2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.callbackparams.combine;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  /**
23   * A collection of arrays of callback-values. CombineStrategy
24   * implementations will create their callback-records in a manner that makes
25   * each callback-record contain exactly one callback-value from each array.
26   * 
27   * @author Henrik Kaipe
28   */
29  public class ValuesCollection {
30      
31      List valuesArrays = new ArrayList();
32  
33      /**
34       * Attaches the specified array of callback-values at the end of this
35       * ValuesCollection.
36       */
37      public void add(Object[] valuesArray) {
38          if (0 < valuesArray.length) {
39              valuesArrays.add(valuesArray);
40          }
41      }
42      
43      /**
44       * Returns the array that contains the callback-values available for
45       * the specified index of the callback-records created from this
46       * ValuesCollection instance.
47       */
48      public Object[] get(int index) {
49          return (Object[]) valuesArrays.get(index);
50      }
51      
52      /**
53       * Returns the number of arrays of callback-values in this
54       * ValuesCollection instance.
55       */
56      public int size() {
57          return valuesArrays.size();
58      }
59  }