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
_type
 
Constructor Summary
BasicBeanDescription(JavaType type, AnnotatedClass ac, AnnotationIntrospector ai)
           
 
Method Summary
 LinkedHashMap<String,AnnotatedField> _findPropertyFields(boolean autodetect, Collection<String> ignoredProperties, boolean forSerialization)
           
 Class<?> classDescribed()
           
static String descFor(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.
 List<String> findCreatorPropertyNames()
          Method for getting ordered list of named Creator properties.
 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.
 LinkedHashMap<String,AnnotatedField> findDeserializableFields(boolean autodetect, Collection<String> ignoredProperties)
           
 Method findFactoryMethod(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.
 LinkedHashMap<String,AnnotatedMethod> findGetters(boolean getterAutoDetect, boolean isGetterAutoDetect, Collection<String> ignoredProperties)
           
 AnnotatedMethod findJsonValueMethod()
          Method for locating the getter method that is annotated with JsonValue annotation, if any.
 AnnotatedMethod findMethod(String name, Class<?>[] paramTypes)
           
 LinkedHashMap<String,AnnotatedField> findSerializableFields(boolean autodetect, Collection<String> ignoredProperties)
           
 JsonSerialize.Inclusion findSerializationInclusion(JsonSerialize.Inclusion defValue)
          Method for determining whether null properties should be written out for a Bean of introspected type.
 LinkedHashMap<String,AnnotatedMethod> findSetters(boolean autodetect)
           
 Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
          Method that can be called to locate a single-arg constructor that takes specified exact type (will not accept supertype constructors)
 AnnotatedClass getClassInfo()
           
 List<AnnotatedConstructor> getConstructors()
           
 List<AnnotatedMethod> getFactoryMethods()
           
 boolean hasKnownClassAnnotations()
          Method for checking whether class being described has any annotations recognized by registered annotation introspector.
 Object instantiateBean(boolean fixAccess)
           
protected  boolean isCglibGetCallbacks(AnnotatedMethod am)
          This method was added to address [JACKSON-53]: need to weed out CGLib-injected "getCallbacks".
protected  boolean isFactoryMethod(AnnotatedMethod am)
           
protected  boolean isGroovyMetaClassGetter(AnnotatedMethod am)
          Another helper method to deal with rest of [JACKSON-103]
protected  boolean isGroovyMetaClassSetter(AnnotatedMethod am)
          Similar to isCglibGetCallbacks(org.codehaus.jackson.map.introspect.AnnotatedMethod), need to suppress a cyclic reference to resolve [JACKSON-103]
protected  String mangleGetterName(Annotated a, String basename)
           
static String manglePropertyName(String basename)
          Method called to figure out name of the property, given corresponding suggested name based on a method or field name.
protected  String mangleSetterName(Annotated a, String basename)
           
 String okNameForAnyGetter(AnnotatedMethod am, String name)
           
 String okNameForGetter(AnnotatedMethod am, String name)
           
 String okNameForIsGetter(AnnotatedMethod am, String name)
           
 String okNameForSetter(AnnotatedMethod am)
           
 
Methods inherited from class org.codehaus.jackson.map.BeanDescription
getBeanClass, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicBeanDescription

public BasicBeanDescription(JavaType type,
                            AnnotatedClass ac,
                            AnnotationIntrospector ai)
Method Detail

getClassInfo

public AnnotatedClass getClassInfo()

classDescribed

public Class<?> classDescribed()

hasKnownClassAnnotations

public boolean hasKnownClassAnnotations()
Method for checking whether class being described has any annotations recognized by registered annotation introspector.


findMethod

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

instantiateBean

public Object instantiateBean(boolean fixAccess)
Parameters:
fixAccess - If true, method is allowed to fix access to the default constructor (to be able to call non-public constructor); if false, has to use constructor as is.
Returns:
Instance of class represented by this descriptor, if suitable default constructor was found; null otherwise.

findGetters

public LinkedHashMap<String,AnnotatedMethod> findGetters(boolean getterAutoDetect,
                                                         boolean isGetterAutoDetect,
                                                         Collection<String> ignoredProperties)
Specified by:
findGetters in class BeanDescription
Parameters:
getterAutoDetect - Whether to use Bean naming convention to automatically detect bean properties matching 'getXxx' methods (unless overridden by per-class annotations)
isGetterAutoDetect - Whether to use Bean naming convention to automatically detect boolean bean properties matching 'isXxx' methods (unless overridden by per-class 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.

findJsonValueMethod

public AnnotatedMethod findJsonValueMethod()
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 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.


getConstructors

public List<AnnotatedConstructor> getConstructors()

getFactoryMethods

public List<AnnotatedMethod> getFactoryMethods()

findSingleArgConstructor

public Constructor<?> findSingleArgConstructor(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 Method findFactoryMethod(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)

isFactoryMethod

protected boolean isFactoryMethod(AnnotatedMethod am)

findCreatorPropertyNames

public List<String> findCreatorPropertyNames()
Method for getting ordered list of named Creator properties. Returns an empty list is none found. If multiple Creator methods are defined, order between properties from different methods is undefined; however, properties for each such Creator are ordered properly relative to each other. For the usual case of just a single Creator, named properties are thus properly ordered.


findSerializableFields

public LinkedHashMap<String,AnnotatedField> findSerializableFields(boolean autodetect,
                                                                   Collection<String> ignoredProperties)

findSerializationInclusion

public JsonSerialize.Inclusion findSerializationInclusion(JsonSerialize.Inclusion 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).


findSetters

public LinkedHashMap<String,AnnotatedMethod> findSetters(boolean autodetect)
Specified by:
findSetters in class BeanDescription
Parameters:
autodetect - Whether setter auto-detection is on: if true, it is enough for a method to have appropriate signature and name ("set[PropertyName]") to qualify; if false, it must have an annotation to be considered.
Returns:
Ordered Map with logical property name as key, and matching setter method as value.

findAnySetter

public AnnotatedMethod findAnySetter()
                              throws 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:
IllegalArgumentException

findDeserializableFields

public LinkedHashMap<String,AnnotatedField> findDeserializableFields(boolean autodetect,
                                                                     Collection<String> ignoredProperties)

okNameForAnyGetter

public String okNameForAnyGetter(AnnotatedMethod am,
                                 String name)

okNameForGetter

public String okNameForGetter(AnnotatedMethod am,
                              String name)

okNameForIsGetter

public String okNameForIsGetter(AnnotatedMethod am,
                                String name)

mangleGetterName

protected String mangleGetterName(Annotated a,
                                  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[]"

Also, see [JACKSON-177]; Hibernate may repackage cglib it uses, so we better catch that too


isGroovyMetaClassSetter

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


isGroovyMetaClassGetter

protected boolean isGroovyMetaClassGetter(AnnotatedMethod am)
Another helper method to deal with rest of [JACKSON-103]


okNameForSetter

public String okNameForSetter(AnnotatedMethod am)

mangleSetterName

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

_findPropertyFields

public LinkedHashMap<String,AnnotatedField> _findPropertyFields(boolean autodetect,
                                                                Collection<String> ignoredProperties,
                                                                boolean forSerialization)
Parameters:
autodetect - Whether to automatically detect public fields as properties; if true will do that, if false will require explicit annotations.
ignoredProperties - (optional) names of properties to ignore; any fields that would be recognized as one of these properties is ignored.
forSerialization - If true, will collect serializable property fields; if false, deserializable
Returns:
Ordered Map with logical property name as key, and matching field as value.

manglePropertyName

public static String manglePropertyName(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 String descFor(AnnotatedElement elem)
Helper method used to describe an annotated element of type Class or Method.