View Javadoc

1   package com.terradue.jcatalogue.client;
2   
3   /*
4    *    Copyright 2011-2012 Terradue srl
5    *
6    *    Licensed under the Apache License, Version 2.0 (the "License");
7    *    you may not use this file except in compliance with the License.
8    *    You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *    Unless required by applicable law or agreed to in writing, software
13   *    distributed under the License is distributed on an "AS IS" BASIS,
14   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *    See the License for the specific language governing permissions and
16   *    limitations under the License.
17   */
18  
19  import java.util.ArrayList;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import lombok.EqualsAndHashCode;
24  import lombok.ToString;
25  
26  @ToString
27  @EqualsAndHashCode( callSuper = true )
28  public class Series
29      extends AtomEntity
30      implements Iterable<DataSet>
31  {
32  
33      private final List<DataSet> dataSets = new ArrayList<DataSet>();
34  
35      public void addDataSet( DataSet dataSet )
36      {
37          dataSets.add( dataSet );
38      }
39  
40      @Override
41      public Iterator<DataSet> iterator()
42      {
43          return dataSets.iterator();
44      }
45  
46      public Series getNextResults()
47      {
48          if ( !hasMoreResults() )
49          {
50              throw new IllegalStateException( "More results not available" );
51          }
52  
53          return getCatalogueClient().getSeries( getNextResultsUri() );
54      }
55  
56      @Override
57      void setCatalogueClient( CatalogueClient catalogueClient )
58      {
59          super.setCatalogueClient( catalogueClient );
60  
61          for ( DataSet dataSet : dataSets )
62          {
63              dataSet.setCatalogueClient( catalogueClient );
64          }
65      }
66  
67  }