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

COVERAGE SUMMARY FOR SOURCE FILE [CopyObjectHandler.java]

nameclass, %method, %block, %line, %
CopyObjectHandler.java100% (1/1)100% (4/4)100% (61/61)100% (13/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CopyObjectHandler100% (1/1)100% (4/4)100% (61/61)100% (13/13)
CopyObjectHandler (): void 100% (1/1)100% (8/8)100% (2/2)
characters (char [], int, int): void 100% (1/1)100% (8/8)100% (2/2)
endElement (String, String, String): void 100% (1/1)100% (42/42)100% (8/8)
getResult (): ObjectMetadata 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.s3.xml;
20 
21import static org.jclouds.util.SaxUtils.currentOrNull;
22 
23import java.util.Date;
24 
25import javax.inject.Inject;
26 
27import org.jclouds.s3.domain.ObjectMetadata;
28import org.jclouds.s3.domain.internal.CopyObjectResult;
29import org.jclouds.date.DateService;
30import org.jclouds.http.functions.ParseSax;
31 
32/**
33 * Parses the response from Amazon S3 COPY Object command.
34 * <p/>
35 * CopyObjectResult is the document we expect to parse.
36 * 
37 * @see <a href= "http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectCOPY.html" />
38 * @author Adrian Cole
39 */
40public class CopyObjectHandler extends ParseSax.HandlerWithResult<ObjectMetadata> {
41 
42   private CopyObjectResult metadata;
43   private StringBuilder currentText = new StringBuilder();
44   @Inject
45   private DateService dateParser;
46   private Date currentLastModified;
47   private String currentETag;
48 
49   public ObjectMetadata getResult() {
50      return metadata;
51   }
52 
53   public void endElement(String uri, String name, String qName) {
54      if (qName.equals("ETag")) {
55         this.currentETag = currentOrNull(currentText);
56      } else if (qName.equals("LastModified")) {
57         this.currentLastModified = dateParser.iso8601DateParse(currentOrNull(currentText));
58      } else if (qName.equals("CopyObjectResult")) {
59         metadata = new CopyObjectResult(currentLastModified, currentETag);
60      }
61      currentText = new StringBuilder();
62   }
63 
64   public void characters(char ch[], int start, int length) {
65      currentText.append(ch, start, length);
66   }
67}

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