本文整理汇总了Java中org.jibx.runtime.IMarshallingContext.setIndent方法的典型用法代码示例。如果您正苦于以下问题:Java IMarshallingContext.setIndent方法的具体用法?Java IMarshallingContext.setIndent怎么用?Java IMarshallingContext.setIndent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jibx.runtime.IMarshallingContext
的用法示例。
在下文中一共展示了IMarshallingContext.setIndent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toXML
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
public void toXML(ModelDefinition.XMLBindingType bindingType, OutputStream xml)
{
try
{
if(bindingType == null)
{
bindingType = ModelDefinition.XMLBindingType.DEFAULT;
}
String bindingName = bindingType.toString();
IBindingFactory factory = (bindingName != null) ? BindingDirectory.getFactory(bindingName, M2Model.class) :
BindingDirectory.getFactory("default", M2Model.class);
IMarshallingContext context = factory.createMarshallingContext();
context.setIndent(4);
context.marshalDocument(this, "UTF-8", null, xml);
}
catch(JiBXException e)
{
throw new DictionaryException(ERR_CREATE_M2MODEL_FAILURE, e);
}
}
示例2: toXML
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
/**
* Create XML representation of System Info
*
* @param xml xml representation of system info
*/
public void toXML(OutputStream xml)
{
try
{
IBindingFactory factory = BindingDirectory.getFactory(SystemInfo.class);
IMarshallingContext context = factory.createMarshallingContext();
context.setIndent(4);
context.marshalDocument(this, "UTF-8", null, xml);
}
catch(JiBXException e)
{
throw new DictionaryException("Failed to create System Info", e);
}
}
示例3: encode2Xml
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
private String encode2Xml(Order order) throws JiBXException, IOException {
factory = BindingDirectory.getFactory(Order.class);
writer = new StringWriter();
IMarshallingContext mctx = factory.createMarshallingContext();
mctx.setIndent(2);
mctx.marshalDocument(order, CHARSET_NAME, null, writer);
String xmlStr = writer.toString();
writer.close();
System.out.println(xmlStr.toString());
return xmlStr;
}
示例4: encode0
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
protected ByteBuf encode0(ChannelHandlerContext ctx, Object body)
throws Exception {
factory = BindingDirectory.getFactory(body.getClass());
writer = new StringWriter();
IMarshallingContext mctx = factory.createMarshallingContext();
mctx.setIndent(2);
mctx.marshalDocument(body, CHARSET_NAME, null, writer);
String xmlStr = writer.toString();
writer.close();
writer = null;
ByteBuf encodeBuf = Unpooled.copiedBuffer(xmlStr, UTF_8);
return encodeBuf;
}
示例5: encode0
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
protected ByteBuf encode0(ChannelHandlerContext ctx, Object body)
throws Exception {
factory = BindingDirectory.getFactory(body.getClass());
writer = new StringWriter();
IMarshallingContext mctx = factory.createMarshallingContext();
mctx.setIndent(2);
mctx.marshalDocument(body, CHARSET_NAME, null, writer);
String xmlStr = writer.toString();
writer.close();
writer = null;
ByteBuf encodeBuf = Unpooled.copiedBuffer(xmlStr, UTF_8);
return encodeBuf;
}
示例6: write
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
public void write () throws JiBXException, IOException
{
IBindingFactory bfact = BindingDirectory.getFactory(Astrogation.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(4);
if (useCompressedFile)
{
mctx.marshalDocument(data, "UTF-8", null, new GZIPOutputStream(new FileOutputStream(outputFile)));
}
else
{
mctx.marshalDocument(data, "UTF-8", null, new FileOutputStream(outputFile));
}
}
示例7: createMarshallingContext
import org.jibx.runtime.IMarshallingContext; //导入方法依赖的package包/类
/**
* Create a new {@code IMarshallingContext}, configured with the correct indentation.
* @return the created marshalling context
* @throws JiBXException in case of errors
*/
protected IMarshallingContext createMarshallingContext() throws JiBXException {
IMarshallingContext marshallingContext = this.bindingFactory.createMarshallingContext();
marshallingContext.setIndent(this.indent);
return marshallingContext;
}