Java 类org.codehaus.jackson.map.ser.BeanPropertyWriter 实例源码

项目:homePi    文件:HomePiUserTestFilter.java   
public void serializeAsField(Object bean, JsonGenerator jGen, SerializerProvider provider, BeanPropertyWriter writer) throws Exception {

    if(bean instanceof HomePiUser){
        HomePiUser user = (HomePiUser)bean;
        Set<String> filterFields = new HashSet<String>();
     filterFields.add("userName");
     filterFields.add("email");
     filterFields.add("locale");
     filterFields.add("picLink");
     filterFields.add("givenName");
     filterFields.add("familyName");
     filterFields.add("fullName");

        SimpleBeanPropertyFilter.filterOutAllExcept(filterFields).serializeAsField(bean, jGen, provider, writer);
    } 
}
项目:libcrunch    文件:JsonTopologySerializer.java   
public void setupModule(SetupContext context) {
  context.addBeanSerializerModifier(new BeanSerializerModifier() {
    @Override
    public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
      BasicBeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
      ListIterator<BeanPropertyWriter> it = beanProperties.listIterator();
      while (it.hasNext()) {
        BeanPropertyWriter writer = it.next();
        // replace the bean writer with my own if it is for "failed"
        if (writer.getName().equals("failed")) {
          BeanPropertyWriter newWriter = new IsFailedWriter(writer);
          it.set(newWriter);
        }
      }
      return beanProperties;
    }
  });
}
项目:test-html-generator-plugin    文件:BeanSerializerBase.java   
/**
 * @param type Nominal type of values handled by this serializer
 * @param properties Property writers used for actual serialization
 */
