Package org.codehaus.jackson.xc

Examples of org.codehaus.jackson.xc.JaxbAnnotationIntrospector


  @Override
  public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
    ObjectMapper mapper = super.locateMapper(type, mediaType);
    AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(
        new JaxbAnnotationIntrospector(),
        new JacksonAnnotationIntrospector()
    );
    mapper.setAnnotationIntrospector(introspector);
    //mapper.setSerializationInclusion(Inclusion.NON_NULL);
    return mapper;
View Full Code Here


    }

    private ObjectMapper getObjectMapper() throws IOException {
        if (this.objectMapper == null) {
            ObjectMapper objectMapper = new ObjectMapper();
            AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
            SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
            serializationConfig = serializationConfig.without(SerializationConfig.Feature.WRAP_ROOT_VALUE)
                                                     .withAnnotationIntrospector(introspector);
            objectMapper.setSerializationConfig(serializationConfig);
            this.objectMapper = objectMapper;
View Full Code Here

    }

    private ObjectMapper getObjectMapper() throws IOException {
        if (this.objectMapper == null) {
            ObjectMapper objectMapper = new ObjectMapper();
            AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
            SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
            serializationConfig = serializationConfig.without(SerializationConfig.Feature.WRAP_ROOT_VALUE)
                                                     .with(SerializationConfig.Feature.INDENT_OUTPUT)
                                                     .withAnnotationIntrospector(introspector);
            objectMapper.setSerializationConfig(serializationConfig);
View Full Code Here

    private static ObjectMapper createObjectMapper() {
        ObjectMapper mapper = new ObjectMapper();

        AnnotationIntrospector pair =
            new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
                                            new JacksonAnnotationIntrospector());

        SerializationConfig serializationConfig =
            mapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL).withAnnotationIntrospector(pair);
           //.withDateFormat(StdDateFormat.getBlueprintISO8601Format());
View Full Code Here

    }

    @Override
    protected Object[] getSingletons() {
        ObjectMapper mapper = new ObjectMapper();
        JaxbAnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector();
        mapper.getSerializationConfig().setAnnotationIntrospector(jaxbIntrospector);
        mapper.getDeserializationConfig().setAnnotationIntrospector(jaxbIntrospector);
        jacksonProvider = new JacksonJsonProvider();
        jacksonProvider.setMapper(mapper);
        return new Object[]{jacksonProvider};
View Full Code Here

    }

    public void testXcVersions()
    {
        if (runsFromAnt()) {
            assertVersion(new JaxbAnnotationIntrospector().version(), MAJOR_VERSION, MINOR_VERSION);
        }
    }
View Full Code Here

    obj.setMyMap(new HashMap<String, String>());
    obj.getMyMap().put("this", "that");
    obj.getMyMap().put("how", "here");

    ObjectMapper mapper = new ObjectMapper();
    mapper.getDeserializationConfig().withAnnotationIntrospector(new JaxbAnnotationIntrospector());
    mapper.getSerializationConfig().withAnnotationIntrospector(new JaxbAnnotationIntrospector());
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    mapper.writeValue(bytesOut, obj);
    obj = mapper.readValue(new ByteArrayInputStream(bytesOut.toByteArray()), ObjectContainingAMap.class);
    assertNotNull(obj.getMyMap());
  }
View Full Code Here

     */

    public void testAutoDetectDisable() throws IOException
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        Jackson183Bean bean = new Jackson183Bean();
        Map<String,Object> result;

        // Ok: by default, should see 2 fields:
        result = writeAndMap(mapper, bean);
        assertEquals(2, result.size());
        assertEquals("a", result.get("a"));
        assertEquals("b", result.get("b"));

        // But when disabling auto-detection, just one
        mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        mapper.configure(SerializationConfig.Feature.AUTO_DETECT_GETTERS, false);
        result = writeAndMap(mapper, bean);
        assertEquals(1, result.size());
        assertNull(result.get("a"));
        assertEquals("b", result.get("b"));
View Full Code Here

    // @since 1.5
    public void testIssue246() throws IOException
    {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        Identified id = new Identified();
        id.id = "123";
        assertEquals("{\"id\":\"123\"}", mapper.writeValueAsString(id));
    }
View Full Code Here

    // Added to check for [JACKSON-171]
    public void testWithJAXB() throws Exception
    {
        String jsonData = "{\"id\":1}";
        ObjectMapper mapper = new ObjectMapper();
        mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
        mapper.readValue(jsonData, JaxbBean.class);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.xc.JaxbAnnotationIntrospector

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.