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

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

Introduction

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

Prototype

public void setImplicitCollections(Map<Class<?>, String> implicitCollections) 

Source Link

Document

Specify implicit collection fields, as a Map consisting of Class instances mapped to comma separated collection field names.

Usage

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  av  a  2  s.  c om*/
        marshaller.setAliases(aliases);
        marshaller.setUseAttributeFor(useAttributeFor);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }

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