List of usage examples for com.fasterxml.jackson.dataformat.xml XmlMapper XmlMapper
public XmlMapper()
From source file:com.sonatype.nexus.perftest.PerformanceTestRunner.java
public static void main(String[] args) throws Exception { final Nexus nexus = new Nexus(); ObjectMapper mapper = new XmlMapper(); mapper.setInjectableValues(new InjectableValues() { @Override//w w w . j a v a 2 s .c o m public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { if (Nexus.class.getName().equals(valueId)) { return nexus; } return null; } }); File src = new File(args[0]).getCanonicalFile(); System.out.format("Using test configuration %s\n", src); PerformanceTest test = mapper.readValue(src, PerformanceTest.class); test.run(); System.out.println("Exit"); System.exit(0); }
From source file:com.sonatype.nexus.perftest.PerformanceTestAsserter.java
public static void main(String[] args) throws Exception { final Nexus nexus = new Nexus(); ObjectMapper mapper = new XmlMapper(); mapper.setInjectableValues(new InjectableValues() { @Override//from w ww . j a v a2 s. c o m public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { if (Nexus.class.getName().equals(valueId)) { return nexus; } return null; } }); File src = new File(args[0]).getCanonicalFile(); String name = src.getName().substring(0, src.getName().lastIndexOf(".")); Collection<ClientSwarm> swarms = mapper.readValue(src, PerformanceTest.class).getSwarms(); List<Metric> metrics = new ArrayList<>(); for (ClientSwarm swarm : swarms) { metrics.add(swarm.getMetric()); } System.out.println("Test " + name + " metrics:" + metrics); assertTest(name, metrics); System.out.println("Exit"); System.exit(0); }
From source file:com.tickaroo.jackson.small.JacksonSmallXmlBenchmark.java
public void parse(String xml) throws Exception { XmlMapper mapper = new XmlMapper(); Employee employee = mapper.readValue(xml, Employee.class); System.out.println(getClass().getSimpleName() + " " + employee.name); }
From source file:ru.anr.base.services.serializer.XMLSerializerImpl.java
/** * Constructor// w ww. ja va 2s .c o m */ public XMLSerializerImpl() { super(new XmlMapper()); JacksonXmlModule module = new JacksonXmlModule(); module.setDefaultUseWrapper(false); mapper().registerModule(module); ((XmlMapper) mapper()).configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true); }
From source file:elf.license.GetLicenseDetailsQueryPojo.java
/** * Constructor/*from w w w . j a v a 2 s . c om*/ * * @param xmlString XML response document * @throws Exception */ public GetLicenseDetailsQueryPojo(String xmlString) throws Exception { try { this.xmlMapper = new XmlMapper(); this.XMLObjectPojo = readXMLStringIntoPojo(xmlString); } catch (Exception e) { throw e; } }
From source file:nl.esciencecenter.xnattool.DataSetConfigList.java
public static DataSetConfigList parseXML(String xml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper xmlMapper = new XmlMapper(); DataSetConfigList value = xmlMapper.readValue(xml, DataSetConfigList.class); // check ?//from w w w .jav a 2 s . co m return value; }
From source file:com.tickaroo.jackson.medium.JacksonMediumXmlBenchmark.java
public void parse(String xml) throws Exception { XmlMapper mapper = new XmlMapper(); Feed feed = mapper.readValue(xml, Feed.class); System.out.println(getClass().getSimpleName() + " " + feed); }
From source file:nl.esciencecenter.xnattool.XnatToolConfig.java
public static XnatToolConfig parseXML(String xml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper xmlMapper = new XmlMapper(); XnatToolConfig value = xmlMapper.readValue(xml, XnatToolConfig.class); // check ?//w w w . j av a 2s .c o m return value; }
From source file:com.orange.ngsi.model.EnityIdModelTest.java
@Test public void deserializationXMLEntityId() throws IOException { String xml = " <entityId type=\"T1\" isPattern=\"false\">\n" + " <id>E1</id>\n" + " </entityId>\n"; ObjectMapper xmlmapper = new XmlMapper(); EntityId entityId = xmlmapper.readValue(xml, EntityId.class); assertEquals("E1", entityId.getId()); }
From source file:com.orange.ngsi.model.ContextAttributeModelTest.java
@Test public void deserializationXMLContextAttribute() throws IOException { String xml = " <contextAttribute>\n" + " <name>A</name>\n" + " <type>T</type>\n" + " <contextValue>22</contextValue>\n" + " </contextAttribute>\n"; ObjectMapper xmlmapper = new XmlMapper(); ContextAttribute contextAttribute = xmlmapper.readValue(xml, ContextAttribute.class); assertEquals("A", contextAttribute.getName()); assertEquals("T", contextAttribute.getType()); assertEquals("22", contextAttribute.getValue()); }