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

COVERAGE SUMMARY FOR SOURCE FILE [Patterns.java]

nameclass, %method, %block, %line, %
Patterns.java100% (4/4)75%  (6/8)80%  (108/135)86%  (25/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Patterns$2100% (1/1)50%  (1/2)23%  (3/13)50%  (1/2)
apply (Character): Pattern 0%   (0/1)0%   (0/10)0%   (0/1)
Patterns$2 (): void 100% (1/1)100% (3/3)100% (1/1)
     
class Patterns$1100% (1/1)100% (2/2)55%  (17/31)60%  (3/5)
apply (Character): Pattern 100% (1/1)50%  (14/28)50%  (2/4)
Patterns$1 (): void 100% (1/1)100% (3/3)100% (1/1)
     
class Patterns100% (1/1)50%  (1/2)96%  (73/76)95%  (19/20)
Patterns (): void 0%   (0/1)0%   (0/3)0%   (0/1)
<static initializer> 100% (1/1)100% (73/73)100% (19/19)
     
class Patterns$3100% (1/1)100% (2/2)100% (15/15)100% (2/2)
Patterns$3 (): void 100% (1/1)100% (3/3)100% (1/1)
apply (String): Pattern 100% (1/1)100% (12/12)100% (1/1)

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.util;
20 
21import java.io.UnsupportedEncodingException;
22import java.net.URLEncoder;
23import java.util.Map;
24import java.util.regex.Pattern;
25 
26import com.google.common.base.Function;
27import com.google.common.collect.MapMaker;
28 
29/**
30 * 
31 * @author Adrian Cole
32 */
33public class Patterns {
34   public static final Pattern TOKEN_PATTERN = Pattern.compile("\\{(.+?)\\}");
35   public static final Pattern TWO_SPACE_PATTERN = Pattern.compile("  ");
36   public static final Pattern URL_ENCODED_PATTERN = Pattern.compile(".*%[a-fA-F0-9][a-fA-F0-9].*");
37   public static final Pattern URI_PATTERN = Pattern.compile("([a-z0-9]+)://([^:]*):(.*)@(.*)");
38   public static final Pattern PATTERN_THAT_BREAKS_URI = Pattern.compile("[a-z0-9]+://.*/.*@.*");
39   public static final Pattern JSON_STRING_PATTERN = Pattern.compile("^[^\"\\{\\[].*[^\\{\\[\"]$");
40   public static final Pattern JSON_NUMBER_PATTERN = Pattern.compile("^[0-9]*\\.?[0-9]*$");
41   public static final Pattern PLUS_PATTERN = Pattern.compile("\\+");
42   public static final Pattern STAR_PATTERN = Pattern.compile("\\*");
43   public static final Pattern _7E_PATTERN = Pattern.compile("%7E");
44   public static final Pattern NEWLINE_PATTERN = Pattern.compile("\r?\n");
45   public static final Pattern SLASH_PATTERN = Pattern.compile("[/]");
46   public static final Pattern IP_PATTERN = Pattern
47            .compile("b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).)"
48                     + "{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b");
49   public static final Pattern LEADING_SLASHES = Pattern.compile("^[/]+");
50   public static final Pattern TRAILING_SLASHES = Pattern.compile("[/]*$");
51   public static final Pattern REST_CONTEXT_BUILDER = Pattern.compile("(.*ContextBuilder)<([^,]+), ?([^>]+)>");
52 
53   public final static Map<Character, Pattern> CHAR_TO_ENCODED_PATTERN = new MapMaker()
54            .makeComputingMap(new Function<Character, Pattern>() {
55               public Pattern apply(Character plain) {
56                  try {
57                     String encoded = URLEncoder.encode(plain + "", "UTF-8");
58                     return Pattern.compile(encoded);
59                  } catch (UnsupportedEncodingException e) {
60                     throw new IllegalStateException("Bad encoding on input: " + plain, e);
61                  }
62               }
63            });
64 
65   public final static Map<Character, Pattern> CHAR_TO_PATTERN = new MapMaker()
66            .makeComputingMap(new Function<Character, Pattern>() {
67               public Pattern apply(Character plain) {
68                  return Pattern.compile(plain + "");
69               }
70            });
71 
72   public final static Map<String, Pattern> TOKEN_TO_PATTERN = new MapMaker()
73            .makeComputingMap(new Function<String, Pattern>() {
74               public Pattern apply(String tokenValue) {
75                  return Pattern.compile("\\{" + tokenValue + "\\}");
76               }
77            });
78}

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