org.codehaus.jackson.map.introspect
Class BasicBeanDescription

java.lang.Object
  extended by org.codehaus.jackson.map.BeanDescription
      extended by org.codehaus.jackson.map.introspect.BasicBeanDescription

public class BasicBeanDescription
extends BeanDescription


Field Summary
 
Fields inherited from class org.codehaus.jackson.map.BeanDescription
_class
 
Constructor Summary
BasicBeanDescription(java.lang.Class<?> forClass, AnnotatedClass ac)
           
 
Method Summary
static java.lang.String descFor(java.lang.reflect.AnnotatedElement elem)
          Helper method used to describe an annotated element of type Class or Method.
 AnnotatedMethod findAnySetter()
          Method used to locate the method of introspected class that implements JsonAnySetter.
 java.lang.reflect.Constructor<?> findDefaultConstructor()
          Method that will locate the no-arg constructor for this class, if it has one, and that constructor has not been marked as ignorable.
 java.lang.reflect.Method findFactoryMethod(java.lang.Class<?>... expArgTypes)
          Method that can be called to find if introspected class declares a static "valueOf" factory method that returns an instance of introspected type, given one of acceptable types.
 java.util.LinkedHashMap<java.lang.String,AnnotatedMethod> findGetters(boolean autodetect, java.util.Collection<java.lang.String> ignoredProperties)
           
 AnnotatedMethod findJsonValue()
          Method for locating the getter method that is annotated with JsonValue annotation, if any.
 AnnotatedMethod findMethod(java.lang.String name, java.lang.Class<?>[] paramTypes)
           
 java.util.LinkedHashMap<java.lang.String,AnnotatedMethod> findSetters(boolean autodetect)
           
 java.lang.reflect.Constructor<?> findSingleArgConstructor(java.lang.Class<?>... argTypes)
          Method that can be called to locate a single-arg constructor that takes specified exact type (will not accept supertype constructors)
protected
<A extends java.lang.annotation.Annotation>
AnnotatedMethod
findUniqueMethodWith(java.lang.Class<A> acls)
          Method for locating the member method that has given "unique" annotation.
<A extends java.lang.annotation.Annotation>
A
getClassAnnotation(java.lang.Class<A> acls)
           
 AnnotatedClass getClassInfo()
           
protected  boolean isCglibGetCallbacks(AnnotatedMethod am)
          This method was added to address [JACKSON-53]: need to weed out CGLib-injected "getCallbacks".
protected  boolean isGroovyMeta(AnnotatedMethod am)
          Similar to isCglibGetCallbacks(org.codehaus.jackson.map.introspect.AnnotatedMethod), need to suppress a cyclic reference to resolve [JACKSON-103]
protected  boolean isIgnored(AnnotatedMethod am)
          Helper method used to check whether given element (method, constructor, class) has enabled (active) instance of JsonIgnore annotation.
protected  java.lang.String mangleGetterName(Annotated a, java.lang.String basename)
           
static java.lang.String manglePropertyName(java.lang.String basename)
          Method called to figure out name of the property, given corresponding suggested name based on a method or field name.
protected  java.lang.String mangleSetterName(Annotated a, java.lang.String basename)
           
protected  java.lang.String okNameForGetter(AnnotatedMethod am)
           
protected  java.lang.String okNameForSetter(AnnotatedMethod am)
           
 boolean willWriteNullProperties(boolean defValue)
          Method for determining whether null properties should be written out for a Bean of introspected type.
 
Methods inherited from class org.codehaus.jackson.map.BeanDescription
getBeanClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicBeanDescription

public BasicBeanDescription(java.lang.Class<?> forClass,
                            AnnotatedClass ac)
Method Detail

getClassInfo

public AnnotatedClass getClassInfo()

getClassAnnotation

public <A extends java.lang.annotation.Annotation> A getClassAnnotation(java.lang.Class<A> acls)

findMethod

public AnnotatedMethod findMethod(java.lang.String name,
                                  java.lang.Class<?>[] paramTypes)

findGetters

public java.util.LinkedHashMap<java.lang.String,AnnotatedMethod> findGetters(boolean autodetect,
                                                                             java.util.Collection<java.lang.String> ignoredProperties)
