EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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