EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.openstack.options]

COVERAGE SUMMARY FOR SOURCE FILE [BaseListOptions.java]

nameclass, %method, %block, %line, %
BaseListOptions.java100% (2/2)89%  (8/9)94%  (97/103)96%  (17.3/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BaseListOptions$Builder100% (1/1)75%  (3/4)89%  (24/27)86%  (6/7)
BaseListOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
changesSince (Date): BaseListOptions 100% (1/1)100% (8/8)100% (2/2)
maxResults (int): BaseListOptions 100% (1/1)100% (8/8)100% (2/2)
startAt (long): BaseListOptions 100% (1/1)100% (8/8)100% (2/2)
     
class BaseListOptions100% (1/1)100% (5/5)96%  (73/76)98%  (11.8/12)
maxResults (int): BaseListOptions 100% (1/1)92%  (22/24)96%  (3.8/4)
startAt (long): BaseListOptions 100% (1/1)96%  (22/23)98%  (3/3)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
BaseListOptions (): void 100% (1/1)100% (3/3)100% (2/2)
changesSince (Date): BaseListOptions 100% (1/1)100% (21/21)100% (2/2)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.openstack.options;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Preconditions.checkState;
23 
24import java.util.Date;
25 
26import org.jclouds.http.options.BaseHttpRequestOptions;
27 
28/**
29 * Options used to control paginated results (aka list commands).
30 * 
31 * @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" />
32 * @author Adrian Cole
33 */
34public class BaseListOptions extends BaseHttpRequestOptions {
35   public static final BaseListOptions NONE = new BaseListOptions();
36 
37   /**
38    * Only return objects changed since this time.
39    */
40   public BaseListOptions changesSince(Date ifModifiedSince) {
41      this.queryParameters.put("changes-since", checkNotNull(ifModifiedSince, "ifModifiedSince")
42               .getTime()
43               / 1000 + "");
44      return this;
45   }
46 
47   /**
48    * Indicates where to begin listing. The list will only include objects that occur after the
49    * offset. This is convenient for pagination: To get the next page of results use the last result
50    * number of the current page + current page offset as the offset.
51    */
52   public BaseListOptions startAt(long offset) {
53      checkState(offset >= 0, "offset must be >= 0");
54      queryParameters.put("offset", Long.toString(checkNotNull(offset, "offset")));
55      return this;
56   }
57 
58   /**
59    * To reduce load on the service, list operations will return a maximum of 1,000 items at a time.
60    * To navigate the collection, the parameters limit and offset can be set in the URI
61    * (e.g.?limit=0&offset=0). If an offset is given beyond the end of a list an empty list will be
62    * returned.
63    * <p/>
64    * Note that list operations never return itemNotFound (404) faults.
65    */
66   public BaseListOptions maxResults(int limit) {
67      checkState(limit >= 0, "limit must be >= 0");
68      checkState(limit <= 10000, "limit must be <= 10000");
69      queryParameters.put("limit", Integer.toString(limit));
70      return this;
71   }
72 
73   public static class Builder {
74 
75      /**
76       * @see BaseListOptions#startAt(long)
77       */
78      public static BaseListOptions startAt(long prefix) {
79         BaseListOptions options = new BaseListOptions();
80         return options.startAt(prefix);
81      }
82 
83      /**
84       * @see BaseListOptions#maxResults(long)
85       */
86      public static BaseListOptions maxResults(int maxKeys) {
87         BaseListOptions options = new BaseListOptions();
88         return options.maxResults(maxKeys);
89      }
90 
91      /**
92       * @see BaseListOptions#changesSince(Date)
93       */
94      public static BaseListOptions changesSince(Date since) {
95         BaseListOptions options = new BaseListOptions();
96         return options.changesSince(since);
97      }
98 
99   }
100}

[all classes][org.jclouds.openstack.options]
EMMA 2.0.5312 (C) Vladimir Roubtsov