net.sf.stitch.crud
Class CrudEntityProperty

java.lang.Object
  extended by net.sf.stitch.crud.CrudEntityProperty

public class CrudEntityProperty
extends java.lang.Object

Represents an Entity Property. We track the Field and the Getter and Setter Methods because annotations may be made at either the field or the getter method, and the presence of a setter tells us the field is not read-only.

Author:
Logan Hutchinson

Constructor Summary
CrudEntityProperty(java.lang.reflect.Field field)
           
 
Method Summary
 java.lang.String getConverter()
          Gets the appropriate converter for the property.
 javax.persistence.EnumType getEnumType()
          Gets the Enumeration Type.
 java.lang.reflect.Field getField()
           
 java.lang.String getFieldName()
          Convenience method to get the name of the field.
 java.lang.reflect.Method getGetter()
           
 java.lang.Integer getMaxLength()
           
 java.lang.String getMessageKey()
          Gets the resource bundle key for translating the field into a localized message.
 java.lang.reflect.Method getSetter()
           
 int getSize()
           
 javax.persistence.TemporalType getTemporalType()
          Gets the Temporal Type.
 boolean isBoolean()
          Is the field a boolean (true/false, yes/no).
 boolean isEnum()
          Is the field an enum.
 boolean isFetchLazy()
           
 boolean isId()
          Is the property annotated with @Id
 boolean isListable()
          Is the property listable from the EntityQuery.
 boolean isLob()
          Is the property annotated with @Lob
 boolean isReadOnly()
          If the property has no setter, the field is read-only.
 boolean isRequired()
          Whether the field is required is determined from the type and its annotations.
 boolean isSearchable()
          Is the property searchable from the EntityQuery.
 boolean isVersion()
          Is the property annotated with @Version
 void setGetter(java.lang.reflect.Method getter)
           
 void setSetter(java.lang.reflect.Method setter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrudEntityProperty

public CrudEntityProperty(java.lang.reflect.Field field)
Method Detail

getGetter

public java.lang.reflect.Method getGetter()

setGetter

public void setGetter(java.lang.reflect.Method getter)

getSetter

public java.lang.reflect.Method getSetter()

setSetter

public void setSetter(java.lang.reflect.Method setter)

getField

public java.lang.reflect.Field getField()

getFieldName

public java.lang.String getFieldName()
Convenience method to get the name of the field.

Returns:
See Field.getName()

isReadOnly

public boolean isReadOnly()
If the property has no setter, the field is read-only.

Returns:
True if no setter is specified, False otherwise.

isRequired

public boolean isRequired()
Whether the field is required is determined from the type and its annotations.

Returns:
True if a null value is unacceptable, False otherwise.

isId

public boolean isId()
Is the property annotated with @Id

Returns:
true if the property is annotated with @Id, false otherwise.

isVersion

public boolean isVersion()
Is the property annotated with @Version

Returns:
true if the property is annotated with @Version, false otherwise.

isLob

public boolean isLob()
Is the property annotated with @Lob

Returns:
true if the property is annotated with @Lob, false otherwise.

isFetchLazy

public boolean isFetchLazy()
Returns:
true if the property is annotated with

isBoolean

public boolean isBoolean()
Is the field a boolean (true/false, yes/no).

Returns:
true if the field class is a Boolean or boolean.

isEnum

public boolean isEnum()
Is the field an enum.

Returns:
true if the field is an enum, false otherwise.

isSearchable

public boolean isSearchable()
Is the property searchable from the EntityQuery. In other words, would you want to search for matches on this property. TODO Rethink name (searchable). Can this be expanded beyond String?

Returns:
true if the field is a String, false otherwise.

isListable

public boolean isListable()
Is the property listable from the EntityQuery. In other words, would you want the field to appear in a one-line summary for the entity. TODO Rethink name (listable). Can this be derived differently?


getMaxLength

public java.lang.Integer getMaxLength()
Returns:
The maximum length of the property.

getSize

public int getSize()
Returns:
Reasonable estimate for input box size.

getMessageKey

public java.lang.String getMessageKey()
Gets the resource bundle key for translating the field into a localized message.

Returns:
Typically, package.class.field

getEnumType

public javax.persistence.EnumType getEnumType()
Gets the Enumeration Type.

Returns:
EnumType for enum fields. This is only applicable for enum properties.

getTemporalType

public javax.persistence.TemporalType getTemporalType()
Gets the Temporal Type.

Returns:
TemporalType if a @Temporal annotation is present.

getConverter

public java.lang.String getConverter()
Gets the appropriate converter for the property.

Returns:
Converter tag that can be embedded in a facelet, if applicable. Otherwise a null is returned.


Copyright © 2007. All Rights Reserved.