Example usage for org.springframework.oxm.xstream XStreamMarshaller setAliases

List of usage examples for org.springframework.oxm.xstream XStreamMarshaller setAliases

Introduction

In this page you can find the example usage for org.springframework.oxm.xstream XStreamMarshaller setAliases.

Prototype

public void setAliases(Map<String, ?> aliases) 

Source Link

Document

Set the alias/type map, consisting of string aliases mapped to classes.

Usage

From source file:br.com.semanticwot.cd.conf.AppWebConfiguration.java

@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);
}

From source file:gov.nyc.doitt.gis.geoclient.service.configuration.AppConfig.java

@Bean
public XStreamMarshaller marshaller() {
    XStreamMarshaller marshaller = new XStreamMarshaller();
    marshaller.setConverters(new ConverterMatcher[] { new MapConverter() });
    Map<String, Class<?>> aliases = new HashMap<String, Class<?>>();
    aliases.put("geosupportResponse", Map.class);
    aliases.put("version", Version.class);
    aliases.put("fileInfo", FileInfo.class);
    aliases.put("error", BadRequest.class);
    aliases.put("chunk", Chunk.class);
    aliases.put("token", Token.class);
    marshaller.setAliases(aliases);
    marshaller.setAutodetectAnnotations(true);
    return marshaller;
}

From source file:org.springframework.social.soundcloud.api.impl.SoundCloudTemplate.java

@Override
protected List<HttpMessageConverter<?>> getMessageConverters() {
    List<HttpMessageConverter<?>> messageConverters = super.getMessageConverters();
    messageConverters.add(new ByteArrayHttpMessageConverter());
    XStreamMarshaller marshaller = new XStreamMarshaller();
    Map<Class<?>, String> implicitCollections = new HashMap<Class<?>, String>();
    implicitCollections.put(TrackArray.class, "tracks");
    marshaller.setImplicitCollections(implicitCollections);

    // marshaller.setConverters(converterMatchers);
    Map<String, Object> aliases = new HashMap<String, Object>();
    aliases.put("playlist", XmlPlaylistUpdate.class.getName());
    // aliases.put("playlist", PlaylistUpdate.class.getName());

    aliases.put("track", TrackReference.class.getName());

    Map<String, Class<?>> useAttributeFor = new HashMap<String, Class<?>>();
    useAttributeFor.put("type", String.class);

    try {/*from   w  w w.  j ava2  s  . c om*/
        marshaller.setAliases(aliases);
        marshaller.setUseAttributeFor(useAttributeFor);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }

    messageConverters.add(new MarshallingHttpMessageConverter(marshaller, marshaller));
    return messageConverters;
}

From source file:org.emonocot.job.sitemap.StaxWriterTest.java

/**
 * @throws Exception/*from  ww  w .  java  2  s .c om*/
 */
@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);

}