EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.blobstore.strategy.internal]

COVERAGE SUMMARY FOR SOURCE FILE [MarkersIfDirectoryReturnNameStrategy.java]

nameclass, %method, %block, %line, %
MarkersIfDirectoryReturnNameStrategy.java100% (2/2)100% (3/3)80%  (74/93)74%  (7.4/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MarkersIfDirectoryReturnNameStrategy100% (1/1)100% (2/2)75%  (45/60)75%  (7.5/10)
execute (StorageMetadata): String 100% (1/1)74%  (42/57)67%  (6/9)
MarkersIfDirectoryReturnNameStrategy (): void 100% (1/1)100% (3/3)100% (2/2)
     
class MarkersIfDirectoryReturnNameStrategy$1100% (1/1)100% (1/1)88%  (29/33)87%  (0.9/1)
<static initializer> 100% (1/1)88%  (29/33)87%  (0.9/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.blobstore.strategy.internal;
20 
21import javax.inject.Singleton;
22 
23import org.jclouds.blobstore.domain.BlobMetadata;
24import org.jclouds.blobstore.domain.StorageMetadata;
25import org.jclouds.blobstore.reference.BlobStoreConstants;
26import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy;
27 
28/**
29 * 
30 * @author Adrian Cole
31 */
32@Singleton
33public class MarkersIfDirectoryReturnNameStrategy implements IfDirectoryReturnNameStrategy {
34   @Override
35   public String execute(StorageMetadata metadata) {
36      switch (metadata.getType()) {
37      case CONTAINER:
38      case FOLDER:
39      case RELATIVE_PATH:
40         return metadata.getName();
41      case BLOB:
42         BlobMetadata blobMd = (BlobMetadata) metadata;
43         for (String suffix : BlobStoreConstants.DIRECTORY_SUFFIXES) {
44            if (metadata.getName().endsWith(suffix)) {
45               return metadata.getName().substring(0, metadata.getName().lastIndexOf(suffix));
46            }
47         }
48         // It is important that this is last, in case there is a file with a known directory
49         // suffix who also has content type set to application/directory
50         if (blobMd.getContentMetadata().getContentType() != null
51               && blobMd.getContentMetadata().getContentType().equals("application/directory"))
52            return metadata.getName();
53      }
54      return null;
55   }
56}

[all classes][org.jclouds.blobstore.strategy.internal]
EMMA 2.0.5312 (C) Vladimir Roubtsov