EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.blobstore.functions]

COVERAGE SUMMARY FOR SOURCE FILE [HttpGetOptionsListToGetOptions.java]

nameclass, %method, %block, %line, %
HttpGetOptionsListToGetOptions.java100% (1/1)50%  (1/2)8%   (9/115)14%  (3/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HttpGetOptionsListToGetOptions100% (1/1)50%  (1/2)8%   (9/115)14%  (3/21)
apply (GetOptions []): GetOptions 0%   (0/1)0%   (0/106)0%   (0/18)
HttpGetOptionsListToGetOptions (DateService): void 100% (1/1)100% (9/9)100% (3/3)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
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/**
20 *
21 * Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
22 *
23 * ====================================================================
24 * Licensed under the Apache License, Version 2.0 (the "License");
25 * you may not use this file except in compliance with the License.
26 * You may obtain a copy of the License at
27 *
28 * http://www.apache.org/licenses/LICENSE-2.0
29 *
30 * Unless required by applicable law or agreed to in writing, software
31 * distributed under the License is distributed on an "AS IS" BASIS,
32 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 * See the License for the specific language governing permissions and
34 * limitations under the License.
35 * ====================================================================
36 */
37 
38package org.jclouds.blobstore.functions;
39 
40import static com.google.common.base.Preconditions.checkNotNull;
41 
42import java.util.Date;
43 
44import javax.inject.Inject;
45import javax.inject.Singleton;
46 
47import org.jclouds.blobstore.options.GetOptions;
48import org.jclouds.date.DateService;
49import org.jclouds.util.Strings2;
50 
51import com.google.common.base.Function;
52 
53/**
54 * 
55 * @author Adrian Cole
56 */
57@Singleton
58public class HttpGetOptionsListToGetOptions implements
59      Function<org.jclouds.http.options.GetOptions[], org.jclouds.blobstore.options.GetOptions> {
60   private final DateService dateService;
61 
62   @Inject
63   HttpGetOptionsListToGetOptions(DateService dateService) {
64      this.dateService = checkNotNull(dateService, "dateService");
65   }
66 
67   public GetOptions apply(org.jclouds.http.options.GetOptions[] from) {
68      checkNotNull(from, "options");
69 
70      org.jclouds.blobstore.options.GetOptions to = new org.jclouds.blobstore.options.GetOptions();
71      if (from.length != 0) {
72         if (from[0].getIfMatch() != null) {
73            to.ifETagMatches(Strings2.replaceAll(from[0].getIfMatch(), '"', ""));
74         }
75         if (from[0].getIfModifiedSince() != null) {
76            Date time = dateService.rfc822DateParse(from[0].getIfModifiedSince());
77            to.ifModifiedSince(time);
78         }
79         if (from[0].getIfNoneMatch() != null) {
80            to.ifETagDoesntMatch(Strings2.replaceAll(from[0].getIfNoneMatch(), '"', ""));
81         }
82         if (from[0].getIfUnmodifiedSince() != null) {
83            Date time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince());
84            to.ifUnmodifiedSince(time);
85         }
86         for (String range : from[0].getRanges()) {
87            String[] firstLast = range.split("\\-");
88            to.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1]));
89         }
90      }
91      return to;
92   }
93 
94}

[all classes][org.jclouds.blobstore.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov