Examples of JsonName


Examples of cc.plural.jsonij.marshal.annotation.JSONName

        for (Field field : fields) {
            ClassProperty property = new ClassProperty();
            property.setKlass(klass);
            String propertyName = field.getName();
            if (field.isAnnotationPresent(JSONName.class)) {
                JSONName jsonName = (JSONName) field.getAnnotation(JSONName.class);
                propertyName = jsonName.value();
            }
            if (field.isAnnotationPresent(JSONCollector.class)) {
                property.setCollector(true);
            }
            property.setPropertyName(propertyName);
            property.registerAccessor(field);
            property.registorMutator(field);
            propertyMap.put(propertyName, property);
        }
        Method[] methods = klass.getDeclaredMethods();
        for (Method method : methods) {
            char ch;
            String propertyName = null;
            String methodName = method.getName();
            boolean collector = false;
           
            Class<?> returnType = method.getReturnType();
            if (methodName.length() > IS_PREFIX.length() && methodName.startsWith(IS_PREFIX) && returnType == boolean.class && Character.isUpperCase(ch = methodName.charAt(IS_PREFIX.length()))) {
                if (method.isAnnotationPresent(JSONName.class)) {
                    JSONName jsonName = (JSONName) method.getAnnotation(JSONName.class);
                    propertyName = jsonName.value();
                } else {
                    propertyName = Character.toLowerCase(ch) + methodName.substring(IS_PREFIX.length() + 1, methodName.length());
                }
                if (method.isAnnotationPresent(JSONCollector.class)) {
                    collector = true;
View Full Code Here

Examples of cc.plural.jsonij.marshal.annotation.JSONName

        return name;
    }

    public static String getJSONName(AccessibleObject object) {
        String name = null;
        JSONName jsonNameAnnotation = object.getAnnotation(JSONName.class);
        if (jsonNameAnnotation != null) {
            name = jsonNameAnnotation.value();
        }
        return name;
    }
View Full Code Here

Examples of com.antiaction.common.json.annotation.JSONName

    JSONNullable nullable;
    boolean bNullable;
    JSONNullValues nullValues;
    boolean bNullValues;
    JSONConverter converter;
    JSONName jsonName;
    try {
      for ( int i=0; i<fields.length; ++i ) {
        field = fields[ i ];
        // debug
        //System.out.println( field.getName() );
        bIgnore = json_om.ignore.contains( field.getName() );
        ignore = field.getAnnotation( JSONIgnore.class );
        if ( ignore != null ) {
          // debug
          //System.out.println( "ignore" );
          bIgnore = true;
        }
        if ( !bIgnore ) {
          fieldModsMask = ClassTypeModifiers.getFieldModifiersMask( field );
          // debug
          //System.out.println( field.getName() + " - " + ClassTypeModifiers.toString( fieldModsMask ) );
          bIgnore = (fieldModsMask & JSONObjectMappingConstants.FIELD_IGNORE_TYPE_MODIFIER) != 0;
        }
        if ( !bIgnore ) {
          fieldType = field.getType();
          fieldTypeName = fieldType.getName();
          classTypeMask = ClassTypeModifiers.getClassTypeModifiersMask( fieldType );
          // debug
          //System.out.println( fieldTypeName + " " + ClassTypeModifiers.toString( classTypeMask ) );

          type = JSONObjectMappingConstants.typeMappings.get( fieldTypeName );
          fieldObjectMapping = null;
          if ( type == null ) {
            if ( (classTypeMask & JSONObjectMappingConstants.FIELD_INVALID_TYPE_MODIFIERS_MASK) != 0 ) {
              throw new JSONException( "Unsupported field class type." );
            }
            classTypeMask &= JSONObjectMappingConstants.FIELD_VALID_TYPE_MODIFIERS_MASK;
            if ( (classTypeMask == JSONObjectMappingConstants.VALID_CLASS) || (classTypeMask == JSONObjectMappingConstants.VALID_MEMBER_CLASS) ) {
              Type genericType = field.getGenericType();
              //System.out.println( "GT: " + genericType + " " + genericType.getClass() );

              type = JSONObjectMappingConstants.T_OBJECT;
              // Cache
              fieldObjectMapping = classMappings.get( fieldTypeName );
              if ( fieldObjectMapping == null ) {
                fieldObjectMapping = mapClass( Class.forName( fieldTypeName, true, clazz.getClassLoader() ) );
              }

              if( genericType instanceof ParameterizedType ) {
                ParameterizedType parameterizedType = (ParameterizedType)genericType;
                Type[] typeArguments = parameterizedType.getActualTypeArguments();
                for ( Type typeArgument : typeArguments ) {
                  Class<?> classType = ((Class<?>)typeArgument);
                  //System.out.println( "Field " + field.getName() + " has a parameterized type of " + classType.getSimpleName() );
                }
              }
            }
            else if ( classTypeMask == JSONObjectMappingConstants.VALID_ARRAY_CLASS ) {
              type = JSONObjectMappingConstants.T_ARRAY;
              arrayType = JSONObjectMappingConstants.arrayTypeMappings.get( fieldTypeName );
              if ( arrayType == null ) {
                level = 0;
                while ( level < fieldTypeName.length() && fieldTypeName.charAt( level ) == '[' ) {
                  ++level;
                }
                // [L<class>;
                if ( level == 1 && level < fieldTypeName.length() && fieldTypeName.charAt( level ) == 'L' && fieldTypeName.endsWith( ";" ) ) {
                  arrayType = JSONObjectMappingConstants.T_OBJECT;
                  fieldTypeName = fieldTypeName.substring( level + 1, fieldTypeName.length() - 1 );
                  fieldType = Class.forName( fieldTypeName, true, clazz.getClassLoader() );
                  // Cache
                  fieldObjectMapping = classMappings.get( fieldTypeName );
                  if ( fieldObjectMapping == null ) {
                    fieldObjectMapping = mapClass( fieldType );
                  }
                }
                else {
                  throw new JSONException( "Unsupported array type '" + fieldTypeName + "'." );
                }
              }
            }
            else {
              throw new JSONException( "Unsupported field class type." );
            }
          }
          // debug
          //System.out.println( type );

          if ( type != null ) {
            json_fm = new JSONObjectFieldMapping();
            json_fm.fieldName = field.getName();
            json_fm.type = type;
            json_fm.arrayType = arrayType;
            json_fm.className = fieldTypeName;
            json_fm.clazz = fieldType;
            json_fm.objectMapping = fieldObjectMapping;
            json_fm.field = clazz.getDeclaredField( json_fm.fieldName );
            json_fm.field.setAccessible( true );

            bNullable = json_om.nullableSet.contains( json_fm.fieldName );
            if ( !bNullable ) {
              nullable = field.getAnnotation( JSONNullable.class );
              if ( nullable != null ) {
                bNullable = nullable.value();
              }
            }
            if ( bNullable ) {
              if ( json_fm.type < JSONObjectMappingConstants.T_OBJECT ) {
                throw new JSONException( "Primitive types can not be nullable." );
              }
              json_fm.nullable = true;
            }
            bNullValues = json_om.nullValuesSet.contains( json_fm.fieldName );
            if ( !bNullValues) {
              nullValues = field.getAnnotation( JSONNullValues.class );
              if ( nullValues != null ) {
                bNullValues = nullValues.value();
              }
            }
            if ( bNullValues ) {
              if ( json_fm.type >= JSONObjectMappingConstants.T_ARRAY && json_fm.arrayType < JSONObjectMappingConstants.T_OBJECT ) {
                throw new JSONException( "Array of primitive type can not have null values." );
              }
              json_fm.nullValues = true;
            }
            converter = field.getAnnotation( JSONConverter.class );
            if ( converter != null ) {
              json_fm.converterName = converter.name();
              Integer converterId = converterNameIdMap.get( json_fm.converterName );
              if ( converterId == null ) {
                converterId = converterIds++;
                converterNameIdMap.put( json_fm.converterName, converterId );
              }
              json_fm.converterId = converterId;
              json_om.converters = true;
            }
            jsonName = field.getAnnotation( JSONName.class );
            if ( jsonName != null ) {
              json_fm.jsonName = jsonName.value();
            }
            else {
              json_fm.jsonName = json_fm.fieldName;
            }
View Full Code Here

Examples of jsonij.json.annotation.JSONName

        return name;
    }

    public static String getJSONName(AccessibleObject object) {
        String name = null;
        JSONName jsonNameAnnotation = object.getAnnotation(JSONName.class);
        if (jsonNameAnnotation != null) {
            name = jsonNameAnnotation.value();
        }
        return name;
    }
View Full Code Here

Examples of jsonij.json.annotation.JSONName

        return name;
    }

    public static String getJSONName(AccessibleObject object) {
        String name = null;
        JSONName jsonNameAnnotation = object.getAnnotation(JSONName.class);
        if (jsonNameAnnotation != null) {
            name = jsonNameAnnotation.value();
        }
        return name;
    }
View Full Code Here

Examples of jsonij.json.marshal.annotation.JSONName

        return name;
    }

    public static String getJSONName(AccessibleObject object) {
        String name = null;
        JSONName jsonNameAnnotation = object.getAnnotation(JSONName.class);
        if (jsonNameAnnotation != null) {
            name = jsonNameAnnotation.value();
        }
        return name;
    }
View Full Code Here

Examples of org.codehaus.enunciate.json.JsonName

    return true;
  }

  @Override
  public String getJsonMemberName() {
    JsonName jsonName = getAnnotation(JsonName.class);
    return jsonName == null ? (isElementRefs() ? getSimpleName() : getName()) : jsonName.value();
  }
View Full Code Here

Examples of org.codehaus.enunciate.json.JsonName

    return true;
  }

  @Override
  public String getJsonMemberName() {
    JsonName jsonName = getAnnotation(JsonName.class);
    return jsonName == null ? "value" : jsonName.value();
  }
View Full Code Here

Examples of org.codehaus.enunciate.json.JsonName

    return false;
  }

  @Override
  public String getJsonMemberName() {
    JsonName jsonName = getAnnotation(JsonName.class);
    return jsonName == null ? (isWrapped() ? getWrapperName() : getName()) : jsonName.value();
  }
View Full Code Here

Examples of org.codehaus.enunciate.json.JsonName

    return true;
  }

  @Override
  public String getJsonMemberName() {
    JsonName jsonName = getAnnotation(JsonName.class);
    return jsonName == null ? getName() : jsonName.value();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.