Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.ser.impl;
  
  
 
     extends BeanSerializerBase
 {
    
Transformer used to add prefix and/or suffix for properties of unwrapped POJO.
 
     protected final NameTransformer _nameTransformer;
     
     /*
     /**********************************************************
     /* Life-cycle: constructors
     /**********************************************************
      */

    
Constructor used for creating unwrapping instance of a standard BeanSerializer
 
     public UnwrappingBeanSerializer(BeanSerializerBase srcNameTransformer transformer) {
         super(srctransformer);
          = transformer;
     }
 
     public UnwrappingBeanSerializer(UnwrappingBeanSerializer srcObjectIdWriter objectIdWriter) {    
         super(srcobjectIdWriter);
          = src._nameTransformer;
     }
 
     protected UnwrappingBeanSerializer(UnwrappingBeanSerializer srcString[] toIgnore) {
         super(srctoIgnore);
          = src._nameTransformer;
     }
     
     /*
     /**********************************************************
     /* Life-cycle: factory methods, fluent factories
     /**********************************************************
      */
 
     @Override
     public JsonSerializer<ObjectunwrappingSerializer(NameTransformer transformer) {
         // !!! 23-Jan-2012, tatu: Should we chain transformers?
         return new UnwrappingBeanSerializer(thistransformer);
     }
 
     @Override
     public boolean isUnwrappingSerializer() {
         return true// sure is
     }
 
     @Override
     public UnwrappingBeanSerializer withObjectIdWriter(ObjectIdWriter objectIdWriter) {
         return new UnwrappingBeanSerializer(thisobjectIdWriter);
     }
 
     @Override
     protected UnwrappingBeanSerializer withIgnorals(String[] toIgnore) {
         return new UnwrappingBeanSerializer(thistoIgnore);
     }

    
JSON Array output can not be done if unwrapping operation is requested; so implementation will simply return 'this'.
 
     @Override
     protected BeanSerializerBase asArraySerializer() {
         return this;
     }
     
     /*
     /**********************************************************
     /* JsonSerializer implementation that differs between impls
     /**********************************************************
      */

    
Main serialization method that will delegate actual output to configured com.fasterxml.jackson.databind.ser.BeanPropertyWriter instances.
 
     @Override
     public final void serialize(Object beanJsonGenerator jgenSerializerProvider provider)
         throws IOExceptionJsonGenerationException
     {
         if ( != null) {
             serializeWithObjectId(beanjgenprovider);
             return;
        }
        if ( != null) {
            serializeFieldsFiltered(beanjgenprovider);
        } else {
            serializeFields(beanjgenprovider);
        }
    }
    private final void serializeWithObjectId(Object beanJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        final ObjectIdWriter w = ;
        WritableObjectId oid = provider.findObjectId(beanw.generator);
        Object id = oid.id;
        
        if (id != null) { // have seen before; serialize just id
            oid.serializer.serialize(idjgenprovider);
            return;
        }
        // if not, bit more work:
        oid.serializer = w.serializer;
        oid.id = id = oid.generator.generateId(bean);
        // possibly. Or maybe not:
        if (w.alwaysAsId) { 
            oid.serializer.serialize(idjgenprovider);
            return;
        }
        
        jgen.writeStartObject();
        SerializedString name = w.propertyName;
        if (name != null) {
            jgen.writeFieldName(name);
            w.serializer.serialize(idjgenprovider);
        }
        if ( != null) {
            serializeFieldsFiltered(beanjgenprovider);
        } else {
            serializeFields(beanjgenprovider);
        }
        jgen.writeEndObject();
    }
    
    /*
    /**********************************************************
    /* Standard methods
    /**********************************************************
     */
    @Override public String toString() {
        return "UnwrappingBeanSerializer for "+handledType().getName();
    }
New to GrepCode? Check out our FAQ X