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

COVERAGE SUMMARY FOR SOURCE FILE [SplitNewlinesAndReturnSecondField.java]

nameclass, %method, %block, %line, %
SplitNewlinesAndReturnSecondField.java50%  (1/2)25%  (1/4)8%   (4/51)17%  (2/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SplitNewlinesAndReturnSecondField$10%   (0/1)0%   (0/2)0%   (0/35)0%   (0/9)
SplitNewlinesAndReturnSecondField$1 (SplitNewlinesAndReturnSecondField): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (String): String 0%   (0/1)0%   (0/29)0%   (0/8)
     
class SplitNewlinesAndReturnSecondField100% (1/1)50%  (1/2)25%  (4/16)67%  (2/3)
apply (HttpResponse): Set 0%   (0/1)0%   (0/12)0%   (0/1)
SplitNewlinesAndReturnSecondField (ReturnStringIf2xx): void 100% (1/1)100% (4/4)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.cloudsigma.functions;
20 
21import java.util.Set;
22 
23import javax.inject.Inject;
24import javax.inject.Singleton;
25 
26import org.jclouds.http.HttpResponse;
27import org.jclouds.http.functions.ReturnStringIf2xx;
28 
29import com.google.common.base.Function;
30import com.google.common.base.Predicates;
31import com.google.common.base.Splitter;
32import com.google.common.collect.ImmutableSet;
33import com.google.common.collect.Iterables;
34 
35/**
36 * 
37 * @author Adrian Cole
38 */
39@Singleton
40public class SplitNewlinesAndReturnSecondField extends SplitNewlines {
41 
42   @Inject
43   SplitNewlinesAndReturnSecondField(ReturnStringIf2xx returnStringIf200) {
44      super(returnStringIf200);
45   }
46 
47   @Override
48   public Set<String> apply(HttpResponse response) {
49      return ImmutableSet.copyOf(Iterables.filter(
50            Iterables.transform(super.apply(response), new Function<String, String>() {
51 
52               @Override
53               public String apply(String arg0) {
54                  if (arg0 == null)
55                     return null;
56                  Iterable<String> parts = Splitter.on(' ').split(arg0);
57                  if (Iterables.size(parts) == 2)
58                     return Iterables.get(parts, 1);
59                  else if (Iterables.size(parts) == 1)
60                     return Iterables.get(parts, 0);
61                  return null;
62               }
63 
64            }), Predicates.notNull()));
65   }
66}

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