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


Java XStreamMarshaller类代码示例

本文整理汇总了Java中org.springframework.oxm.xstream.XStreamMarshaller的典型用法代码示例。如果您正苦于以下问题:Java XStreamMarshaller类的具体用法?Java XStreamMarshaller怎么用?Java XStreamMarshaller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XStreamMarshaller类属于org.springframework.oxm.xstream包,在下文中一共展示了XStreamMarshaller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMessageConverter

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
/**
 * @param xstreamMarshaller The fully configured {@link XStreamMarshaller}
 * @return The configured {@link MarshallingHttpMessageConverter}.
 */
@Bean
public MarshallingHttpMessageConverter getMessageConverter(
    final XStreamMarshaller xstreamMarshaller) {
  final List<MediaType> mediaTypes = new ArrayList<>();
  mediaTypes.add(MediaType.APPLICATION_XML);
  mediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);

  final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter();
  xmlConverter.setSupportedMediaTypes(mediaTypes);

  xmlConverter.setMarshaller(xstreamMarshaller);
  xmlConverter.setUnmarshaller(xstreamMarshaller);

  return xmlConverter;
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:20,代码来源:S3MockApplication.java

示例2: setUp

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
/**
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
	writer = new StaxEventItemWriter();
	writer.setResource(new FileSystemResource("target/test-outputs/StaxWriterTest.xml"));
	writer.setRootTagName("urlset");
	XStreamMarshaller marshaller = new XStreamMarshaller();

	Map<String, Object> aliases = new HashMap<String, Object>();
	aliases.put("url", Url.class);
	marshaller.setAliases(aliases);
	writer.setMarshaller(marshaller);
	Map<String, String> attributes = new HashMap<String, String>();
	attributes.put("xmlns", "http://www.sitemaps.org/schemas/sitemap");
	writer.setRootElementAttributes(attributes);

}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:StaxWriterTest.java

示例3: unmarshallTest

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
/**
 * Unmarshall test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void unmarshallTest() throws Exception {
	final String content = "abcdefg";
	final String xmlContent = "<string>" + content + "</string>";
	File temp;
	temp = File.createTempFile("UnmarshallXmlTestTempFile", ".xml");

	final BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
	bw.write(xmlContent);
	bw.close();

	final XStream xstream = new XStream();
	xstream.alias("TestXml", TestXml.class);

	assertEquals(content, unmarshallXml(new XStreamMarshaller(), temp.getPath()));
}
 
开发者ID:Hack23,项目名称:cia,代码行数:23,代码来源:UnmarshallXmlTest.java

示例4: configureMessageConverters

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {

	FilteringJackson2HttpMessageConverter jsonConverter 
			= new FilteringJackson2HttpMessageConverter();
	jsonConverter.setSupportedMediaTypes(ApiMediaTypes.getJsonMediaTypes());
	converters.add(jsonConverter);
	
	MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter();
	xmlConverter.setSupportedMediaTypes(ApiMediaTypes.getXmlMediaTypes());
	XStreamMarshaller xStreamMarshaller = new XStreamMarshaller();
	xmlConverter.setMarshaller(xStreamMarshaller);
	xmlConverter.setUnmarshaller(xStreamMarshaller);
	converters.add(xmlConverter);
	
	FilteringTextMessageConverter filteringTextMessageConverter = 
			new FilteringTextMessageConverter(new MediaType("text", "plain", Charset.forName("utf-8")));
	filteringTextMessageConverter.setDelimiter("\t");
	converters.add(filteringTextMessageConverter);
	
}
 
开发者ID:oncoblocks,项目名称:centromere,代码行数:22,代码来源:WebServicesConfig.java

示例5: registerXStreamMarshaller

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
public void registerXStreamMarshaller(XStreamMarshaller marshaller, ResourceRegister register) throws Exception {
    marshaller.setSupportedClasses(register.getTargetClasses());
    if (!register.isEmpty()) {
        Collection<ClassDescriptor> cls = register.getClassDescriptors();
        Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
        Map<Class<?>, String> omittedFields = new HashMap<Class<?>, String>();
        for (ClassDescriptor cl : cls) {
            Class<?> clazz = cl.getTargetClass();
            String name = cl.getName();
            if (!StringUtils.hasLength(name))
                name = clazz.getSimpleName();
            aliases.put(name, clazz);
            Collection<String> fields = cl.getExcludesFields();
            for (String fieldName : fields) {
                omittedFields.put(clazz, fieldName);
            }

        }
        marshaller.setOmittedFields(omittedFields);
        marshaller.setAliases(aliases);
    }

}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:24,代码来源:OxmConverter.java

示例6: registerConverter

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
public void registerConverter(Class<? extends ConverterMatcher>... converterClass) throws Exception {
    XStreamMarshaller marshaller = (XStreamMarshaller) getMarshaller();
    marshaller.setConverters(new ConverterMatcher[] {});
    if (converterClass == null) {
        return;
    }

    List<ConverterMatcher> converters = new ArrayList<ConverterMatcher>(converterClass.length);
    for (Class<? extends ConverterMatcher> clazz : converterClass) {
        if (clazz == null)
            continue;
        ConverterMatcher converter = clazz.getConstructor(Mapper.class).newInstance(marshaller.getXStream().getMapper());
        converters.add(converter);

    }
    marshaller.setConverters(converters.toArray(new ConverterMatcher[converters.size()]));
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:18,代码来源:OxmConverter.java

示例7: getXStreamMarshaller

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
/**
 * @return The pre-configured {@link XStreamMarshaller}.
 */
