本文整理汇总了Java中org.jibx.runtime.IMarshallingContext类的典型用法代码示例。如果您正苦于以下问题:Java IMarshallingContext类的具体用法?Java IMarshallingContext怎么用?Java IMarshallingContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMarshallingContext类属于org.jibx.runtime包,在下文中一共展示了IMarshallingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: marshall
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
public String marshall(XmlAction action) {
// marshall:
// marshal to StringBuffer:
StringWriter writer = new StringWriter();
IMarshallingContext m = XmlBindingTools.getInstance()
.createMarshaller();
try {
m.marshalDocument(action, "UTF-8", null, writer);
} catch (JiBXException e) {
freemind.main.Resources.getInstance().logException(e);
return null;
}
String result = writer.toString();
return result;
}
示例3: 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);
}
}
示例4: marshalOutputStream
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
@Override
protected void marshalOutputStream(Object graph, OutputStream outputStream)
throws XmlMappingException, IOException {
try {
IMarshallingContext marshallingContext = createMarshallingContext();
marshallingContext.startDocument(this.encoding, this.standalone, outputStream);
marshalDocument(marshallingContext, graph);
}
catch (JiBXException ex) {
throw convertJibxException(ex, true);
}
}
示例5: marshalWriter
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
@Override
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
try {
IMarshallingContext marshallingContext = createMarshallingContext();
marshallingContext.startDocument(this.encoding, this.standalone, writer);
marshalDocument(marshallingContext, graph);
}
catch (JiBXException ex) {
throw convertJibxException(ex, true);
}
}
示例6: marshalDocument
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
private void marshalDocument(IMarshallingContext marshallingContext, Object graph) throws IOException, JiBXException {
if (StringUtils.hasLength(docTypeRootElementName)) {
IXMLWriter xmlWriter = marshallingContext.getXmlWriter();
xmlWriter.writeDocType(docTypeRootElementName, docTypeSystemId, docTypePublicId, docTypeInternalSubset);
}
marshallingContext.marshalDocument(graph);
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: createMarshaller
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
public IMarshallingContext createMarshaller() {
try {
return mBindingFactory.createMarshallingContext();
} catch (JiBXException e) {
freemind.main.Resources.getInstance().logException(e);
return null;
}
}
示例11: serialize
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
try {
// marshal with all namespace declarations, since external state unknown
IMarshallingContext ctx = bindingFactory.createMarshallingContext();
ctx.setOutput(output, format == null ? null : format.getCharSetEncoding());
marshal(true, ctx);
} catch (JiBXException e) {
throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
}
}
示例12: testSimpleStyle
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
@Test
public void testSimpleStyle() throws JiBXException {
FillInfo fillInfo = StyleUtil.createFill("#FFFF00", 0.5f);
StrokeInfo strokeInfo = StyleUtil.createStroke("red", 3, 0.5f, "3 4");
PolygonSymbolizerInfo polygonSymbolizerInfo = StyleUtil.createPolygonSymbolizer(fillInfo, strokeInfo);
RuleInfo ruleInfo = StyleUtil.createRule("myTitle", "myName", polygonSymbolizerInfo);
IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
StringWriter sw = new StringWriter();
mctx.setOutput(sw);
mctx.marshalDocument(ruleInfo);
Assert.assertEquals(
"<sld:Rule xmlns:sld=\"http://www.opengis.net/sld\">" +
"<sld:Name>myName</sld:Name>" +
"<sld:Title>myTitle</sld:Title>" +
"<sld:PolygonSymbolizer>" +
"<sld:Fill>" +
"<sld:CssParameter name=\"fill\">#FFFF00</sld:CssParameter>" +
"<sld:CssParameter name=\"fill-opacity\">0.5</sld:CssParameter>" +
"</sld:Fill>" +
"<sld:Stroke>" +
"<sld:CssParameter name=\"stroke\">red</sld:CssParameter>" +
"<sld:CssParameter name=\"stroke-width\">3</sld:CssParameter>" +
"<sld:CssParameter name=\"stroke-dasharray\">3 4</sld:CssParameter>" +
"<sld:CssParameter name=\"stroke-opacity\">0.5</sld:CssParameter>" +
"</sld:Stroke>" +
"</sld:PolygonSymbolizer>" +
"</sld:Rule>",
sw.toString());
}
示例13: testPointstyle
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
@Test
public void testPointstyle() throws JiBXException {
FillInfo fillInfo = StyleUtil.createFill("#FFFF00", 0.5f);
StrokeInfo strokeInfo = StyleUtil.createStroke("red", 3, 0.5f, "3 4");
MarkInfo circleMark = StyleUtil.createMark("circle", fillInfo, strokeInfo);
GraphicInfo graphicInfo = StyleUtil.createGraphic(circleMark, 40);
PointSymbolizerInfo pointSymbolizerInfo= StyleUtil.createPointSymbolizer(graphicInfo);
RuleInfo ruleInfo = StyleUtil.createRule("myTitle", "myName", pointSymbolizerInfo);
IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
StringWriter sw = new StringWriter();
mctx.setOutput(sw);
mctx.marshalDocument(ruleInfo);
Assert.assertEquals(
"<sld:Rule xmlns:sld=\"http://www.opengis.net/sld\">" +
"<sld:Name>myName</sld:Name>" +
"<sld:Title>myTitle</sld:Title>" +
"<sld:PointSymbolizer>" +
"<sld:Graphic>" +
"<sld:Mark>" +
"<sld:WellKnownName>circle</sld:WellKnownName>" +
"<sld:Fill>" +
"<sld:CssParameter name=\"fill\">#FFFF00</sld:CssParameter>" +
"<sld:CssParameter name=\"fill-opacity\">0.5</sld:CssParameter>" +
"</sld:Fill>" +
"<sld:Stroke>" +
"<sld:CssParameter name=\"stroke\">red</sld:CssParameter>" +
"<sld:CssParameter name=\"stroke-width\">3</sld:CssParameter>" +
"<sld:CssParameter name=\"stroke-dasharray\">3 4</sld:CssParameter>" +
"<sld:CssParameter name=\"stroke-opacity\">0.5</sld:CssParameter>" +
"</sld:Stroke>" +
"</sld:Mark>" +
"<sld:Size>40</sld:Size>" +
"</sld:Graphic>" +
"</sld:PointSymbolizer>" +
"</sld:Rule>",
sw.toString());
}
示例14: convert
import org.jibx.runtime.IMarshallingContext; //导入依赖的package包/类
@Override
public Style convert(UserStyleInfo userStyleInfo) throws LayerException {
IBindingFactory bindingFactory;
try {
// create a dummy SLD root
StyledLayerDescriptorInfo sld = new StyledLayerDescriptorInfo();
sld.setVersion(SLD_VERSION);
StyledLayerDescriptorInfo.ChoiceInfo choice = new StyledLayerDescriptorInfo.ChoiceInfo();
NamedLayerInfo namedLayerInfo = new NamedLayerInfo();
namedLayerInfo.setName(DUMMY_NAMED_LAYER);
NamedLayerInfo.ChoiceInfo userChoice = new NamedLayerInfo.ChoiceInfo();
userChoice.setUserStyle(userStyleInfo);
namedLayerInfo.getChoiceList().add(userChoice);
choice.setNamedLayer(namedLayerInfo);
sld.getChoiceList().add(choice);
// force through Geotools parser
bindingFactory = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
IMarshallingContext marshallingContext = bindingFactory.createMarshallingContext();
StringWriter sw = new StringWriter();
marshallingContext.setOutput(sw);
marshallingContext.marshalDocument(sld);
SLDParser parser = new SLDParser(styleFactory, filterService.getFilterFactory());
parser.setOnLineResourceLocator(new ResourceServiceBasedLocator());
parser.setInput(new StringReader(sw.toString()));
Style[] styles = parser.readXML();
if (styles.length != 0) {
return styles[0];
} else {
throw new LayerException(ExceptionCode.INVALID_USER_STYLE, userStyleInfo.getName());
}
} catch (Exception e) {
throw new LayerException(e, ExceptionCode.INVALID_USER_STYLE, userStyleInfo.getName());
}
}
示例15: 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));
}
}