/** * Converts the specified accelerate configuration into an XML byte array. * * @param accelerateConfiguration * The configuration to convert. * * @return The XML byte array representation. */ public byte[] convertToXmlByteArray(BucketAccelerateConfiguration accelerateConfiguration) { XmlWriter xml = new XmlWriter(); xml.start("AccelerateConfiguration", "xmlns", Constants.XML_NAMESPACE); xml.start("Status").value(accelerateConfiguration.getStatus()).end(); xml.end(); return xml.getBytes(); }
public byte[] getBytes() { assert(tags.size() == 0); return this.toString().getBytes(UTF8); }
public XmlWriter value(String value) { appendEscapedString(value, sb); return this; }
@Test public void testEscapedCharacters() { XmlWriter w = new XmlWriter(); String[] attrs = { "tab", "newLine", "return", "ampersand", "quote", "lessthan", "greaterthan" }; String[] values = { "\t", "\n", "\r", "&", "\"", "<", ">" }; w.start("test", attrs, values); w.end(); String expected = "<test tab=\"	\" newLine=\" \" return=\" \" ampersand=\"&\" quote=\""\" lessthan=\"<\" greaterthan=\">\"></test>"; assertEquals(expected, w.toString()); }
public XmlWriter start(String name, String attr, String value) { sb.append("<").append(name); writeAttr(attr, value); sb.append(">"); tags.add(name); return this; }
public XmlWriter start(String name, String[] attrs, String[] values) { sb.append("<").append(name); for (int i = 0; i < Math.min(attrs.length, values.length); i++) { writeAttr(attrs[i], values[i]); } sb.append(">"); tags.add(name); return this; }
public byte[] convertToXmlByteArray(ObjectTagging tagging) { XmlWriter writer = new XmlWriter(); writer.start("Tagging").start("TagSet"); for (Tag tag : tagging.getTagSet()) { writer.start("Tag"); writer.start("Key").value(tag.getKey()).end(); writer.start("Value").value(tag.getValue()).end(); writer.end(); // </Tag> } writer.end(); // </TagSet> writer.end(); // </Tagging> return writer.getBytes(); } }
private void writeAttr(String name, String value) { sb.append(' ').append(name).append("=\""); appendEscapedString(value, sb); sb.append("\""); }
/** * Begins writing with the specified name, attr, and value. * @param name the name * @param attr the attr * @param value the vaule * @return an instance of XmlWriter. */ public XmlWriter start(String name, String attr, String value) { sb.append("<").append(name); writeAttr(attr, value); sb.append(">"); tags.add(name); return this; }
/** * Gets the byte. * @return the byte[] of the XML. */ public byte[] getBytes() { assert (tags.size() == 0); return this.toString().getBytes(UTF8); }
public byte[] convertToXmlByteArray(ServerSideEncryptionConfiguration sseConfig) { XmlWriter xml = new XmlWriter(); xml.start("ServerSideEncryptionConfiguration", "xmlns", Constants.XML_NAMESPACE); for (ServerSideEncryptionRule rule : sseConfig.getRules()) { xml.start("Rule"); writeServerSideEncryptionByDefault(xml, rule.getApplyServerSideEncryptionByDefault()); xml.end(); } xml.end(); return xml.getBytes(); }
/** * Appends the specified value. * @param value value to be appended * @return an instance of XmlWriter. */ public XmlWriter value(String value) { appendEscapedString(value, sb); return this; }