private static void addGrantsIfNotNull(XmlWriter xml, AccessControlList accessControlList) {
        if (accessControlList == null) {
            return;
        }

        AclXmlFactory aclXmlFactory = new AclXmlFactory();
        xml.start("AccessControlList");

        for(Grant grant: accessControlList.getGrantsAsList()) {
            xml.start("Grant");
            if (grant.getGrantee() != null) {
                 aclXmlFactory.convertToXml(grant.getGrantee(), xml);
            }
            addIfNotNull(xml, "Permission", grant.getPermission());
            xml.end();
        }
        xml.end();
    }
Converts the SelectObjectContentRequest to an XML fragment that can be sent to
the SelectObjectContent operation of Amazon S3.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/transform/RequestXmlFactory.java