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

COVERAGE SUMMARY FOR SOURCE FILE [ListOptions.java]

nameclass, %method, %block, %line, %
ListOptions.java100% (2/2)75%  (9/12)79%  (84/106)83%  (18.3/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListOptions100% (1/1)75%  (6/8)76%  (61/80)80%  (12.8/16)
getLimit (): Integer 0%   (0/1)0%   (0/13)0%   (0/2)
getToken (): String 0%   (0/1)0%   (0/4)0%   (0/1)
limit (int): ListOptions 100% (1/1)92%  (22/24)96%  (3.8/4)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
ListOptions (): void 100% (1/1)100% (3/3)100% (2/2)
includeMeta (): ListOptions 100% (1/1)100% (9/9)100% (2/2)
metaIncluded (): boolean 100% (1/1)100% (12/12)100% (2/2)
token (String): ListOptions 100% (1/1)100% (10/10)100% (2/2)
     
class ListOptions$Builder100% (1/1)75%  (3/4)88%  (23/26)86%  (6/7)
ListOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
includeMeta (): ListOptions 100% (1/1)100% (7/7)100% (2/2)
limit (int): ListOptions 100% (1/1)100% (8/8)100% (2/2)
token (String): ListOptions 100% (1/1)100% (8/8)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.atmos.options;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Preconditions.checkState;
23 
24import org.jclouds.http.options.BaseHttpRequestOptions;
25 
26/**
27 * Options used to control paginated results (aka list commands).
28 * 
29 * @author Adrian Cole
30 */
31public class ListOptions extends BaseHttpRequestOptions {
32   public static final ListOptions NONE = new ListOptions();
33 
34   /**
35    * specifies the position to resume listing
36    * <p/>
37    * note this is an opaque value and should not be interpreted.
38    */
39   public ListOptions token(String token) {
40      this.headers.put("x-emc-token", checkNotNull(token, "x-emc-token"));
41      return this;
42   }
43 
44   public String getToken() {
45      return getFirstHeaderOrNull("x-emc-token");
46   }
47 
48   /**
49    * the maximum number of items that should be returned. If this is not specified, there is no
50    * limit.
51    */
52   public ListOptions limit(int maxresults) {
53      checkState(maxresults >= 0, "maxresults must be >= 0");
54      checkState(maxresults <= 10000, "maxresults must be <= 10000");
55      headers.put("x-emc-limit", Integer.toString(maxresults));
56      return this;
57   }
58 
59   /**
60    * the maximum number of items that should be returned. If this is not specified, there is no
61    * limit.
62    */
63   public ListOptions includeMeta() {
64      headers.put("x-emc-include-meta", Integer.toString(1));
65      return this;
66   }
67 
68   public boolean metaIncluded() {
69      String meta = getFirstHeaderOrNull("x-emc-include-meta");
70      return (meta != null) ? meta.equals("1") : false;
71   }
72 
73   public Integer getLimit() {
74      String maxresults = getFirstHeaderOrNull("x-emc-limit");
75      return (maxresults != null) ? new Integer(maxresults) : null;
76   }
77 
78   public static class Builder {
79 
80      /**
81       * @see ListOptions#token(String)
82       */
83      public static ListOptions token(String token) {
84         ListOptions options = new ListOptions();
85         return options.token(token);
86      }
87 
88      /**
89       * @see ListOptions#includeMeta()
90       */
91      public static ListOptions includeMeta() {
92         ListOptions options = new ListOptions();
93         return options.includeMeta();
94      }
95 
96      /**
97       * @see ListOptions#limit(int)
98       */
99      public static ListOptions limit(int maxKeys) {
100         ListOptions options = new ListOptions();
101         return options.limit(maxKeys);
102      }
103 
104   }
105}

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