本文整理汇总了Java中org.apache.axiom.om.util.StAXUtils.createXMLStreamWriter方法的典型用法代码示例。如果您正苦于以下问题:Java StAXUtils.createXMLStreamWriter方法的具体用法?Java StAXUtils.createXMLStreamWriter怎么用?Java StAXUtils.createXMLStreamWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.util.StAXUtils
的用法示例。
在下文中一共展示了StAXUtils.createXMLStreamWriter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStringXML
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
* Util method to convert the pullstream to a string
*
* @param reader
* @return
*/
private String getStringXML(XMLStreamReader reader) throws XMLStreamException {
//the returned pullparser starts at an Element rather than the start
//document event. This is somewhat disturbing but since an ADBBean
//denotes an XMLFragment, it is justifiable to keep the current event
//at the Start-element rather than the start document
//What it boils down to is that we need to wrap the reader in a
//stream wrapper to get a fake start-document event
StreamingOMSerializer ser = new StreamingOMSerializer();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);
ser.serialize(
new StreamWrapper(reader),
writer);
writer.flush();
return byteArrayOutputStream.toString();
}
示例2: getInputObject
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
protected Object[] getInputObject(List inputObjects, Operation operation)
throws XMLStreamException, XmlSerializingException, XmlParsingException {
StringWriter inputStringWriter = new StringWriter();
XMLStreamWriter inputXmlStreamWriter = StAXUtils.createXMLStreamWriter(inputStringWriter);
this.javaObjectSerializer.serializeInputElement(inputObjects.toArray(),
operation.getInputElement(),
operation.getInputParameters(),
inputXmlStreamWriter);
inputXmlStreamWriter.flush();
String inputXmlString = inputStringWriter.toString();
System.out.println("input Xml String ==> " + inputXmlString);
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(inputXmlString.getBytes()));
Object[] objects = this.xmlStreamParser.getInputParameters(xmlReader, operation);
return objects;
}
示例3: getReturnObject
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
protected Object getReturnObject(Object returnObject, Operation operation)
throws XMLStreamException, XmlSerializingException, XmlParsingException {
// get the response xml serializer
StringWriter outputStringWriter = new StringWriter();
XMLStreamWriter outputXMLStringWriter = StAXUtils.createXMLStreamWriter(outputStringWriter);
this.javaObjectSerializer.serializeOutputElement(returnObject,
operation.getOutPutElement(),
operation.getOutputParameter(),
outputXMLStringWriter);
outputXMLStringWriter.flush();
String outputXmlString = outputStringWriter.toString();
System.out.println("output Xml String ==> " + outputXmlString);
XMLStreamReader outputXmlReader =
StAXUtils.createXMLStreamReader(new ByteArrayInputStream(outputXmlString.getBytes()));
return this.xmlStreamParser.getOutputObject(outputXmlReader, operation);
}
示例4: testMappedSerialize3
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public void testMappedSerialize3() throws XMLStreamException {
String jsonString = getMappedJSONString();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(outStream);
JSONDataSource source = getMappedDataSource(jsonString);
source.serialize(writer);
writer.flush();
assertEquals(
"<?xml version='1.0' encoding='UTF-8'?><mapping><inner><first>test string one</first></inner><inner>test string two</inner><name>foo</name></mapping>",
new String(outStream.toByteArray()));
}
示例5: testBadgerfishSerialize3
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public void testBadgerfishSerialize3() throws XMLStreamException, JSONException, IOException,
ParserConfigurationException, SAXException {
String jsonString = getBadgerfishJSONString();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(outStream);
JSONBadgerfishDataSource source = getBadgerfishDataSource(jsonString);
source.serialize(writer);
writer.flush();
assertXMLEqual(
"<?xml version='1.0' encoding='UTF-8'?><p xmlns=\"http://def.ns\" xmlns:bb=\"http://other.nsb\" xmlns:aa=\"http://other.ns\"><sam att=\"lets\">555</sam></p>",
new String(outStream.toByteArray()));
}
示例6: serialize
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public void serialize(Writer writerTarget, OMOutputFormat format) throws XMLStreamException {
MTOMXMLStreamWriter writer =
new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writerTarget));
writer.setOutputFormat(format);
serialize(writer);
writer.flush();
writer.close();
}
示例7: getAsString
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
* Utility method to write the reader contents to a String
* @return String
*/
public String getAsString() throws XMLStreamException {
StringWriter sw = new StringWriter();
XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(sw);
// Write the reader to the writer
outputTo(writer);
// Flush the writer and get the String
writer.flush();
sw.flush();
String str = sw.toString();
writer.close();
return str;
}
示例8: serialize
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public void serialize(Writer writerTarget, OMOutputFormat format) throws XMLStreamException {
MTOMXMLStreamWriter writer =
new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writerTarget));
writer.setOutputFormat(format);
serialize(writer);
writer.flush();
writer.close();
}
示例9: testSerializeDeserializeWrapped
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
private static void testSerializeDeserializeWrapped(Object bean, Object expectedResult) throws Exception {
StringWriter sw = new StringWriter();
XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(sw);
writer.writeStartElement("", "root", "urn:test");
writer.writeDefaultNamespace("urn:test");
ADBBeanUtil.serialize(bean, writer);
writer.writeEndElement();
writer.flush();
OMElement omElement3 = new StAXOMBuilder(StAXUtils.createXMLStreamReader(new StringReader(sw.toString()))).getDocumentElement();
assertBeanEquals(expectedResult, ADBBeanUtil.parse(bean.getClass(), omElement3.getFirstElement().getXMLStreamReader()));
}
示例10: serialize
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public void serialize(OutputStream outputStream,
OMOutputFormat omOutputFormat) throws XMLStreamException {
XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(outputStream);
serialize(xmlStreamWriter);
xmlStreamWriter.flush();
}
示例11: createWriter
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
* The writer is created lazily.
* If only the output stream is used, then the writer is never created.
*/
private void createWriter() throws XMLStreamException {
if (writer == null) {
writer = StAXUtils.createXMLStreamWriter(os, charSetEncoding);
}
}
示例12: serialize
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
* @param output
* @param format
* @throws XMLStreamException
* @see OMDataSource#serialize(java.io.OutputStream, org.apache.axiom.om.OMOutputFormat)
*/
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
serialize(xmlStreamWriter);
xmlStreamWriter.flush();
}
示例13: serialize
import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
* @param output
* @param format
* @throws javax.xml.stream.XMLStreamException
*
* @see OMDataSource#serialize(java.io.OutputStream, org.apache.axiom.om.OMOutputFormat)
*/
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
serialize(xmlStreamWriter);
xmlStreamWriter.flush();
}