protected BeanSerializerBase(JavaType type,
        BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties,
        AnyGetterWriter anyGetterWriter,
        Object filterId)
{
    super(type);
    _props = properties;
    _filteredProps = filteredProperties;
    _anyGetterWriter = anyGetterWriter;
    _propertyFilterId = filterId;
}
项目:test-html-generator-plugin    文件:BeanSerializerBase.java   
@SuppressWarnings("unchecked")
public BeanSerializerBase(Class<?> rawType,
        BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties,
        AnyGetterWriter anyGetterWriter,
        Object filterId)
{
    super((Class<Object>) rawType);
    _props = properties;
    _filteredProps = filteredProperties;
    _anyGetterWriter = anyGetterWriter;
    _propertyFilterId = filterId;
}
项目:homePi    文件:LogDataTestFilter.java   
public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov, BeanPropertyWriter writer) throws Exception {
    if (bean instanceof LogData) {
        Set<String> filterFields = new HashSet<String>();
        filterFields.add("logKey");
        filterFields.add("logMessage");
        filterFields.add("createTime");
        filterFields.add("logTypeId");

        SimpleBeanPropertyFilter.filterOutAllExcept(filterFields).serializeAsField(bean, jgen, prov, writer);
    }
}
项目:homePi    文件:PiProfileTestFilter.java   
public void serializeAsField(Object bean, JsonGenerator jGen, SerializerProvider provider, BeanPropertyWriter writer) throws Exception {

    if (bean instanceof PiProfile) {
        Set<String> filterFields = new HashSet<String>();
        filterFields.add("ipAddress");
        filterFields.add("name");
        filterFields.add("sshPortNumber");
        filterFields.add("piSerialId");
        filterFields.add("apiKey");

        SimpleBeanPropertyFilter.filterOutAllExcept(filterFields).serializeAsField(bean, jGen, provider, writer);
    }
}
项目:homePi    文件:ManagedAppTestFilter.java   
public void serializeAsField(Object bean, JsonGenerator jGen, SerializerProvider provider, BeanPropertyWriter writer) throws Exception {

    if (bean instanceof ManagedApp) {
        Set<String> filterFields = new HashSet<String>();
        filterFields.add("versionNumber");
        filterFields.add("appName");
        filterFields.add("fileName");
        filterFields.add("deploymentPath");

        SimpleBeanPropertyFilter.filterOutAllExcept(filterFields).serializeAsField(bean, jGen, provider, writer);
    }
}
项目:ingress-indonesia-dev    文件:BeanSerializerBase.java   
public BeanSerializerBase(Class<?> paramClass, BeanPropertyWriter[] paramArrayOfBeanPropertyWriter1, BeanPropertyWriter[] paramArrayOfBeanPropertyWriter2, AnyGetterWriter paramAnyGetterWriter, Object paramObject)
{
  super(paramClass);
  this._props = paramArrayOfBeanPropertyWriter1;
  this._filteredProps = paramArrayOfBeanPropertyWriter2;
  this._anyGetterWriter = paramAnyGetterWriter;
  this._propertyFilterId = paramObject;
}
项目:ingress-indonesia-dev    文件:BeanSerializerBase.java   
protected BeanSerializerBase(JavaType paramJavaType, BeanPropertyWriter[] paramArrayOfBeanPropertyWriter1, BeanPropertyWriter[] paramArrayOfBeanPropertyWriter2, AnyGetterWriter paramAnyGetterWriter, Object paramObject)
{
  super(paramJavaType);
  this._props = paramArrayOfBeanPropertyWriter1;
  this._filteredProps = paramArrayOfBeanPropertyWriter2;
  this._anyGetterWriter = paramAnyGetterWriter;
  this._propertyFilterId = paramObject;
}
项目:ingress-indonesia-dev    文件:UnwrappingBeanPropertyWriter.java   
public BeanPropertyWriter withSerializer(JsonSerializer<Object> paramJsonSerializer)
{
  if (getClass() != UnwrappingBeanPropertyWriter.class)
    throw new IllegalStateException("UnwrappingBeanPropertyWriter sub-class does not override 'withSerializer()'; needs to!");
  if (!paramJsonSerializer.isUnwrappingSerializer())
    paramJsonSerializer = paramJsonSerializer.unwrappingSerializer();
  return new UnwrappingBeanPropertyWriter(this, paramJsonSerializer);
}
项目:community-edition-old    文件:UniqueIdPropertyWriter.java   
protected UniqueIdPropertyWriter(BeanPropertyWriter base)
{
    super(base);
}
项目:community-edition-old    文件:UniqueIdPropertyWriter.java   
protected UniqueIdPropertyWriter(BeanPropertyWriter base, JsonSerializer<Object> ser)
{
    super(base, ser);
}
项目:community-edition-old    文件:UniqueIdPropertyWriter.java   
/**
 * We have to override this!
 */
