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

COVERAGE SUMMARY FOR SOURCE FILE [ParseOsFromVAppTemplateName.java]

nameclass, %method, %block, %line, %
ParseOsFromVAppTemplateName.java0%   (0/1)0%   (0/3)0%   (0/60)0%   (0/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParseOsFromVAppTemplateName0%   (0/1)0%   (0/3)0%   (0/60)0%   (0/13)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
ParseOsFromVAppTemplateName (Map): void 0%   (0/1)0%   (0/9)0%   (0/3)
apply (String): OperatingSystem 0%   (0/1)0%   (0/47)0%   (0/9)

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 */
19package org.jclouds.trmk.vcloud_0_8.compute.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrUnrecognized;
23 
24import java.util.Map;
25import java.util.regex.Matcher;
26import java.util.regex.Pattern;
27 
28import javax.inject.Inject;
29import javax.inject.Singleton;
30 
31import org.jclouds.compute.domain.OperatingSystem;
32import org.jclouds.compute.domain.OsFamily;
33import org.jclouds.compute.util.ComputeServiceUtils;
34 
35import com.google.common.base.Function;
36 
37/**
38 * @author Adrian Cole
39 */
40@Singleton
41public class ParseOsFromVAppTemplateName implements Function<String, OperatingSystem> {
42   protected static final Pattern OS_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
43 
44   protected final Map<OsFamily, Map<String, String>> osVersionMap;
45 
46   @Inject
47   protected ParseOsFromVAppTemplateName(Map<OsFamily, Map<String, String>> osVersionMap) {
48      this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
49   }
50 
51   @Override
52   public OperatingSystem apply(String from) {
53      OperatingSystem.Builder builder = OperatingSystem.builder();
54      OsFamily osFamily = parseOsFamilyOrUnrecognized(checkNotNull(from, "vapp template name"));
55      builder.family(osFamily);
56      builder.description(from);
57      builder.is64Bit(from.indexOf("64") != -1);
58      Matcher matcher = OS_PATTERN.matcher(from);
59      if (matcher.find()) {
60         builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap));
61      }
62      return builder.build();
63   }
64}

[all classes][org.jclouds.trmk.vcloud_0_8.compute.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov