EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.blobstore.strategy.internal]

COVERAGE SUMMARY FOR SOURCE FILE [ListContainerAndRecurseThroughFolders.java]

nameclass, %method, %block, %line, %
ListContainerAndRecurseThroughFolders.java100% (4/4)100% (8/8)67%  (85/126)75%  (11.3/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListContainerAndRecurseThroughFolders100% (1/1)100% (2/2)56%  (44/78)70%  (7.7/11)
execute (String, ListContainerOptions): Set 100% (1/1)53%  (38/72)59%  (4.7/8)
ListContainerAndRecurseThroughFolders (ListContainerStrategy): void 100% (1/1)100% (6/6)100% (3/3)
     
class ListContainerAndRecurseThroughFolders$1100% (1/1)100% (2/2)76%  (19/25)81%  (1.6/2)
apply (StorageMetadata): boolean 100% (1/1)62%  (10/16)62%  (0.6/1)
ListContainerAndRecurseThroughFolders$1 (ListContainerAndRecurseThroughFolder... 100% (1/1)100% (9/9)100% (1/1)
     
class ListContainerAndRecurseThroughFolders$2100% (1/1)100% (2/2)93%  (13/14)94%  (1.9/2)
apply (StorageMetadata): boolean 100% (1/1)88%  (7/8)87%  (0.9/1)
ListContainerAndRecurseThroughFolders$2 (ListContainerAndRecurseThroughFolder... 100% (1/1)100% (6/6)100% (1/1)
     
class ListContainerAndRecurseThroughFolders$3100% (1/1)100% (2/2)100% (9/9)100% (2/2)
ListContainerAndRecurseThroughFolders$3 (ListContainerAndRecurseThroughFolder... 100% (1/1)100% (6/6)100% (1/1)
apply (StorageMetadata): BlobMetadata 100% (1/1)100% (3/3)100% (1/1)

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.blobstore.strategy.internal;
20 
21import static com.google.common.collect.Iterables.concat;
22import static com.google.common.collect.Iterables.filter;
23import static com.google.common.collect.Iterables.transform;
24import static com.google.common.collect.Lists.newArrayList;
25import static com.google.common.collect.Sets.newLinkedHashSet;
26 
27import java.util.List;
28import java.util.Set;
29 
30import javax.inject.Singleton;
31 
32import org.jclouds.blobstore.domain.BlobMetadata;
33import org.jclouds.blobstore.domain.StorageMetadata;
34import org.jclouds.blobstore.domain.StorageType;
35import org.jclouds.blobstore.options.ListContainerOptions;
36import org.jclouds.blobstore.strategy.ListBlobsInContainer;
37import org.jclouds.blobstore.strategy.ListContainerStrategy;
38 
39import com.google.common.base.Function;
40import com.google.common.base.Predicate;
41import com.google.inject.Inject;
42 
43/**
44 * Retrieves all blobs in the blobstore by the most efficient means possible.
45 * 
46 * @author Adrian Cole
47 */
48@Singleton
49public class ListContainerAndRecurseThroughFolders implements ListBlobsInContainer {
50 
51   protected final ListContainerStrategy lister;
52 
53   @Inject
54   ListContainerAndRecurseThroughFolders(ListContainerStrategy lister) {
55      this.lister = lister;
56   }
57 
58   @Override
59   public Set<? extends BlobMetadata> execute(final String containerName, final ListContainerOptions options) {
60      final List<Iterable<? extends BlobMetadata>> lists = newArrayList();
61      Iterable<? extends StorageMetadata> pwdList = lister.execute(containerName, options);
62      for (StorageMetadata md : filter(pwdList, new Predicate<StorageMetadata>() {
63         @Override
64         public boolean apply(StorageMetadata input) {
65            return (input.getType() == StorageType.FOLDER || input.getType() == StorageType.RELATIVE_PATH)
66                     && options.isRecursive();
67         }
68      })) {
69         String directory = (options.getDir() != null) ? options.getDir() + "/" + md.getName() : md.getName();
70         lists.add(execute(containerName, options.clone().inDirectory(directory)));
71      }
72      lists.add(transform(filter(pwdList, new Predicate<StorageMetadata>() {
73         @Override
74         public boolean apply(StorageMetadata input) {
75            return input.getType() == StorageType.BLOB;
76         }
77      }), new Function<StorageMetadata, BlobMetadata>() {
78         @Override
79         public BlobMetadata apply(StorageMetadata from) {
80            return (BlobMetadata) from;
81         }
82      }));
83      return newLinkedHashSet(concat(lists));
84   }
85}

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