Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
    *
    * Portions copyright 2006-2009 James Murty. Please see LICENSE.txt
    * for applicable license terms and NOTICE.txt for applicable notices.
    *
    * Licensed under the Apache License, Version 2.0 (the "License").
    * You may not use this file except in compliance with the License.
    * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
   * or in the "license" file accompanying this file. This file is distributed
   * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
   * express or implied. See the License for the specific language governing
   * permissions and limitations under the License.
   */
  package com.amazonaws.services.s3.model.transform;
  
  import static com.amazonaws.util.StringUtils.UTF8;
  
  import java.util.Date;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Locale;
  import java.util.Map;
  import java.util.UUID;
  
  
XML Sax parser to read XML documents returned by S3 via the REST interface, converting these documents into objects.
 
 public class XmlResponsesSaxParser {
     private static final Log log = LogFactory.getLog(XmlResponsesSaxParser.class);
 
     private XMLReader xr = null;
 
     private boolean sanitizeXmlDocument = true;

    
Constructs the XML SAX parser.

 
     public XmlResponsesSaxParser() throws AmazonClientException {
         // Ensure we can load the XML Reader.
         try {
              = XMLReaderFactory.createXMLReader();
         } catch (SAXException e) {
             throw new AmazonClientException("Couldn't initialize a SAX driver to create an XMLReader"e);
         }
     }

    
Parses an XML document from an input stream using a document handler.

Parameters:
handler the handler for the XML document
inputStream an input stream containing the XML document to parse
Throws:
java.io.IOException on error reading from the input stream (ie connection reset)
com.amazonaws.AmazonClientException on error with malformed XML, etc
 
     protected void parseXmlInputStream(DefaultHandler handlerInputStream inputStream)
             throws IOException {
         try {
 
             if (.isDebugEnabled()) {
                 .debug("Parsing XML response document with handler: " + handler.getClass());
             }
 
             BufferedReader breader = new BufferedReader(new InputStreamReader(inputStream,
                 .));
             .setContentHandler(handler);
             .setErrorHandler(handler);
             .parse(new InputSource(breader));
 
         } catch (IOException e) {
             throw e;
 
         } catch (Throwable t) {
             try {
                 inputStream.close();
             } catch (IOException e) {
                 if (.isErrorEnabled()) {
                     .error("Unable to close response InputStream up after XML parse failure"e);
                 }
             }
             throw new AmazonClientException("Failed to parse XML document with handler "
                 + handler.getClass(), t);
         }
     }
 
     protected InputStream sanitizeXmlDocument(DefaultHandler handlerInputStream inputStream)
             throws IOException {
 
         if (!) {
             // No sanitizing will be performed, return the original input stream unchanged.
             return inputStream;
         } else {
             if (.isDebugEnabled()) {
                 .debug("Sanitizing XML document destined for handler " + handler.getClass());
             }
 
             InputStream sanitizedInputStream = null;
 
             try {
 
                 /*
                  * Read object listing XML document from input stream provided into a
                  * string buffer, so we can replace troublesome characters before
                  * sending the document to the XML parser.
                  */
                 StringBuilder listingDocBuffer = new StringBuilder();
                 BufferedReader br = new BufferedReader(
                     new InputStreamReader(inputStream.));
 
                 char[] buf = new char[8192];
                 int read = -1;
                 while ((read = br.read(buf)) != -1) {
                     listingDocBuffer.append(buf, 0, read);
                 }
                 br.close();
 
                 /*
                  * Replace any carriage return (\r) characters with explicit XML
                  * character entities, to prevent the SAX parser from
                  * misinterpreting 0x0D characters as 0x0A and being unable to
                  * parse the XML.
                  */
                 String listingDoc = listingDocBuffer.toString().replaceAll("\r""
");
 
                 sanitizedInputStream = new ByteArrayInputStream(
                     listingDoc.getBytes());
 
             } catch (IOException e) {
                 throw e;
 
             } catch (Throwable t) {
                 try {
                     inputStream.close();
                 } catch (IOException e) {
                     if (.isErrorEnabled()) {
                         .error("Unable to close response InputStream after failure sanitizing XML document"e);
                     }
                 }
                 throw new AmazonClientException("Failed to sanitize XML document destined for handler "
                     + handler.getClass(), t);
             }
             return sanitizedInputStream;
         }
     }

    
Checks if the specified string is empty or null and if so, returns null. Otherwise simply returns the string.

Parameters:
s The string to check.
Returns:
Null if the specified string was null, or empty, otherwise returns the string the caller passed in.
 
     private static String checkForEmptyString(String s) {
         if (s == nullreturn null;
         if (s.length() == 0) return null;
 
         return s;
     }

    
Safely parses the specified string as an integer and returns the value. If a NumberFormatException occurs while parsing the integer, an error is logged and -1 is returned.

Parameters:
s The string to parse and return as an integer.
Returns:
The integer value of the specified string, otherwise -1 if there were any problems parsing the string as an integer.
 
     private static int parseInt(String s) {
         try {
             return Integer.parseInt(s);
         } catch (NumberFormatException nfe) {
             .error("Unable to parse integer value '" + s + "'"nfe);
         }
 
         return -1;
     }

    
Safely parses the specified string as a long and returns the value. If a NumberFormatException occurs while parsing the long, an error is logged and -1 is returned.

Parameters:
s The string to parse and return as a long.
Returns:
The long value of the specified string, otherwise -1 if there were any problems parsing the string as a long.
 
     private static long parseLong(String s) {
         try {
             return Long.parseLong(s);
         } catch (NumberFormatException nfe) {
             .error("Unable to parse long value '" + s + "'"nfe);
         }
 
         return -1;
     }

    
Parses a ListBucket response XML document from an input stream.

Parameters:
inputStream XML data input stream.
Returns:
the XML handler object populated with data parsed from the XML stream.
Throws:
com.amazonaws.AmazonClientException
 
             throws IOException {
         ListBucketHandler handler = new ListBucketHandler();
         parseXmlInputStream(handlersanitizeXmlDocument(handlerinputStream));
         return handler;
     }

    
Parses a ListVersions response XML document from an input stream.

Parameters:
inputStream XML data input stream.
Returns:
the XML handler object populated with data parsed from the XML stream.
Throws:
com.amazonaws.AmazonClientException
 
             throws IOException {
         ListVersionsHandler handler = new ListVersionsHandler();
         parseXmlInputStream(handlersanitizeXmlDocument(handlerinputStream));
         return handler;
     }

    
Parses a ListAllMyBuckets response XML document from an input stream.

Parameters:
inputStream XML data input stream.
Returns:
the XML handler object populated with data parsed from the XML stream.
Throws:
com.amazonaws.AmazonClientException
 
             throws IOException {
         ListAllMyBucketsHandler handler = new ListAllMyBucketsHandler();
         parseXmlInputStream(handlersanitizeXmlDocument(handlerinputStream));
         return handler;
     }

    
Parses an AccessControlListHandler response XML document from an input stream.

Parameters:
inputStream XML data input stream.
Returns:
the XML handler object populated with data parsed from the XML stream.
Throws:
com.amazonaws.AmazonClientException
 
             throws IOException {
         AccessControlListHandler handler = new AccessControlListHandler();
         parseXmlInputStream(handlerinputStream);
         return handler;
     }

    
Parses a LoggingStatus response XML document for a bucket from an input stream.

Parameters:
inputStream XML data input stream.
Returns:
the XML handler object populated with data parsed from the XML stream.
Throws:
com.amazonaws.AmazonClientException
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
     public String parseBucketLocationResponse(InputStream inputStream)
             throws IOException {
         BucketLocationHandler handler = new BucketLocationHandler();
         parseXmlInputStream(handlerinputStream);
         return handler.getLocation();
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         DeleteObjectsHandler handler = new DeleteObjectsHandler();
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         CopyObjectResultHandler handler = new CopyObjectResultHandler();
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
             throws IOException {
         ListMultipartUploadsHandler handler = new ListMultipartUploadsHandler();
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
     public ListPartsHandler parseListPartsResponse(InputStream inputStream)
             throws IOException {
         ListPartsHandler handler = new ListPartsHandler();
         parseXmlInputStream(handlerinputStream);
         return handler;
     }


    

Parameters:
inputStream
Returns:
true if the bucket's is configured as Requester Pays, false if it is configured as Owner pays.
Throws:
com.amazonaws.AmazonClientException
 
             throws IOException {
         parseXmlInputStream(handlerinputStream);
         return handler;
     }
 
     // ////////////
     // Handlers //
     // ////////////
 
    
Handler for ListBucket response XML documents.
 
     public static class ListBucketHandler extends AbstractHandler {
         private final ObjectListing objectListing = new ObjectListing();
 
         private S3ObjectSummary currentObject = null;
         private Owner currentOwner = null;
         private String lastKey = null;
 
         public ObjectListing getObjectListing() {
             return ;
         }
 
         @Override
         protected void doStartElement(
                 String uri,
                 String name,
                 String qName,
                 Attributes attrs) {
 
             if (in("ListBucketResult")) {
                 if (name.equals("Contents")) {
                      = new S3ObjectSummary();
                     .setBucketName(.getBucketName());
                 }
             }
 
             else if (in("ListBucketResult""Contents")) {
                 if (name.equals("Owner")) {
                      = new Owner();
                 }
             }
         }
 
         @Override
         protected void doEndElement(String uriString nameString qName) {
             if (atTopLevel()) {
                 if (name.equals("ListBucketResult")) {
                     /*
                      * S3 only includes the NextMarker XML element if the
                      * request specified a delimiter, but for consistency we'd
                      * like to always give easy access to the next marker if
                      * we're returning a list of results that's truncated.
                      */
                     if (.isTruncated()
                         && .getNextMarker() == null) {
 
                         String nextMarker = null;
                         if (!.getObjectSummaries().isEmpty()) {
                             nextMarker = .getObjectSummaries()
                                 .get(.getObjectSummaries().size() - 1)
                                 .getKey();
 
                         } else if (!.getCommonPrefixes().isEmpty()) {
                             nextMarker = .getCommonPrefixes()
                                 .get(.getCommonPrefixes().size() - 1);
                         } else {
                             .error("S3 response indicates truncated results, "
                                     + "but contains no object summaries or "
                                     + "common prefixes.");
                         }
 
                         .setNextMarker(nextMarker);
                     }
                 }
             }
 
             else if (in("ListBucketResult")) {
                 if (name.equals("Name")) {
                     .setBucketName(getText());
                     if (.isDebugEnabled()) {
                         .debug("Examining listing for bucket: "
                                 + .getBucketName());
                     }
 
                 } else if (name.equals("Prefix")) {
                     .setPrefix(checkForEmptyString(getText()));
 
                 } else if (name.equals("Marker")) {
                     .setMarker(checkForEmptyString(getText()));
 
                 } else if (name.equals("NextMarker")) {
                     .setNextMarker(getText());
 
                 } else if (name.equals("MaxKeys")) {
                     .setMaxKeys(parseInt(getText()));
 
                 } else if (name.equals("Delimiter")) {
                     .setDelimiter(checkForEmptyString(getText()));
 
                 } else if (name.equals("EncodingType")) {
                     .setEncodingType(checkForEmptyString(getText()));
 
                 } else if (name.equals("IsTruncated")) {
                     String isTruncatedStr =
                         getText().toLowerCase(Locale.getDefault());
 
                     if (isTruncatedStr.startsWith("false")) {
                         .setTruncated(false);
                     } else if (isTruncatedStr.startsWith("true")) {
                         .setTruncated(true);
                     } else {
                         throw new IllegalStateException(
                                 "Invalid value for IsTruncated field: "
                                 + isTruncatedStr);
                     }
 
                 } else if (name.equals("Contents")) {
                     .getObjectSummaries().add();
                      = null;
                 }
             }
 
             else if (in("ListBucketResult""Contents")) {
                 if (name.equals("Key")) {
                      = getText();
                     .setKey();
 
                 } else if (name.equals("LastModified")) {
                     .setLastModified(
                             ServiceUtils.parseIso8601Date(getText()));
 
                 } else if (name.equals("ETag")) {
                     .setETag(
                             ServiceUtils.removeQuotes(getText()));
 
                 } else if (name.equals("Size")) {
                     .setSize(parseLong(getText()));
 
                 } else if (name.equals("StorageClass")) {
                     .setStorageClass(getText());
 
                 } else if (name.equals("Owner")) {
                     .setOwner();
                      = null;
                 }
             }
 
             else if (in("ListBucketResult""Contents""Owner")) {
                 if (name.equals("ID")) {
                     .setId(getText());
 
                 } else if (name.equals("DisplayName")) {
                     .setDisplayName(getText());
                 }
             }
 
             else if (in("ListBucketResult""CommonPrefixes")) {
                 if (name.equals("Prefix")) {
                     .getCommonPrefixes().add(getText());
                 }
             }
         }
     }

    
Handler for ListAllMyBuckets response XML documents. The document is parsed into com.amazonaws.services.s3.model.Buckets available via the getBuckets() method.
 
     public static class ListAllMyBucketsHandler extends AbstractHandler {
 
         private final List<Bucketbuckets = new ArrayList<Bucket>();
         private Owner bucketsOwner = null;
 
         private Bucket currentBucket = null;

        

Returns:
the buckets listed in the document.
 
         public List<BucketgetBuckets() {
             return ;
         }

        

Returns:
the owner of the buckets.
 
         public Owner getOwner() {
             return ;
         }
 
         @Override
         protected void doStartElement(
                 String uri,
                 String name,
                 String qName,
                 Attributes attrs) {
 
             if (in("ListAllMyBucketsResult")) {
                 if (name.equals("Owner")) {
                      = new Owner();
                 }
             } else if (in("ListAllMyBucketsResult""Buckets")) {
                 if (name.equals("Bucket")) {
                      = new Bucket();
                     .setOwner();
                 }
             }
         }
 
         @Override
         protected void doEndElement(String uriString nameString qName) {
             if (in("ListAllMyBucketsResult""Owner")) {
                 if (name.equals("ID")) {
                     .setId(getText());
 
                 } else if (name.equals("DisplayName")) {
                     .setDisplayName(getText());
                 }
             }
 
             else if (in("ListAllMyBucketsResult""Buckets")) {
                 if (name.equals("Bucket")) {
                     .add();
                      = null;
                 }
             }
 
             else if (in("ListAllMyBucketsResult""Buckets""Bucket")) {
                 if (name.equals("Name")) {
                     .setName(getText());
 
                 } else if (name.equals("CreationDate")) {
                     Date creationDate = DateUtils.parseISO8601Date(getText());
                     .setCreationDate(creationDate);
                 }
             }
         }
     }

    
Handler for AccessControlList response XML documents. The document is parsed into an com.amazonaws.services.s3.model.AccessControlList object available via the getAccessControlList() method.
 
     public static class AccessControlListHandler extends AbstractHandler {
 
         private final AccessControlList accessControlList =
             new AccessControlList();
 
         private Grantee currentGrantee = null;
         private Permission currentPermission = null;

        

Returns:
an object representing the ACL document.
 
         public AccessControlList getAccessControlList() {
             return ;
         }
 
         @Override
         protected void doStartElement(
                 String uri,
                 String name,
                 String qName,
                 Attributes attrs) {
 
             if (in("AccessControlPolicy")) {
                 if (name.equals("Owner")) {
                     .setOwner(new Owner());
 
                 }
             }
 
             else if (in("AccessControlPolicy""AccessControlList""Grant")) {
                 if (name.equals("Grantee")) {
                     String type = XmlResponsesSaxParser
                         .findAttributeValue"xsi:type"attrs );
 
                     if ("AmazonCustomerByEmail".equals(type)) {
                          = new EmailAddressGrantee(null);
                     } else if ("CanonicalUser".equals(type)) {
                          = new CanonicalGrantee(null);
                     } else if ("Group".equals(type)) {
                         /*
                          * Nothing to do for GroupGrantees here since we
                          * can't construct an empty enum value early.
                          */
                     }
                 }
             }
         }
 
         @Override
         protected void doEndElement(String uriString nameString qName) {
             if (in("AccessControlPolicy""Owner")) {
                 if (name.equals("ID")) {
                     .getOwner().setId(getText());
                 } else if (name.equals("DisplayName")) {
                     .getOwner().setDisplayName(getText());
                 }
             }
 
             else if (in("AccessControlPolicy""AccessControlList")) {
                 if (name.equals("Grant")) {
                     .grantPermission(
                             );
 
                      = null;
                      = null;
                 }
             }
 
             else if (in("AccessControlPolicy""AccessControlList""Grant")) {
                 if (name.equals("Permission")) {
                      = Permission.parsePermission(getText());
                 }
             }
 
             else if (in("AccessControlPolicy""AccessControlList""Grant""Grantee")) {
                 if (name.equals("ID")) {
                     .setIdentifier(getText());
 
                 } else if (name.equals("EmailAddress")) {
                     .setIdentifier(getText());
 
                 } else if (name.equals("URI")) {
                     /*
                      * Only GroupGrantees contain an URI element in them, and we
                      * can't construct currentGrantee during startElement for a
                      * GroupGrantee since it's an enum.
                      */
                      = GroupGrantee.parseGroupGrantee(getText());
 
                 } else if (name.equals("DisplayName")) {
                     ((CanonicalGrantee)
                         .setDisplayName(getText());
                 }
             }
         }
     }

    
Handler for LoggingStatus response XML documents for a bucket. The document is parsed into an com.amazonaws.services.s3.model.BucketLoggingConfiguration object available via the getBucketLoggingConfiguration() method.
 
     public static class BucketLoggingConfigurationHandler extends AbstractHandler {
 
         private final BucketLoggingConfiguration bucketLoggingConfiguration =
                 new BucketLoggingConfiguration();

        

Returns:
an object representing the bucket's LoggingStatus document.
 
             return ;
         }
 
         @Override
         protected void doStartElement(
                 String uri,
                 String name,
                 String qName,
                 Attributes attrs) {
 
         }
 
         @Override
         protected void doEndElement(String uriString nameString qName) {
             if (in("BucketLoggingStatus""LoggingEnabled")) {
                 if (name.equals("TargetBucket")) {
                     
                         .setDestinationBucketName(getText());
 
                 } else if (name.equals("TargetPrefix")) {
                     
                         .setLogFilePrefix(getText());
                 }
             }
         }
     }

    
Handler for CreateBucketConfiguration response XML documents for a bucket. The document is parsed into a String representing the bucket's location, available via the getLocation() method.
 
     public static class BucketLocationHandler extends AbstractHandler {
 
         private String location = null;

        

Returns:
the bucket's location.
 
         public String getLocation() {
             return ;
         }
 
         @Override
         protected void doStartElement(
                 String uri,
                 String name,
                 String qName,
                 Attributes attrs) {
 
         }
 
         @Override
         protected void doEndElement(String uriString nameString qName) {
             if (atTopLevel()) {
                 if (name.equals("LocationConstraint")) {
                     String elementText = getText();
                     if (elementText.length() == 0) {
                          = null;
                     } else {
                          = elementText;
                     }
                 }
             }
         }
     }
 
     public static class CopyObjectResultHandler extends AbstractSSEHandler implements ObjectExpirationResult {
 
         // Data items for successful copy
         private final CopyObjectResult result = new CopyObjectResult();
 
         // Data items for failed copy
         private String errorCode = null;
         private String errorMessage = null;
         private String errorRequestId = null;
         private String errorHostId = null;
         private boolean receivedErrorResponse = false;
 
         @Override
         protected ServerSideEncryptionResult sseResult() {
             return ;
         }
 
         public Date getLastModified() {
             return .getLastModifiedDate();
         }
 
         public String getVersionId() {
             return .getVersionId();
         }
 
         public void setVersionId(String versionId) {
             .setVersionId(versionId);
         }
 
         @Override
         public Date getExpirationTime() {
             return .getExpirationTime();
         }
 
         @Override
         public void setExpirationTime(Date expirationTime) {
             .setExpirationTime(expirationTime);
         }
 
         @Override
         public String getExpirationTimeRuleId() {
             return .getExpirationTimeRuleId();
         }
 
         @Override
         public void setExpirationTimeRuleId(String expirationTimeRuleId) {
             .setExpirationTimeRuleId(expirationTimeRuleId);
         }
 
         public String getETag() {
             return .getETag();
         }
 
         public String getErrorCode() {
             return ;
         }
 
         public String getErrorHostId() {
             return ;
         }
 
         public String getErrorMessage() {
             return ;
         }
 
         public String getErrorRequestId() {
             return ;
         }
 
         public boolean isErrorResponse() {
             return ;
         }
 
         @Override
         protected void doStartElement(
                 String uri,
                 String name,
                 String qName,
                 Attributes attrs) {
 
             if (atTopLevel()) {
                 if (name.equals("CopyObjectResult") || name.equals("CopyPartResult")) {
                      = false;
                 } else if (name.equals("Error")) {
                      = true;
                 }
             }
         }
 
         @Override
         protected void doEndElement(String uriString nameString qName) {
             if (in("CopyObjectResult") || in ("CopyPartResult")) {
                 if (name.equals("LastModified")) {
                     .setLastModifiedDate(ServiceUtils.parseIso8601Date(getText()));
                 } else if (name.equals("ETag")) {
                    .setETag(ServiceUtils.removeQuotes(getText()));
                }
            }
            else if (in("Error")) {
                if (name.equals("Code")) {
                     = getText();
                } else if (name.equals("Message")) {
                     = getText();
                } else if (name.equals("RequestId")) {
                     = getText();
                } else if (name.equals("HostId")) {
                     = getText();
                }
            }
        }
    }

    
Handler for parsing RequestPaymentConfiguration XML response associated with an Amazon S3 bucket. The XML response is parsed into a RequestPaymentConfiguration object.
    public static class RequestPaymentConfigurationHandler extends AbstractHandler {
        private String payer = null;
            return new RequestPaymentConfiguration(Payer.valueOf());
        }
        @Override
        protected void doStartElement(
                String uri,
                String name,
                String qName,
                Attributes attrs) {
        }
        @Override
        protected void doEndElement(String uriString nameString qName) {
            if (in("RequestPaymentConfiguration")) {
                if (name.equals("Payer")) {
                     = getText();
                }
            }
        }
    }

    
Handler for ListVersionsResult XML document.
    public static class ListVersionsHandler extends AbstractHandler {
        private final VersionListing versionListing = new VersionListing();
        private S3VersionSummary currentVersionSummary;
        private Owner currentOwner;
        public VersionListing getListing() {
            return ;
        }
        @Override
        protected void doStartElement(
                String uri,
                String name,
                String qName,
                Attributes attrs) {
            if (in("ListVersionsResult")) {
                if (name.equals("Version")) {
                     = new S3VersionSummary();
                    .setBucketName(
                            .getBucketName());
                } else if (name.equals("DeleteMarker")) {
                     = new S3VersionSummary();
                    .setBucketName(
                            .getBucketName());
                    .setIsDeleteMarker(true);
                }
            }
            else if (in("ListVersionsResult""Version")
                    || in("ListVersionsResult""DeleteMarker")) {
                if (name.equals("Owner")) {
                     = new Owner();
                }
            }
        }
        @Override
        protected void doEndElement(
                String uri,
                String name,
                String qName) {
            if (in("ListVersionsResult")) {
                if (name.equals("Name")) {
                    .setBucketName(getText());
                } else if (name.equals("Prefix")) {
                    .setPrefix(checkForEmptyString(getText()));
                } else if (name.equals("KeyMarker")) {
                    .setKeyMarker(checkForEmptyString(getText()));
                } else if (name.equals("VersionIdMarker")) {
                    .setVersionIdMarker(checkForEmptyString(
                            getText()));
                } else if (name.equals("MaxKeys")) {
                    .setMaxKeys(Integer.parseInt(getText()));
                } else if (name.equals("Delimiter")) {
                    .setDelimiter(checkForEmptyString(getText()));
                } else if (name.equals("EncodingType")) {
                    .setEncodingType(checkForEmptyString(
                            getText()));
                } else if (name.equals("NextKeyMarker")) {
                    .setNextKeyMarker(getText());
                } else if (name.equals("NextVersionIdMarker")) {
                    .setNextVersionIdMarker(getText());
                } else if (name.equals("IsTruncated")) {
                    .setTruncated("true".equals(getText()));
                } else if (name.equals("Version")
                        || name.equals("DeleteMarker")) {
                    .getVersionSummaries()
                        .add();
                     = null;
                }
            }
            else if (in("ListVersionsResult""CommonPrefixes")) {
                if (name.equals("Prefix")) {
                    .getCommonPrefixes()
                        .add(checkForEmptyString(getText()));
                }
            }