当前位置: 首页>>代码示例>>Java>>正文


Java IMarshallingContext类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:22,代码来源:M2Model.java

示例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;

}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:17,代码来源:XmlBindingTools.java

示例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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:SystemInfo.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:JibxMarshaller.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JibxMarshaller.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:JibxMarshaller.java

示例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;
   }
 
开发者ID:changyuefeng,项目名称:netty-book,代码行数:12,代码来源:TestOrder.java

示例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;
   }
 
开发者ID:changyuefeng,项目名称:netty-book,代码行数:14,代码来源:AbstractHttpXmlEncoder.java

示例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;
}
 
开发者ID:Hope6537,项目名称:hope-tactical-equipment,代码行数:14,代码来源:AbstractHttpXmlEncoder.java

示例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;
	}
}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:9,代码来源:XmlBindingTools.java

示例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);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:13,代码来源:JiBXDataSource.java

示例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());
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:31,代码来源:StyleUtilTest.java

示例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());
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:39,代码来源:StyleUtilTest.java

示例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());
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:38,代码来源:StyleConverterServiceImpl.java

示例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));
    }
}
 
开发者ID:makhidkarun,项目名称:cartography,代码行数:15,代码来源:AccessXMLFile.java


注:本文中的org.jibx.runtime.IMarshallingContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。