org.apache.commons.clazz.reflect.common
Class AccessorMethodParser

java.lang.Object
  extended by org.apache.commons.clazz.reflect.common.AccessorMethodParser
Direct Known Subclasses:
ExtendedReflectedListPropertyIntrospector.AddAccessorMethodParser, ExtendedReflectedListPropertyIntrospector.AddIndexedAccessorMethodParser, ExtendedReflectedListPropertyIntrospector.RemoveAccessorMethodParser, ExtendedReflectedListPropertyIntrospector.RemoveIndexedAccessorMethodParser, ExtendedReflectedListPropertyIntrospector.SizeAccessorMethodParser, ReflectedListPropertyIntrospectorSupport.GetAccessorMethodParser, ReflectedListPropertyIntrospectorSupport.ReadAccessorMethodParser, ReflectedListPropertyIntrospectorSupport.SetAccessorMethodParser, ReflectedListPropertyIntrospectorSupport.WriteAccessorMethodParser, ReflectedMappedPropertyIntrospector.GetAccessorMethodParser, ReflectedMappedPropertyIntrospector.KeySetAccessorMethodParser, ReflectedMappedPropertyIntrospector.PutAccessorMethodParser, ReflectedMappedPropertyIntrospector.ReadAccessorMethodParser, ReflectedMappedPropertyIntrospector.RemoveAccessorMethodParser, ReflectedMappedPropertyIntrospector.WriteAccessorMethodParser, ReflectedScalarPropertyIntrospector.ReadAccessorMethodParser, ReflectedScalarPropertyIntrospector.WriteAccessorMethodParser

public class AccessorMethodParser
extends Object

Version:
$Id: AccessorMethodParser.java 155436 2005-02-26 13:17:48Z dirkv $
Author:
Dmitri Plotnikov

Constructor Summary
AccessorMethodParser()
           
 
Method Summary
protected  String decapitalize(String string)
          Changes the first character of the string to lower case, unless the second character is upper case.
protected  Class getParameterType(Method method)
          Extract the parameter type from the method, if it has one.
protected  String getPropertyName(Method method)
          Parse method name and return the corresponding property name.
protected  Class getValueType(Method method)
          Extract the value type from the method.
 AccessorMethodParseResults parse(Method method)
          Parses the supplied method according to the parser's configuration.
protected  int requiredParameterCount()
          If a method parsed by this parser must have a number or parameters, override and return that number.
protected  String requiredPrefix()
          If a method parsed by this parser must have a certain prefix, override and return a non-null prefix string
protected  String testAndRemoveSuffix(String methodName)
          If a method parsed by this parser must have a certain suffix, override this method, check that it does and remove the suffix.
protected  boolean testFirstCharacterOfPropertyName(char ch)
          Returns true if the character can be the first character of a Capitalized property name.
protected  boolean testParameterType(int index, Class parameterType)
          To check constraints on the type of a parameter, override and perform the check.
protected  boolean testReturnType(Class javaClass)
          To check constraints on the return type of methods parsed by this parser, override and perform the check.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessorMethodParser

public AccessorMethodParser()
Method Detail

requiredParameterCount

protected int requiredParameterCount()
If a method parsed by this parser must have a number or parameters, override and return that number.


requiredPrefix

protected String requiredPrefix()
If a method parsed by this parser must have a certain prefix, override and return a non-null prefix string


testReturnType

protected boolean testReturnType(Class javaClass)
To check constraints on the return type of methods parsed by this parser, override and perform the check.

Parameters:
javaClass - The return type of the method (never null)
Returns:
boolean True if the return type passes the parser's constraints

testParameterType

protected boolean testParameterType(int index,
                                    Class parameterType)
To check constraints on the type of a parameter, override and perform the check.

Parameters:
javaClass - The return type of the method (never null)
Returns:
boolean True if the return type passes the parser's constraints

testAndRemoveSuffix

protected String testAndRemoveSuffix(String methodName)
If a method parsed by this parser must have a certain suffix, override this method, check that it does and remove the suffix.


testFirstCharacterOfPropertyName

protected boolean testFirstCharacterOfPropertyName(char ch)
Returns true if the character can be the first character of a Capitalized property name.


getValueType

protected Class getValueType(Method method)
Extract the value type from the method. Depending on the type of method, it could be the return type or the type of a parameter.


getParameterType

protected Class getParameterType(Method method)
Extract the parameter type from the method, if it has one. For example a mapped property "get" method might have a "key" parameter.


parse

public AccessorMethodParseResults parse(Method method)
Parses the supplied method according to the parser's configuration. If the parse process fails, returns null.

Parameters:
method -
Returns:
AccessorMethodParseResults

getPropertyName

protected String getPropertyName(Method method)
Parse method name and return the corresponding property name. Return null if the method name does not satisfy the parser's grammar.

The default implementation of the method checks if the method name starts with the specified prefix followed by an optionally capitalized property name.

Parameters:
methodName -
Returns:
String

decapitalize

protected String decapitalize(String string)
Changes the first character of the string to lower case, unless the second character is upper case. This is consistent with the JavaBean specification.

Parameters:
candidate -
Returns:
String


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.