Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.module.jaxb.ser;
  
  
  
  
 
     extends StdSerializer<Object>
     implements ContextualSerializer,
         SchemaAware
 {
     protected final XmlAdapter<?,Object_xmlAdapter;
 
     protected final boolean _fromClassAnnotation;
     
     protected final JavaType _valueType;
     
     protected final JsonSerializer<Object_serializer;
     
     @SuppressWarnings("unchecked")
     public XmlAdapterJsonSerializer(XmlAdapter<?,?> xmlAdapter,
             boolean fromClassAnnotation) {
         this((XmlAdapter<?,Object>)  xmlAdapterfromClassAnnotationnullnull);
     }
 
     protected XmlAdapterJsonSerializer(XmlAdapter<?,ObjectxmlAdapter,
             boolean fromClassAnnotation,
             JavaType valueTypeJsonSerializer<Objectserializer)
     {
         super(Object.class);
          = xmlAdapter;
          = fromClassAnnotation;
          = valueType;
          = serializer;
     }
 
             BeanProperty propertythrows JsonMappingException
     {
         TypeFactory typeFactory = prov.getConfig().getTypeFactory();
 
         JavaType type = typeFactory.constructType(.getClass());
         JavaType[] rawTypes = typeFactory.findTypeParameters(typeXmlAdapter.class);
         JavaType valueType;
         
         if (rawTypes == null || rawTypes.length < 2) {
             valueType = TypeFactory.unknownType();
         } else {
             valueType = rawTypes[0];
             /* [Issue-10]: Infinite loop for "identity" adapter; try to prevent,
              * if (but only if!) we are resolving something that came from class
              * annotation. Property annotations are ok.
              */
             if () {
                 JavaType otherType = rawTypes[1];
                 if (otherType != null && otherType.getRawClass() == valueType.getRawClass()) {
                     // 17-Jul-2012, tatu: Report an error? Handle some other way?
                     throw new IllegalArgumentException("'Identity' adapters for Class annotations not allowed");
                 }
             }
         }
         JsonSerializer<Objectser = prov.findValueSerializer(valueTypeproperty);
         return new XmlAdapterJsonSerializer(valueTypeser);
     }
     
     @Override
     public void serialize(Object valueJsonGenerator jgenSerializerProvider provider)
         throws IOException
     {
         Object adapted;
         // first, use adapter to get a familiar type of a value
         try {
             adapted = .marshal(value);
         } catch (IOException e) { // pass exceptions that are declared to be thrown as-is
             throw e;
         } catch (Exception e) {
             throw new JsonMappingException("Unable to marshal: "+e.getMessage(), e);
         }
         // then serialize that
         if (adapted == null) {
             // 14-Jan-2011, ideally should know property, use 'findNullValueSerializer' but...
             provider.defaultSerializeNull(jgen);
         } else {
             _checkSerializer();
             .serialize(adaptedjgenprovider);
         }
     }
 
     @Override
    public JsonNode getSchema(SerializerProvider providerType typeHint)
            throws JsonMappingException
    {
        _checkSerializer();
        if ( instanceof SchemaAware) {
            return ((SchemaAware).getSchema(providernull);
        }
        return JsonSchema.getDefaultSchemaNode();
    }
    private final void _checkSerializer()
    {
        if ( == null) {
            throw new IllegalStateException("No serializer assigned for XmlAdapterJsonDeserializer ("
                +.getClass().getName()+"): resolve() not called?");
        }
    }
New to GrepCode? Check out our FAQ X