@Override
public BeanPropertyWriter withSerializer(JsonSerializer<Object> ser)
{
    return new UniqueIdPropertyWriter(this, ser);
}
项目:community-edition-old    文件:JacksonHelper.java   
@Override
public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider provider, BeanPropertyWriter writer) throws Exception
{
    writer.serializeAsField(bean, jgen, provider);
}
项目:test-html-generator-plugin    文件:BeanSerializerBase.java   
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    ObjectNode o = createSchemaNode("object", true);
    //todo: should the classname go in the title?
    //o.put("title", _className);
    ObjectNode propertiesNode = o.objectNode();
    for (int i = 0; i < _props.length; i++) {
        BeanPropertyWriter prop = _props[i];
        JavaType propType = prop.getSerializationType();
        // 03-Dec-2010, tatu: SchemaAware REALLY should use JavaType, but alas it doesn't...
        Type hint = (propType == null) ? prop.getGenericPropertyType() : propType.getRawClass();
        // Maybe it already has annotated/statically configured serializer?
        JsonSerializer<Object> ser = prop.getSerializer();
        if (ser == null) { // nope
            Class<?> serType = prop.getRawSerializationType();
            if (serType == null) {
                serType = prop.getPropertyType();
            }
            ser = provider.findValueSerializer(serType, prop);
        }
        JsonNode schemaNode = (ser instanceof SchemaAware) ?
                ((SchemaAware) ser).getSchema(provider, hint) : 
                JsonSchema.getDefaultSchemaNode();
        if(prop.getAnnotation(XmlAttribute.class)!=null && schemaNode instanceof ObjectNode)
            ((ObjectNode)schemaNode).put("isattr", true);
        propertiesNode.put(prop.getName(), schemaNode);
    }
    o.put("properties", propertiesNode);
    if(typeHint instanceof Class)
    {
        Class<?> claz = (Class<?>)typeHint;
     if(claz.getAnnotation(XmlRootElement.class)!=null
            && !claz.getAnnotation(XmlRootElement.class).name().equals("##default"))
        o.put("name", claz.getAnnotation(XmlRootElement.class).name());
     else if(claz.getAnnotation(XmlType.class)!=null
            && !claz.getAnnotation(XmlType.class).name().equals("##default"))
        o.put("name", claz.getAnnotation(XmlType.class).name());
     else
        o.put("name", claz.getSimpleName());
    }
    return o;
}
项目:test-html-generator-plugin    文件:BeanSerializerBase.java   
@Override
public void resolve(SerializerProvider provider)
    throws JsonMappingException
{
    int filteredCount = (_filteredProps == null) ? 0 : _filteredProps.length;
    for (int i = 0, len = _props.length; i < len; ++i) {
        BeanPropertyWriter prop = _props[i];
        if (prop.hasSerializer()) {
            continue;
        }
        // Was the serialization type hard-coded? If so, use it
        JavaType type = prop.getSerializationType();

        /* It not, we can use declared return type if and only if
         * declared type is final -- if not, we don't really know
         * the actual type until we get the instance.
         */
        if (type == null) {
            type = provider.constructType(prop.getGenericPropertyType());
            if (!type.isFinal()) {
                /* 18-Feb-2010, tatus: But even if it is non-final, we may
                 *   need to retain some of type information so that we can
                 *   accurately handle contained types
                 */
                if (type.isContainerType() || type.containedTypeCount() > 0) {
                    prop.setNonTrivialBaseType(type);
                }
                continue;
            }
        }
        JsonSerializer<Object> ser = provider.findValueSerializer(type, prop);
        /* 04-Feb-2010, tatu: We may have stashed type serializer for content types
         *   too, earlier; if so, it's time to connect the dots here:
         */
        if (type.isContainerType()) {
            TypeSerializer typeSer = type.getContentType().getTypeHandler();
            if (typeSer != null) {
                // for now, can do this only for standard containers...
                if (ser instanceof ContainerSerializerBase<?>) {
                    // ugly casts... but necessary
                    @SuppressWarnings("unchecked")
                    JsonSerializer<Object> ser2 = (JsonSerializer<Object>)((ContainerSerializerBase<?>) ser).withValueTypeSerializer(typeSer);
                    ser = ser2;
                }
            }
        }
        prop = prop.withSerializer(ser);
        _props[i] = prop;
        // and maybe replace filtered property too? (see [JACKSON-364])
        if (i < filteredCount) {
            BeanPropertyWriter w2 = _filteredProps[i];
            if (w2 != null) {
                _filteredProps[i] = w2.withSerializer(ser);
            }
        }
    }

    // also, any-getter may need to be resolved
    if (_anyGetterWriter != null) {
        _anyGetterWriter.resolve(provider);
    }
}
项目:12306-android-Decompile    文件:SimpleBeanPropertyFilter.java   
public void serializeAsField(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, BeanPropertyWriter paramBeanPropertyWriter)
  throws Exception
{
  if (this._propertiesToInclude.contains(paramBeanPropertyWriter.getName()))
    paramBeanPropertyWriter.serializeAsField(paramObject, paramJsonGenerator, paramSerializerProvider);
}
项目:12306-android-Decompile    文件:SimpleBeanPropertyFilter.java   
public void serializeAsField(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, BeanPropertyWriter paramBeanPropertyWriter)
  throws Exception
{
  if (!this._propertiesToExclude.contains(paramBeanPropertyWriter.getName()))
    paramBeanPropertyWriter.serializeAsField(paramObject, paramJsonGenerator, paramSerializerProvider);
}
项目:12306-android-Decompile    文件:SimpleBeanPropertyFilter.java   
public void serializeAsField(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, BeanPropertyWriter paramBeanPropertyWriter)
  throws Exception
{
  if (this._propertiesToInclude.contains(paramBeanPropertyWriter.getName()))
    paramBeanPropertyWriter.serializeAsField(paramObject, paramJsonGenerator, paramSerializerProvider);
}
项目:12306-android-Decompile    文件:SimpleBeanPropertyFilter.java   
public void serializeAsField(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, BeanPropertyWriter paramBeanPropertyWriter)
  throws Exception
{
  if (!this._propertiesToExclude.contains(paramBeanPropertyWriter.getName()))
    paramBeanPropertyWriter.serializeAsField(paramObject, paramJsonGenerator, paramSerializerProvider);
}
项目:libcrunch    文件:JsonTopologySerializer.java   
public IsFailedWriter(BeanPropertyWriter base) {
  super(base);
}
项目:libcrunch    文件:JsonTopologySerializer.java   
public IsFailedWriter(BeanPropertyWriter base, JsonSerializer<Object> ser) {
  super(base, ser);
}
项目:libcrunch    文件:JsonTopologySerializer.java   
@Override
public BeanPropertyWriter withSerializer(JsonSerializer<Object> ser) {
  return new IsFailedWriter(this, ser);
}
项目:ingress-indonesia-dev    文件:BeanSerializerBase.java   
protected void serializeFields(Object paramObject, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider)
{
  BeanPropertyWriter[] arrayOfBeanPropertyWriter;
  if ((this._filteredProps != null) && (paramSerializerProvider.getSerializationView() != null))
    arrayOfBeanPropertyWriter = this._filteredProps;
  int i;
  JsonMappingException localJsonMappingException;
  while (true)
  {
    i = 0;
    try
    {
      int j = arrayOfBeanPropertyWriter.length;
      while (true)
        if (i < j)
        {
          BeanPropertyWriter localBeanPropertyWriter = arrayOfBeanPropertyWriter[i];
          if (localBeanPropertyWriter != null)
            localBeanPropertyWriter.serializeAsField(paramObject, paramJsonGenerator, paramSerializerProvider);
          i++;
          continue;
          arrayOfBeanPropertyWriter = this._props;
          break;
        }
      if (this._anyGetterWriter != null)
        this._anyGetterWriter.getAndSerialize(paramObject, paramJsonGenerator, paramSerializerProvider);
      return;
    }
    catch (Exception localException)
    {
      if (i == arrayOfBeanPropertyWriter.length);
      for (String str2 = "[anySetter]"; ; str2 = arrayOfBeanPropertyWriter[i].getName())
      {
        wrapAndThrow(paramSerializerProvider, localException, paramObject, str2);
        return;
      }
    }
    catch (StackOverflowError localStackOverflowError)
    {
      localJsonMappingException = new JsonMappingException("Infinite recursion (StackOverflowError)");
      if (i != arrayOfBeanPropertyWriter.length);
    }
  }
  for (String str1 = "[anySetter]"; ; str1 = arrayOfBeanPropertyWriter[i].getName())
  {
    localJsonMappingException.prependPath(new JsonMappingException.Reference(paramObject, str1));
    throw localJsonMappingException;
  }
}
项目:ingress-indonesia-dev    文件:UnwrappingBeanPropertyWriter.java   
public UnwrappingBeanPropertyWriter(BeanPropertyWriter paramBeanPropertyWriter)
{
  super(paramBeanPropertyWriter);
}
项目:ingress-indonesia-dev    文件:UnwrappingBeanPropertyWriter.java   
public UnwrappingBeanPropertyWriter(BeanPropertyWriter paramBeanPropertyWriter, JsonSerializer<Object> paramJsonSerializer)
{
  super(paramBeanPropertyWriter, paramJsonSerializer);
}