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

COVERAGE SUMMARY FOR SOURCE FILE [ContainerNameValidator.java]

nameclass, %method, %block, %line, %
ContainerNameValidator.java100% (1/1)100% (3/3)100% (43/43)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ContainerNameValidator100% (1/1)100% (3/3)100% (43/43)100% (9/9)
ContainerNameValidator (): void 100% (1/1)100% (5/5)100% (2/2)
exception (String, String): IllegalArgumentException 100% (1/1)100% (16/16)100% (1/1)
validate (String): void 100% (1/1)100% (22/22)100% (6/6)

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.azureblob.predicates.validators;
20 
21import javax.inject.Inject;
22 
23import org.jclouds.predicates.validators.DnsNameValidator;
24 
25import com.google.inject.Singleton;
26 
27/**
28 * Validates name for Azure container. The complete requirements are listed at:
29 * http://weblogs.asp.net
30 * /vblasberg/archive/2009/02/17/azure-details-and-limitations-blobs-tables-and-queues.aspx
31 * 
32 * @see org.jclouds.rest.InputParamValidator
33 * @see org.jclouds.predicates.Validator
34 * 
35 * @author Oleksiy Yarmula
36 */
37@Singleton
38public class ContainerNameValidator extends DnsNameValidator {
39 
40   @Inject
41   ContainerNameValidator() {
42      super(3,63);
43   }
44 
45   public void validate(String containerName) {
46      super.validate(containerName);
47      if (containerName.contains("--"))
48         throw exception(containerName, "Every dash must be followed by letter or number");
49      if (containerName.endsWith("-"))
50         throw exception(containerName, "Shouldn't end with a dash");
51   }
52 
53   @Override
54   protected IllegalArgumentException exception(String containerName, String reason) {
55      return new IllegalArgumentException(
56               String
57                        .format(
58                                 "Object '%s' doesn't match Azure container naming convention. "
59                                          + "Reason: %s. For more info, please refer to http://weblogs.asp.net/vblasberg/archive/2009/02/17/"
60                                          + "azure-details-and-limitations-blobs-tables-and-queues.aspx.",
61                                 containerName, reason));
62   }
63 
64}

[all classes][org.jclouds.azureblob.predicates.validators]
EMMA 2.0.5312 (C) Vladimir Roubtsov