Package com.fasterxml.jackson.dataformat.xml

Examples of com.fasterxml.jackson.dataformat.xml.XmlMapper


        summary.setCustomPropertyCollection(customProperties);
        return summary;
    }

    private static XmlMapper getXmlMapper() {
        XmlMapper mapper = new XmlMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE);
        mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return mapper;
    }
View Full Code Here


     * Initializes {@link #xmlFactory} field, which may be instantiated or obtained from other part of the application.
     */
    protected void initXmlFactory() {
        initXmlModule();
        xmlFactory = new XmlFactory();
        xmlMapper = new XmlMapper(xmlFactory, xmlModule);
        xmlFactory.setCodec(xmlMapper);
    }
View Full Code Here

    /**********************************************************
     */

    public void testSimplePoint() throws Exception
    {
        final ObjectMapper mapper = new XmlMapper();
        Server server = startServer(TEST_PORT, SimpleResourceApp.class);
        Point p;
        String xml = null;

        try {
            InputStream in = new URL("http://localhost:"+TEST_PORT+"/point").openStream();
            byte[] bytes = readAll(in);
            in.close();
            xml = new String(bytes, "UTF-8");
            p = mapper.readValue(xml, Point.class);
        } finally {
            server.stop();
        }
        // ensure we got a valid Point
        assertNotNull(p);
View Full Code Here

                    } else {
                        throw SupportLogger.LOGGER.invalidReaderWriterProperty(null, (String) defaultUseWrapper, "defaultUseWrapper");
                    }
                }

                final XmlMapper xmlMapper = xmlModule == null ? new XmlMapper(xmlFactory) : new XmlMapper(xmlFactory, xmlModule);
                xmlFactory.setCodec(xmlMapper);
            }
        }
        return xmlFactory;
    }
View Full Code Here

    public synchronized XmlMapper getDefaultMapper()
    {
        if (_defaultMapper == null) {
            // 10-Oct-2012, tatu: Better do things explicitly...
            JacksonXmlModule module = getConfiguredModule();
            _defaultMapper = (module == null) ? new XmlMapper() : new XmlMapper(module);
            _setAnnotations(_defaultMapper, _defaultAnnotationsToUse);
        }
        return _defaultMapper;
    }
View Full Code Here

     */
    @Override
    protected XmlMapper mapper()
    {
        if (_mapper == null) {
            _mapper = new XmlMapper();
            _setAnnotations(_mapper, _defaultAnnotationsToUse);
        }
        return _mapper;
    }
View Full Code Here

     */
    @Override
    public XmlMapper _locateMapperViaProvider(Class<?> type, MediaType mediaType)
    {
        // First: were we configured with a specific instance?
        XmlMapper m = _mapperConfig.getConfiguredMapper();
        if (m == null) {
            // If not, maybe we can get one configured via context?
            if (_providers != null) {
                ContextResolver<XmlMapper> resolver = _providers.getContextResolver(XmlMapper.class, mediaType);
                /* Above should work as is, but due to this bug
View Full Code Here

        return new ObjectMapper();
    }

    @Bean
    public XmlMapper xmlMapper() {
        return new XmlMapper();
    }
View Full Code Here

    private Map<String, EclipsePlatform> platforms;

    @Before
    public void setUp() throws Exception {
        String responseXml = Fixtures.load("/fixtures/tools/eclipse.xml");
        XmlMapper serializer = new XmlMapper();
        EclipseXml eclipseXml = serializer.readValue(responseXml, EclipseXml.class);
        eclipseDownloads = new EclipseDownloadsXmlConverter().convert(eclipseXml);
        platforms = eclipseDownloads.getPlatforms();
    }
View Full Code Here

    private String responseXml = Fixtures.load("/fixtures/tools/eclipse.xml");

    @Test
    public void unmarshal() throws Exception {
        XmlMapper serializer = new XmlMapper();

        EclipseXml eclipseXml = serializer.readValue(responseXml, EclipseXml.class);
        assertThat(eclipseXml.getEclipseXmlProducts(), notNullValue());
        assertThat(eclipseXml.getEclipseXmlProducts().size(), equalTo(6));

        EclipseXmlProduct eclipseXmlProduct = eclipseXml.getEclipseXmlProducts().get(0);
        assertThat(eclipseXmlProduct.getName(), equalTo("SpringSource Tool Suites Downloads"));
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.dataformat.xml.XmlMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.