Specified by:
findGetters in class BeanDescription
Parameters:
autodetect - Whether to use Bean naming convention to automatically detect bean properties; if true will do that, if false will require explicit annotations.
ignoredProperties - (optional, may be null) Names of properties to ignore; getters for these properties are not to be returned.
Returns:
Ordered Map with logical property name as key, and matching getter method as value.

findJsonValue

public AnnotatedMethod findJsonValue()
Method for locating the getter method that is annotated with JsonValue annotation, if any. If multiple ones are found, an error is reported by throwing IllegalArgumentException


findDefaultConstructor

public java.lang.reflect.Constructor<?> findDefaultConstructor()
Method that will locate the no-arg constructor for this class, if it has one, and that constructor has not been marked as ignorable. Method will also ensure that the constructor is accessible.


findSingleArgConstructor

public java.lang.reflect.Constructor<?> findSingleArgConstructor(java.lang.Class<?>... argTypes)
Method that can be called to locate a single-arg constructor that takes specified exact type (will not accept supertype constructors)

Parameters:
argTypes - Type(s) of the argument that we are looking for

findFactoryMethod

public java.lang.reflect.Method findFactoryMethod(java.lang.Class<?>... expArgTypes)
Method that can be called to find if introspected class declares a static "valueOf" factory method that returns an instance of introspected type, given one of acceptable types.

Parameters:
expArgTypes - Types that the matching single argument factory method can take: will also accept super types of these types (ie. arg just has to be assignable from expArgType)

findSetters

public java.util.LinkedHashMap<java.lang.String,AnnotatedMethod> findSetters(boolean autodetect)
Specified by:
findSetters in class BeanDescription
Returns:
Ordered Map with logical property name as key, and matching setter method as value.

findAnySetter

public AnnotatedMethod findAnySetter()
                              throws java.lang.IllegalArgumentException
Method used to locate the method of introspected class that implements JsonAnySetter. If no such method exists null is returned. If more than one are found, an exception is thrown. Additional checks are also made to see that method signature is acceptable: needs to take 2 arguments, first one String or Object; second any can be any type.

Throws:
java.lang.IllegalArgumentException

willWriteNullProperties

public boolean willWriteNullProperties(boolean defValue)
Method for determining whether null properties should be written out for a Bean of introspected type. This is based on global feature (lowest priority, passed as argument) and per-class annotation (highest priority).


okNameForGetter

protected java.lang.String okNameForGetter(AnnotatedMethod am)

mangleGetterName

protected java.lang.String mangleGetterName(Annotated a,
                                            java.lang.String basename)
Returns:
Null to indicate that method is not a valid accessor; otherwise name of the property it is accessor for

isCglibGetCallbacks

protected boolean isCglibGetCallbacks(AnnotatedMethod am)
This method was added to address [JACKSON-53]: need to weed out CGLib-injected "getCallbacks". At this point caller has detected a potential getter method with name "getCallbacks" and we need to determine if it is indeed injectect by Cglib. We do this by verifying that the result type is "net.sf.cglib.proxy.Callback[]"


isGroovyMeta

protected boolean isGroovyMeta(AnnotatedMethod am)
Similar to isCglibGetCallbacks(org.codehaus.jackson.map.introspect.AnnotatedMethod), need to suppress a cyclic reference to resolve [JACKSON-103]


okNameForSetter

protected java.lang.String okNameForSetter(AnnotatedMethod am)

mangleSetterName

protected java.lang.String mangleSetterName(Annotated a,
                                            java.lang.String basename)
Returns:
Null to indicate that method is not a valid accessor; otherwise name of the property it is accessor for

findUniqueMethodWith

protected <A extends java.lang.annotation.Annotation> AnnotatedMethod findUniqueMethodWith(java.lang.Class<A> acls)
Method for locating the member method that has given "unique" annotation. If more than one method is found to have the annotation, error is reported.


isIgnored

protected boolean isIgnored(AnnotatedMethod am)
Helper method used to check whether given element (method, constructor, class) has enabled (active) instance of JsonIgnore annotation.


manglePropertyName

public static java.lang.String manglePropertyName(java.lang.String basename)
Method called to figure out name of the property, given corresponding suggested name based on a method or field name.

Parameters:
basename - Name of accessor/mutator method, not including prefix ("get"/"is"/"set")

descFor

public static java.lang.String descFor(java.lang.reflect.AnnotatedElement elem)
Helper method used to describe an annotated element of type Class or Method.