org.ckkloverdos.beans
Class JavaBeanProperty

java.lang.Object
  extended by org.ckkloverdos.beans.JavaBeanProperty

public class JavaBeanProperty
extends java.lang.Object

A generic representation of a JavaBean property. It provides utility methods to retrieve its accessor, either as property names (getPropertyAccessor(boolean)) or as getter method calls (getReadMethodAccesor(boolean)).

This is useful in a scripting or code generation environment.

Author:
Christos KK Loverdos

Constructor Summary
JavaBeanProperty(java.lang.Class c)
          Constructs a JavaBeanProperty for the given class c.
JavaBeanProperty(java.lang.Class c, JavaTypeRegistry typeRegistry)
          Constructs a JavaBeanProperty for the given class c, using the typeRegistry to resolve types.
JavaBeanProperty(java.lang.String name, java.lang.Class c, JavaTypeRegistry typeRegistry)
          Constructs a JavaBeanProperty for the given class c, using the typeRegistry to resolve types and name as the property name.
 
Method Summary
 java.lang.String getFullName()
          Returns the fully qualified name of this property.
 java.lang.String getFullName(boolean includeTopParent)
          Returns the fully qualified name of this property, with the option to include the top parent name in it.
 NameAndType getFullNameType()
           
 NameAndType getFullNameType(boolean includeTopParent)
           
 java.lang.Class getJavaClass()
          Returns the java class of this property.
 java.lang.String getName()
          Returns the non-qualified name of this property.
 NameAndType getNameType()
           
 JavaBeanProperty getParent()
          Returns the parent property.
 JavaBeanProperty[] getProperties()
          Returns the sub-properties.
 JavaBeanProperty getProperty(java.lang.String name)
          Returns the named sub-property of the property represented by this instance.
 java.lang.String getPropertyAccessor(boolean fullyQualified)
          Returns an accessor for this property, based on direct property access.
 java.lang.String getPropertyAccessor(boolean fullyQualified, boolean includeTopParent)
          Returns an accessor for this property, based on direct property access.
 java.lang.String getReadMethodAccesor(boolean fullyQualified)
          Returns an accessor for this property, based on read method calls.
 java.lang.String getReadMethodAccesor(boolean fullyQualified, boolean includeTopParent)
          Returns an accessor for this property, based on read method calls.
 java.lang.String getReadMethodName()
          Returns the method name used to read this property.
 JavaType getType()
          Returns the type of this property.
 JavaTypeRegistry getTypeRegistry()
          Returns the JavaTypeRegistry given in this or the other constructor.
 boolean hasProperty(java.lang.String name)
          Returns true iff name is a sub-property of the property represented by this instance.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaBeanProperty

public JavaBeanProperty(java.lang.Class c)
Constructs a JavaBeanProperty for the given class c. The name of the property is the empty string.

Parameters:
c -

JavaBeanProperty

public JavaBeanProperty(java.lang.Class c,
                        JavaTypeRegistry typeRegistry)
Constructs a JavaBeanProperty for the given class c, using the typeRegistry to resolve types. The name of the property is the empty string.

Parameters:
c -
typeRegistry -

JavaBeanProperty

public JavaBeanProperty(java.lang.String name,
                        java.lang.Class c,
                        JavaTypeRegistry typeRegistry)
Constructs a JavaBeanProperty for the given class c, using the typeRegistry to resolve types and name as the property name.

Parameters:
name -
c -
typeRegistry -
Method Detail

getTypeRegistry

public JavaTypeRegistry getTypeRegistry()
Returns the JavaTypeRegistry given in this or the other constructor.


getProperties

public JavaBeanProperty[] getProperties()
Returns the sub-properties.


getParent

public JavaBeanProperty getParent()
Returns the parent property.


getName

public java.lang.String getName()
Returns the non-qualified name of this property.


getType

public JavaType getType()
Returns the type of this property.


getNameType

public NameAndType getNameType()

getFullNameType

public NameAndType getFullNameType()

getFullNameType

public NameAndType getFullNameType(boolean includeTopParent)

getFullName

public java.lang.String getFullName()
Returns the fully qualified name of this property. If this instance has been created from a root property using successive getProperty(String) calls, then the whole property hierarchy will appear in the full name.


getFullName

public java.lang.String getFullName(boolean includeTopParent)
Returns the fully qualified name of this property, with the option to include the top parent name in it.

Parameters:
includeTopParent -

getJavaClass

public java.lang.Class getJavaClass()
Returns the java class of this property.


getReadMethodName

public java.lang.String getReadMethodName()
Returns the method name used to read this property.


hasProperty

public boolean hasProperty(java.lang.String name)
Returns true iff name is a sub-property of the property represented by this instance.

Parameters:
name -

getPropertyAccessor

public java.lang.String getPropertyAccessor(boolean fullyQualified)
Returns an accessor for this property, based on direct property access. This method could be useful in scripting.

Parameters:
fullyQualified -

getPropertyAccessor

public java.lang.String getPropertyAccessor(boolean fullyQualified,
                                            boolean includeTopParent)
Returns an accessor for this property, based on direct property access. This method could be useful in scripting.

Parameters:
fullyQualified -
includeTopParent -

getReadMethodAccesor

public java.lang.String getReadMethodAccesor(boolean fullyQualified)
Returns an accessor for this property, based on read method calls. This method could be useful in scripting.

Parameters:
fullyQualified -

getReadMethodAccesor

public java.lang.String getReadMethodAccesor(boolean fullyQualified,
                                             boolean includeTopParent)
Returns an accessor for this property, based on read method calls. This method could be useful in scripting.

Parameters:
fullyQualified -
includeTopParent -

getProperty

public JavaBeanProperty getProperty(java.lang.String name)
Returns the named sub-property of the property represented by this instance.

Parameters:
name -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 1999-2007 Christos KK Loverdos. All Rights Reserved.