/** * Adds the specified value as text to the current position of the in * progress XML document. * * @param s * The text to add to the XML document. * * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter value(String s) { append(escapeXMLEntities(s)); return this; }
public Request<CreateQueryLoggingConfigRequest> marshall(CreateQueryLoggingConfigRequest createQueryLoggingConfigRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("CreateQueryLoggingConfigRequest"); if (createQueryLoggingConfigRequest != null) { xmlWriter.startElement("HostedZoneId").value(createQueryLoggingConfigRequest.getHostedZoneId()).endElement(); xmlWriter.startElement("CloudWatchLogsLogGroupArn").value(createQueryLoggingConfigRequest.getCloudWatchLogsLogGroupArn()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
@Test public void testEscapeXMLEntitiesProperlyEscapedFromString() { String expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>quote "" apostrophe '' lessthan << greaterthan >> ampersand &&</Test>"; StringWriter sw = new StringWriter(); XMLWriter xw = new XMLWriter(sw); xw.startElement("Test"); xw.value("quote "\" apostrophe '' lessthan << greaterthan >> ampersand &&"); xw.endElement(); sw.flush(); assertEquals(sw.toString(), expectedString); }
/** * Creates a new XMLWriter, ready to write an XML document to the specified * writer. The root element in the XML document will specify an xmlns * attribute with the specified namespace parameter. * * @param w * The writer this XMLWriter will write to. * @param xmlns * The XML namespace to include in the xmlns attribute of the * root element. */ public XMLWriter(Writer w, String xmlns) { this.writer = w; this.xmlns = xmlns; append(PROLOG); }
@Test public void testEscapeXMLEntitiesProperlyEscapedFromObject() { final String objectValue = "quote "" apostrophe '' lessthan << greaterthan >> ampersand &&"; String expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>" + objectValue + "</Test>"; Object objectToWrite = new Object() { @Override public String toString() { return objectValue; } }; StringWriter sw = new StringWriter(); XMLWriter xw = new XMLWriter(sw); xw.startElement("Test"); xw.value(objectToWrite); xw.endElement(); sw.flush(); assertEquals(sw.toString(), expectedString); }
/** * Starts a new element with the specified name at the current position in * the in-progress XML document. * * @param element * The name of the new element. * * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter startElement(String element) { append("<" + element); if (rootElement && xmlns != null) { append(" xmlns=\"" + xmlns + "\""); rootElement = false; } append(">"); elementStack.push(element); return this; }
public Request<CreateReusableDelegationSetRequest> marshall(CreateReusableDelegationSetRequest createReusableDelegationSetRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); "AmazonRoute53"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("CreateReusableDelegationSetRequest"); if (createReusableDelegationSetRequest != null) { xmlWriter.startElement("CallerReference").value(createReusableDelegationSetRequest.getCallerReference()).endElement(); xmlWriter.startElement("HostedZoneId").value(createReusableDelegationSetRequest.getHostedZoneId()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
@Test public void testXMLWriterWithDates() { Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2015, 4, 24); Date date = cal.getTime(); String expectedString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Test>" + StringUtils.fromDate(date) + "</Test>"; StringWriter sw = new StringWriter(); XMLWriter xw = new XMLWriter(sw); xw.startElement("Test"); xw.value(date); xw.endElement(); sw.flush(); assertEquals(sw.toString(), expectedString); }
/** * Adds the string representation of the specified object to the current * position of the in progress XML document. * * @param obj * The object to translate to a string and add to the XML * document. * * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter value(Object obj) { append(escapeXMLEntities(obj.toString())); return this; }
/** * Creates a new XMLWriter, ready to write an XML document to the specified * writer. The root element in the XML document will specify an xmlns * attribute with the specified namespace parameter. * * @param w The writer this XMLWriter will write to. * @param xmlns The XML namespace to include in the xmlns attribute of the * root element. */ public XMLWriter(Writer w, String xmlns) { this.writer = w; this.xmlns = xmlns; append(PROLOG); }
public Request<CreateTrafficPolicyRequest> marshall(CreateTrafficPolicyRequest createTrafficPolicyRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("CreateTrafficPolicyRequest"); if (createTrafficPolicyRequest != null) { xmlWriter.startElement("Name").value(createTrafficPolicyRequest.getName()).endElement(); xmlWriter.startElement("Document").value(createTrafficPolicyRequest.getDocument()).endElement(); xmlWriter.startElement("Comment").value(createTrafficPolicyRequest.getComment()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
/** * Adds the specified date as text to the current position of the * in-progress XML document. * * @param date * The date to add to the XML document. * * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter value(Date date) { append(escapeXMLEntities(StringUtils.fromDate(date))); return this; }
/** * Creates a new XMLWriter, ready to write an XML document to the specified * writer. The root element in the XML document will specify an xmlns * attribute with the specified namespace parameter. * * @param w * The writer this XMLWriter will write to. * @param xmlns * The XML namespace to include in the xmlns attribute of the * root element. */ public XMLWriter(Writer w, String xmlns) { this.writer = w; this.xmlns = xmlns; append(PROLOG); }
public Request<CreateCloudFrontOriginAccessIdentityRequest> marshall(CreateCloudFrontOriginAccessIdentityRequest createCloudFrontOriginAccessIdentityRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); createCloudFrontOriginAccessIdentityRequest, "AmazonCloudFront"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "http://cloudfront.amazonaws.com/doc/2018-11-05/"); xmlWriter.startElement("CloudFrontOriginAccessIdentityConfig"); xmlWriter.startElement("CallerReference").value(cloudFrontOriginAccessIdentityConfig.getCallerReference()).endElement(); xmlWriter.startElement("Comment").value(cloudFrontOriginAccessIdentityConfig.getComment()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
/** * Adds the specified value as Base64 encoded text to the current position of the in * progress XML document. * * @param b * The binary data to add to the XML document. * * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter value(ByteBuffer b) { append(escapeXMLEntities(Base64.encodeAsString(BinaryUtils.copyBytesFrom(b)))); return this; }
/** * Starts a new element with the specified name at the current position in * the in-progress XML document. * * @param element The name of the new element. * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter startElement(String element) { append("<" + element); if (rootElement && xmlns != null) { append(" xmlns=\"" + xmlns + "\""); rootElement = false; } append(">"); elementStack.push(element); return this; }
public Request<UpdateHostedZoneCommentRequest> marshall(UpdateHostedZoneCommentRequest updateHostedZoneCommentRequest) { if (updateHostedZoneCommentRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<UpdateHostedZoneCommentRequest> request = new DefaultRequest<UpdateHostedZoneCommentRequest>(updateHostedZoneCommentRequest, "AmazonRoute53"); request.setHttpMethod(HttpMethodName.POST); String uriResourcePath = "/2013-04-01/hostedzone/{Id}"; uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", updateHostedZoneCommentRequest.getId()); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("UpdateHostedZoneCommentRequest"); if (updateHostedZoneCommentRequest != null) { if (updateHostedZoneCommentRequest.getComment() != null) { xmlWriter.startElement("Comment").value(updateHostedZoneCommentRequest.getComment()).endElement(); } } xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); } } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t); } return request; }
/** * Adds the specified value as text to the current position of the in * progress XML document. * * @param s The text to add to the XML document. * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter value(String s) { append(escapeXMLEntities(s)); return this; }
/** * Starts a new element with the specified name at the current position in * the in-progress XML document. * * @param element * The name of the new element. * * @return This XMLWriter so that additional method calls can be chained * together. */ public XMLWriter startElement(String element) { append("<" + element); if (rootElement && xmlns != null) { append(" xmlns=\"" + xmlns + "\""); rootElement = false; } append(">"); elementStack.push(element); return this; }
public Request<CreateTrafficPolicyVersionRequest> marshall(CreateTrafficPolicyVersionRequest createTrafficPolicyVersionRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); "AmazonRoute53"); request.setHttpMethod(HttpMethodName.POST); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", createTrafficPolicyVersionRequest.getId()); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("CreateTrafficPolicyVersionRequest"); if (createTrafficPolicyVersionRequest != null) { xmlWriter.startElement("Document").value(createTrafficPolicyVersionRequest.getDocument()).endElement(); xmlWriter.startElement("Comment").value(createTrafficPolicyVersionRequest.getComment()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);