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

COVERAGE SUMMARY FOR SOURCE FILE [MutableObjectMetadataImpl.java]

nameclass, %method, %block, %line, %
MutableObjectMetadataImpl.java100% (1/1)85%  (22/26)76%  (179/237)75%  (46.2/62)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MutableObjectMetadataImpl100% (1/1)85%  (22/26)76%  (179/237)75%  (46.2/62)
MutableObjectMetadataImpl (ObjectMetadata): void 0%   (0/1)0%   (0/31)0%   (0/9)
compareTo (ObjectMetadata): int 0%   (0/1)0%   (0/11)0%   (0/1)
getBucket (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getUri (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
equals (Object): boolean 100% (1/1)78%  (29/37)69%  (9/13)
hashCode (): int 100% (1/1)89%  (17/19)97%  (3.9/4)
MutableObjectMetadataImpl (): void 100% (1/1)100% (14/14)100% (5/5)
getCacheControl (): String 100% (1/1)100% (3/3)100% (1/1)
getContentMetadata (): MutableContentMetadata 100% (1/1)100% (3/3)100% (1/1)
getETag (): String 100% (1/1)100% (3/3)100% (1/1)
getKey (): String 100% (1/1)100% (3/3)100% (1/1)
getLastModified (): Date 100% (1/1)100% (3/3)100% (1/1)
getOwner (): CanonicalUser 100% (1/1)100% (3/3)100% (1/1)
getStorageClass (): ObjectMetadata$StorageClass 100% (1/1)100% (3/3)100% (1/1)
getUserMetadata (): Map 100% (1/1)100% (3/3)100% (1/1)
setBucket (String): void 100% (1/1)100% (4/4)100% (2/2)
setCacheControl (String): void 100% (1/1)100% (4/4)100% (2/2)
setContentMetadata (MutableContentMetadata): void 100% (1/1)100% (4/4)100% (2/2)
setETag (String): void 100% (1/1)100% (4/4)100% (2/2)
setKey (String): void 100% (1/1)100% (4/4)100% (2/2)
setLastModified (Date): void 100% (1/1)100% (4/4)100% (2/2)
setOwner (CanonicalUser): void 100% (1/1)100% (4/4)100% (2/2)
setStorageClass (ObjectMetadata$StorageClass): void 100% (1/1)100% (4/4)100% (2/2)
setUri (URI): void 100% (1/1)100% (4/4)100% (2/2)
setUserMetadata (Map): void 100% (1/1)100% (4/4)100% (2/2)
toString (): String 100% (1/1)100% (55/55)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.s3.domain.internal;
20 
21import java.io.Serializable;
22import java.net.URI;
23import java.util.Date;
24import java.util.Map;
25 
26import org.jclouds.http.HttpUtils;
27import org.jclouds.io.MutableContentMetadata;
28import org.jclouds.io.payloads.BaseMutableContentMetadata;
29import org.jclouds.s3.domain.CanonicalUser;
30import org.jclouds.s3.domain.MutableObjectMetadata;
31import org.jclouds.s3.domain.ObjectMetadata;
32 
33import com.google.common.collect.Maps;
34 
35/**
36 * Allows you to manipulate metadata.
37 * 
38 * @author Adrian Cole
39 */
40public class MutableObjectMetadataImpl implements Serializable, MutableObjectMetadata {
41 
42   /** The serialVersionUID */
43   private static final long serialVersionUID = -4648755473986695062L;
44 
45   private String key;
46   private String bucket;
47   private URI uri;
48   private Date lastModified;
49   private String eTag;
50   private CanonicalUser owner;
51   private StorageClass storageClass;
52   private String cacheControl;
53   private Map<String, String> userMetadata = Maps.newHashMap();
54   private MutableContentMetadata contentMetadata;
55 
56   public MutableObjectMetadataImpl() {
57      this.storageClass = StorageClass.STANDARD;
58      this.contentMetadata = new BaseMutableContentMetadata();
59   }
60 
61   public MutableObjectMetadataImpl(ObjectMetadata from) {
62      this.storageClass = StorageClass.STANDARD;
63      this.contentMetadata = new BaseMutableContentMetadata();
64      HttpUtils.copy(from.getContentMetadata(), this.contentMetadata);
65      this.key = from.getKey();
66      this.uri = from.getUri();
67      this.bucket = from.getBucket();
68   }
69 
70   /**
71    *{@inheritDoc}
72    */
73   @Override
74   public String getKey() {
75      return key;
76   }
77 
78   /**
79    *{@inheritDoc}
80    */
81   @Override
82   public String getBucket() {
83      return bucket;
84   }
85 
86   /**
87    *{@inheritDoc}
88    */
89   @Override
90   public URI getUri() {
91      return uri;
92   }
93 
94   /**
95    *{@inheritDoc}
96    */
97   @Override
98   public void setUri(URI uri) {
99      this.uri = uri;
100   }
101 
102   /**
103    *{@inheritDoc}
104    */
105   @Override
106   public CanonicalUser getOwner() {
107      return owner;
108   }
109 
110   /**
111    *{@inheritDoc}
112    */
113   @Override
114   public StorageClass getStorageClass() {
115      return storageClass;
116   }
117 
118   /**
119    *{@inheritDoc}
120    */
121   @Override
122   public String getCacheControl() {
123      return cacheControl;
124   }
125 
126   /**
127    *{@inheritDoc}
128    */
129   @Override
130   public Date getLastModified() {
131      return lastModified;
132   }
133 
134   /**
135    *{@inheritDoc}
136    */
137   @Override
138   public String getETag() {
139      return eTag;
140   }
141 
142   /**
143    *{@inheritDoc}
144    */
145   @Override
146   public int compareTo(ObjectMetadata o) {
147      return (this == o) ? 0 : getKey().compareTo(o.getKey());
148   }
149 
150   /**
151    *{@inheritDoc}
152    */
153   @Override
154   public Map<String, String> getUserMetadata() {
155      return userMetadata;
156   }
157 
158   /**
159    *{@inheritDoc}
160    */
161   @Override
162   public void setCacheControl(String cacheControl) {
163      this.cacheControl = cacheControl;
164   }
165 
166   /**
167    *{@inheritDoc}
168    */
169   @Override
170   public void setETag(String eTag) {
171      this.eTag = eTag;
172   }
173 
174   /**
175    *{@inheritDoc}
176    */
177   @Override
178   public void setKey(String key) {
179      this.key = key;
180   }
181 
182   /**
183    *{@inheritDoc}
184    */
185   @Override
186   public void setBucket(String bucket) {
187      this.bucket = bucket;
188   }
189 
190   /**
191    *{@inheritDoc}
192    */
193   @Override
194   public void setLastModified(Date lastModified) {
195      this.lastModified = lastModified;
196   }
197 
198   /**
199    *{@inheritDoc}
200    */
201   @Override
202   public void setOwner(CanonicalUser owner) {
203      this.owner = owner;
204   }
205 
206   /**
207    *{@inheritDoc}
208    */
209   @Override
210   public void setStorageClass(StorageClass storageClass) {
211      this.storageClass = storageClass;
212   }
213 
214   /**
215    *{@inheritDoc}
216    */
217   @Override
218   public void setUserMetadata(Map<String, String> userMetadata) {
219      this.userMetadata = userMetadata;
220   }
221 
222   /**
223    * {@inheritDoc}
224    */
225   @Override
226   public MutableContentMetadata getContentMetadata() {
227      return contentMetadata;
228   }
229 
230   /**
231    * {@inheritDoc}
232    */
233   @Override
234   public void setContentMetadata(MutableContentMetadata contentMetadata) {
235      this.contentMetadata = contentMetadata;
236   }
237 
238   @Override
239   public int hashCode() {
240      final int prime = 31;
241      int result = 1;
242      result = prime * result + ((uri == null) ? 0 : uri.hashCode());
243      return result;
244   }
245 
246   @Override
247   public boolean equals(Object obj) {
248      if (this == obj)
249         return true;
250      if (obj == null)
251         return false;
252      if (getClass() != obj.getClass())
253         return false;
254      MutableObjectMetadataImpl other = (MutableObjectMetadataImpl) obj;
255      if (uri == null) {
256         if (other.uri != null)
257            return false;
258      } else if (!uri.equals(other.uri))
259         return false;
260      return true;
261   }
262 
263   @Override
264   public String toString() {
265      return String
266               .format(
267                        "[key=%s, bucket=%s, uri=%s, eTag=%s, cacheControl=%s, contentMetadata=%s, lastModified=%s, owner=%s, storageClass=%s, userMetadata=%s]",
268                        key, bucket, uri, eTag, cacheControl, contentMetadata, lastModified, owner, storageClass,
269                        userMetadata);
270   }
271 
272}

[all classes][org.jclouds.s3.domain.internal]
EMMA 2.0.5312 (C) Vladimir Roubtsov