@Bean
public XStreamMarshaller getXStreamMarshaller() {
  final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();

  xstreamMarshaller.setSupportedClasses(Bucket.class,
      Owner.class,
      ListAllMyBucketsResult.class,
      CopyPartResult.class,
      CopyObjectResult.class,
      ListBucketResult.class,
      InitiateMultipartUploadResult.class,
      ListMultipartUploadsResult.class,
      ListPartsResult.class,
      CompleteMultipartUploadResult.class,
      BatchDeleteRequest.class,
      BatchDeleteResponse.class,
      ErrorResponse.class);

  xstreamMarshaller.setAnnotatedClasses(Bucket.class,
      Owner.class,
      CopyPartResult.class,
      ListAllMyBucketsResult.class,
      CopyObjectResult.class,
      ListBucketResult.class,
      InitiateMultipartUploadResult.class,
      ListMultipartUploadsResult.class,
      ListPartsResult.class,
      CompleteMultipartUploadResult.class,
      BatchDeleteRequest.class,
      BatchDeleteResponse.class,
      ErrorResponse.class);

  return xstreamMarshaller;
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:38,代码来源:S3MockApplication.java

示例8: getMarshallingXmlViewResolver

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
@Bean
  public CustomXMLViewResolver getMarshallingXmlViewResolver() { // Resolver para o formato XML
      //Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
      //marshaller.setClassesToBeBound(Product.class);
XStreamMarshaller marshaller = new XStreamMarshaller();
HashMap<String, Class<?>> keys = new HashMap<String,Class<?>>();
//keys.put("product", Product.class);
//keys.put("price", Price.class);
marshaller.setAliases(keys);
      return new CustomXMLViewResolver(marshaller);
  }
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:12,代码来源:AppWebConfiguration.java

示例9: createXmlHttpMessageConverter

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
private HttpMessageConverter<Object> createXmlHttpMessageConverter() {
       MarshallingHttpMessageConverter xmlConverter = 
         new MarshallingHttpMessageConverter();

       
       XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();
       xmlConverter.setMarshaller(xstreamMarshaller);
       xmlConverter.setUnmarshaller(xstreamMarshaller);

       return xmlConverter;
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:12,代码来源:AppConfig.java

示例10: createXmlHttpMessageConverter

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
private HttpMessageConverter<Object> createXmlHttpMessageConverter() {
	MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter();

	XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();
	xmlConverter.setMarshaller(xstreamMarshaller);
	xmlConverter.setUnmarshaller(xstreamMarshaller);

	return xmlConverter;
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:10,代码来源:RestConfig.java

示例11: setUp

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
/**
 * @throws Exception
 *             if there is a problem initializing the unmarshaller
 */
@Before
public final void setUp() throws Exception {
	QNameMapFactory qNameMapFactory = new QNameMapFactory();
	qNameMapFactory.afterPropertiesSet();
	ReflectionProviderFactory reflectionProviderFactory = new ReflectionProviderFactory();
	reflectionProviderFactory.afterPropertiesSet();

	StaxDriver streamDriver = new StaxDriver(qNameMapFactory.getObject());
	streamDriver.setRepairingNamespace(false);

	unmarshaller = new XStreamMarshaller();

	((XStreamMarshaller) unmarshaller).setAutodetectAnnotations(true);
	Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
	aliases.put("Representation", Representation.class);
	aliases.put("Agent", Agent.class);
	aliases.put("TaxonName", TaxonName.class);
	aliases.put("CategoricalCharacter", CategoricalCharacter.class);
	aliases.put("StateDefinition", StateDefinition.class);
	aliases.put("Dataset", Dataset.class);

	((XStreamMarshaller) unmarshaller).setAliases(aliases);

	((XStreamMarshaller) unmarshaller).setStreamDriver(streamDriver);
	((XStreamMarshaller) unmarshaller)
	.setConverters(new ConverterMatcher[] { new URIConverter(), new IgnoreConverter() });
	((XStreamMarshaller) unmarshaller).afterPropertiesSet();

}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:34,代码来源:AbstractIdentificationKeyMarshallingTest.java

示例12: createMarshaller

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
/**
 * Creates an XStream object based on a media type. By default, it creates a
 * {@link HierarchicalStreamDriver} or a {@link DomDriver}.
 * @return The XStream object.
 */
protected AbstractMarshaller createMarshaller() {
    AbstractMarshaller result = null;

    try {
        XStreamMarshaller marshaller = new XStreamMarshaller();
        marshaller.setStreamDriver(getXmlDriverClass().newInstance());
        result = marshaller;
    } catch (Exception e) {
        Context.getCurrentLogger().log(Level.WARNING, "Unable to create the XStream driver.", e);
    }

    return result;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:19,代码来源:OxmConverter.java

示例13: productMarshaller

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
@Bean
public XStreamMarshaller productMarshaller() {

	HashMap<String, Class> aliases = new HashMap<String, Class>();
	aliases.put("product", Product.class);

	XStreamMarshaller marshaller = new XStreamMarshaller();
	try {
		marshaller.setAliases(aliases);
	} catch (Exception ignored) {}

	return marshaller;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:14,代码来源:JobXmlFileConfiguration.java

示例14: setMarshaller

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
@Autowired(required=false) 
public void setMarshaller(XStreamMarshaller marshaller) {
	super.setMarshaller(marshaller);
}
 
开发者ID:u2ware,项目名称:springfield,代码行数:5,代码来源:XmlView.java

示例15: springfieldXStreamMarshaller

import org.springframework.oxm.xstream.XStreamMarshaller; //导入依赖的package包/类
@Bean
public XStreamMarshaller springfieldXStreamMarshaller(){
	XStreamMarshaller b = new XStreamMarshaller();
	b.setAutodetectAnnotations(true);
	return b;
}
 
开发者ID:u2ware,项目名称:springfield,代码行数:7,代码来源:WebmvcRenderConfiguration.java


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