Example usage for com.fasterxml.jackson.dataformat.xml XmlMapper XmlMapper

List of usage examples for com.fasterxml.jackson.dataformat.xml XmlMapper XmlMapper

Introduction

In this page you can find the example usage for com.fasterxml.jackson.dataformat.xml XmlMapper XmlMapper.

Prototype

public XmlMapper() 

Source Link

Usage

From source file:com.orange.ngsi.model.EnityIdModelTest.java

@Test
public void serializationXMLEntityId() throws IOException {

    EntityId entityId = new EntityId("E1", "T1", false);

    ObjectMapper xmlmapper = new XmlMapper();
    String xml = xmlmapper.writeValueAsString(entityId);

    assertTrue(xml.contains("E1"));
    assertTrue(xml.contains("T1"));
}

From source file:net.landora.gsbliptv.BlipTV.java

private BlipTV() {
    mapper = new XmlMapper();
}

From source file:com.ning.billing.recurly.model.RecurlyObject.java

public static XmlMapper newXmlMapper() {
    final XmlMapper xmlMapper = new XmlMapper();
    xmlMapper.setSerializerProvider(new RecurlyXmlSerializerProvider());
    final AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    final AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
    final AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
    xmlMapper.setAnnotationIntrospector(pair);
    xmlMapper.registerModule(new JodaModule());
    xmlMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    final SimpleModule m = new SimpleModule("module", new Version(1, 0, 0, null, null, null));
    m.addSerializer(Accounts.class, new RecurlyObjectsSerializer<Accounts, Account>(Accounts.class, "account"));
    m.addSerializer(AddOns.class, new RecurlyObjectsSerializer<AddOns, AddOn>(AddOns.class, "add_on"));
    m.addSerializer(Adjustments.class,
            new RecurlyObjectsSerializer<Adjustments, Adjustment>(Adjustments.class, "adjustment"));
    m.addSerializer(Coupons.class, new RecurlyObjectsSerializer<Coupons, Coupon>(Coupons.class, "coupon"));
    m.addSerializer(Invoices.class, new RecurlyObjectsSerializer<Invoices, Invoice>(Invoices.class, "invoice"));
    m.addSerializer(Plans.class, new RecurlyObjectsSerializer<Plans, Plan>(Plans.class, "plan"));
    m.addSerializer(RecurlyErrors.class,
            new RecurlyObjectsSerializer<RecurlyErrors, RecurlyError>(RecurlyErrors.class, "error"));
    m.addSerializer(SubscriptionAddOns.class,
            new RecurlyObjectsSerializer<SubscriptionAddOns, SubscriptionAddOn>(SubscriptionAddOns.class,
                    "subscription_add_on"));
    m.addSerializer(Subscriptions.class,
            new RecurlyObjectsSerializer<Subscriptions, Subscription>(Subscriptions.class, "subscription"));
    m.addSerializer(Transactions.class,
            new RecurlyObjectsSerializer<Transactions, Transaction>(Transactions.class, "transaction"));
    xmlMapper.registerModule(m);//from  w ww  . j  av  a2s .c  om

    return xmlMapper;
}

From source file:nl.esciencecenter.xnattool.DataSetConfig.java

public static DataSetConfig parseXML(String xml) throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper xmlMapper = new XmlMapper();
    DataSetConfig value = xmlMapper.readValue(xml, DataSetConfig.class);
    value.postReadUpdate();//from ww  w  .  j  a  v a 2  s.com
    return value;
}

From source file:com.springapp.domain.http.account.Account.java

public static Account fromXML(String xml) {
    ObjectMapper xmlMapper = new XmlMapper();
    try {//  w  w  w  .  ja v  a 2  s  .  c  o  m
        Account value = xmlMapper.readValue(xml, Account.class);
        return value;
    } catch (IOException e) {

        log.error("Error in creating Account object from xml :{} , error : {}", xml, e);
    }
    return null;
}

From source file:com.gplus.api.GPlusEDCAsActivityTest.java

public GPlusEDCAsActivityTest() {
    gplusSerializer = new GPlusActivitySerializer();
    jsonMapper = new ObjectMapper();
    xmlMapper = new XmlMapper();
}

From source file:com.reddit.api.RedditEDCAsActivityJSONTest.java

public RedditEDCAsActivityJSONTest() {
    redditSerializer = new RedditActivitySerializer();
    jsonMapper = new ObjectMapper();
    xmlMapper = new XmlMapper();
}

From source file:com.netflix.discovery.converters.jackson.EurekaXmlJacksonCodec.java

public EurekaXmlJacksonCodec(final KeyFormatter keyFormatter, boolean compact) {
    xmlMapper = new XmlMapper() {
        public ObjectMapper registerModule(Module module) {
            setSerializerFactory(getSerializerFactory().withSerializerModifier(
                    EurekaJacksonXmlModifiers.createXmlSerializerModifier(keyFormatter)));
            return super.registerModule(module);
        }/*from   w ww. ja  v  a  2s  . com*/
    };
    xmlMapper.setSerializationInclusion(Include.NON_NULL);
    xmlMapper.addMixIn(DataCenterInfo.class, DataCenterInfoXmlMixIn.class);
    xmlMapper.addMixIn(InstanceInfo.PortWrapper.class, PortWrapperXmlMixIn.class);
    xmlMapper.addMixIn(Application.class, ApplicationXmlMixIn.class);
    xmlMapper.addMixIn(Applications.class, ApplicationsXmlMixIn.class);
    SimpleModule xmlModule = new SimpleModule();
    xmlMapper.registerModule(xmlModule);

    if (compact) {
        addMiniConfig(xmlMapper);
    }
}

From source file:controllers.PersonControllerTest.java

@Test
public void testPostPersonXml() throws Exception {
    Person person = new Person();
    person.name = "zeeess name - and some utf8 => ";

    String response = ninjaTestBrowser.postXml(getServerAddress() + "api/person.xml", person);

    System.out.println("j: " + response);

    Person result = new XmlMapper().readValue(response, Person.class);
    assertEquals(person.name, result.name);
}

From source file:com.programmingskillz.SampleApplication.java

private JacksonXMLProvider jacksonXMLProvider() {
    XmlMapper xmlMapper = new XmlMapper();
    xmlMapper.registerModule(new JavaTimeModule());

    JacksonXMLProvider xmlProvider = new JacksonXMLProvider();

    xmlProvider.setMapper(xmlMapper);//from  w  w w .  j  a va 2 s .  co m
    xmlProvider.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    return xmlProvider;
}