net.sf.jso.schema
Class JSOStorableClass

java.lang.Object
  extended bynet.sf.jso.schema.JSOStorableClass
All Implemented Interfaces:
java.io.Serializable, StorableClass

public class JSOStorableClass
extends java.lang.Object
implements StorableClass

Meta class for storable classes.

See Also:
Serialized Form

Constructor Summary
JSOStorableClass(ClassDescriptor aDescriptor)
          Constructs the storable class.
 
Method Summary
 void addJavaSubclass(java.lang.Class aClass)
          Adds a class to the set of subclasses of the storable class.
 boolean check(StorableClass aClass)
          Checks this storable class against another one.
 boolean equals(java.lang.Object o)
          Indicates whether some other storable class is "equal to" this one.
static java.lang.reflect.Method getCallbackMethod(java.lang.Class aClass, java.lang.String method)
          Returns callback method, or null if class does not have the method.
 CID getCID()
          Returns the class' schema identification.
static java.lang.reflect.Field getContainerField()
          Returns a generic fake field for storing values of container classes.
 java.lang.reflect.Field getContainerValueField()
          Returns a generic fake field for storing values of container classes.
 java.lang.String getDeleteStatement()
          Returns the delete statement for an object in the form: delete from <table> where oid = ?
static java.lang.reflect.Field getField(java.lang.Class aClass, java.lang.String name)
          Returns a field, or null if class does not have the field.
 java.lang.Integer getFieldType(java.lang.reflect.Field field)
          Returns the type of a field as established in StorableField.
 long getId()
          Returns the cataloged id of this class descriptor's class.
 java.lang.String getInsertStatement()
          Returns an insert statement for an object in the form: insert into <table> (oid,<fields>) values (?
 java.util.Set getJavaAccessibleFields()
          Returns the set of accessible fields of the storable class.
 java.lang.Class getJavaClass()
          Returns the target java class.
 java.lang.reflect.Field getJavaField(java.lang.String fieldName)
          Returns a fields of the storable class.
 java.util.Set getJavaFields()
          Returns the set of fields of the storable class.
 java.util.Set getJavaReferenceFields()
          Returns the set of fields of the storable class that are from types StorableField.OBJECT or StorableField.CONTAINER.
 java.util.Set getJavaSubclasses()
          Returns the set of subclasses of the storable class.
 java.util.Set getJavaSummaryFields()
          Returns the set of summary fields of the storable class.
 java.util.Set getJavaSuperclasses()
          Returns the set of superclasses of the storable class.
 java.lang.reflect.Field getJsoMetadataField()
          Returns class's jsoMetadata field.
 java.lang.reflect.Method getJsoPostRetrieveMethod()
          Returns class's jsoPostRetrieve() method.
 java.lang.reflect.Method getJsoPreDeleteMethod()
          Returns class's jsoPreDelete() method.
 java.lang.reflect.Method getJsoPreStoreMethod()
          Returns class's jsoPreStore() method.
 java.lang.String getSelectStatement(boolean summary)
          Returns a select statement for an object in the form: select <fields> from <table> where oid = ?
 java.lang.String getTableName()
          Returns the name of the storable class's corresponding table.
 java.lang.String getUpdateStatement()
          Returns an update statement for an object in the form: update <table> set <fields = ?
static java.lang.reflect.Field getValueField()
          Returns a generic fake field for storing values of wrapper classes.
 java.lang.reflect.Constructor getVoidConstructor()
          Returns class's void constructor.
 java.lang.reflect.Field getWrapperValueField()
          Returns a generic fake field for storing values of wrapper classes.
 int hashCode()
          Returns a hash code value for the class descriptor.
 boolean isAccessible(java.lang.reflect.Field field)
          Indicates if the supplied field is accessible.
 boolean isChecked()
          Indicates if this storable class has been checked agains corresponding class.
 boolean isCollectionType()
          Indicates if storable class is a collection type.
 boolean isContainerType()
          Indicates if storable class is a container type.
 boolean isGarbageCollectable()
          Indicates if the storable class is garabage collectable.
 boolean isMapType()
          Indicates if storable class is a map type.
 boolean isStorableType()
          Indicates if storable class is a storable type.
 boolean isSummary(java.lang.reflect.Field field)
          Indicates if the supplied field is a summary field.
 java.lang.Object newInstance()
          Creates new instance of storable class' target java class.
 java.lang.Object newProxy(OID oid, boolean isSummary, StorageManager aManager)
          Creates a new proxy to storable class' target java class.
 void removeJavaSubclass(java.lang.Class aClass)
          Removes a class to the set of subclasses of the storable class.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSOStorableClass

public JSOStorableClass(ClassDescriptor aDescriptor)
                 throws StorageException
Constructs the storable class.

Parameters:
aDescriptor - Correspondin class descriptor.
Method Detail

getJavaClass

public java.lang.Class getJavaClass()
Returns the target java class.

Specified by:
getJavaClass in interface StorableClass
Returns:
The target java class.

getId

public long getId()
Returns the cataloged id of this class descriptor's class.

Specified by:
getId in interface StorableClass
Returns:
Class' schema identification.

getCID

public CID getCID()
Returns the class' schema identification.

Specified by:
getCID in interface StorableClass
Returns:
Class' schema identification.

isChecked

public boolean isChecked()
Indicates if this storable class has been checked agains corresponding class.

Specified by:
isChecked in interface StorableClass
Returns:
true if descriptor has been checked; false otherwise.

isGarbageCollectable

public boolean isGarbageCollectable()
Indicates if the storable class is garabage collectable.

Specified by:
isGarbageCollectable in interface StorableClass
Returns:
true if the storable class is garabage collectable; false> otherwise.

getJavaField

public java.lang.reflect.Field getJavaField(java.lang.String fieldName)
                                     throws StorageException
Returns a fields of the storable class.

Specified by:
getJavaField in interface StorableClass
Parameters:
fieldName - The name of the field to be returned.
Returns:
The field with the supplied name.
Throws:
StorageException - If no such field exists int the class.

getFieldType

public java.lang.Integer getFieldType(java.lang.reflect.Field field)
                               throws StorageException
Returns the type of a field as established in StorableField.

Specified by:
getFieldType in interface StorableClass
Parameters:
field - The field of which the name should be returned.
Returns:
The type of the field.
Throws:
StorageException - If no such field exists int the class.

getJsoMetadataField

public java.lang.reflect.Field getJsoMetadataField()
Returns class's jsoMetadata field.

Specified by:
getJsoMetadataField in interface StorableClass
Returns:
The jsoMetadata field.

getJsoPreStoreMethod

public java.lang.reflect.Method getJsoPreStoreMethod()
Returns class's jsoPreStore() method.

Specified by:
getJsoPreStoreMethod in interface StorableClass
Returns:
The jsoPreStore() method if class has it; null otherwise.

getJsoPostRetrieveMethod

public java.lang.reflect.Method getJsoPostRetrieveMethod()
Returns class's jsoPostRetrieve() method.

Specified by:
getJsoPostRetrieveMethod in interface StorableClass
Returns:
The jsoPostRetrieve() method if class has it; null otherwise.

getJsoPreDeleteMethod

public java.lang.reflect.Method getJsoPreDeleteMethod()
Returns class's jsoPreDelete() method.

Specified by:
getJsoPreDeleteMethod in interface StorableClass
Returns:
The jsoPreDelete() method if class has it; null otherwise.

getVoidConstructor

public java.lang.reflect.Constructor getVoidConstructor()
Returns class's void constructor.

Specified by:
getVoidConstructor in interface StorableClass
Returns:
The void constructor if class has it; null otherwise.

isSummary

public boolean isSummary(java.lang.reflect.Field field)
                  throws StorageException
Indicates if the supplied field is a summary field.

Specified by:
isSummary in interface StorableClass
Returns:
true if the field is part of the class' summary; false otherwise;
Throws:
StorageException

isAccessible

public boolean isAccessible(java.lang.reflect.Field field)
                     throws StorageException
Indicates if the supplied field is accessible.

Specified by:
isAccessible in interface StorableClass
Returns:
true if the field may be accessed during query processing; false otherwise;
Throws:
StorageException

getValueField

public static java.lang.reflect.Field getValueField()
Returns a generic fake field for storing values of wrapper classes.


getWrapperValueField

public java.lang.reflect.Field getWrapperValueField()
Returns a generic fake field for storing values of wrapper classes.

Specified by:
getWrapperValueField in interface StorableClass
Returns:
Field used for wrapper classes' values.

getContainerField

public static java.lang.reflect.Field getContainerField()
Returns a generic fake field for storing values of container classes.


getContainerValueField

public java.lang.reflect.Field getContainerValueField()
Returns a generic fake field for storing values of container classes.

Specified by:
getContainerValueField in interface StorableClass
Returns:
Field used for container classes' values.

getJavaFields

public java.util.Set getJavaFields()
Returns the set of fields of the storable class.

Specified by:
getJavaFields in interface StorableClass
Returns:
The set of fields of the storable class.

getJavaAccessibleFields

public java.util.Set getJavaAccessibleFields()
Returns the set of accessible fields of the storable class.

Specified by:
getJavaAccessibleFields in interface StorableClass
Returns:
The set of accessible fields of the storable class.

getJavaSummaryFields

public java.util.Set getJavaSummaryFields()
Returns the set of summary fields of the storable class.

Specified by:
getJavaSummaryFields in interface StorableClass
Returns:
The set of summary fields of the storable class.

getJavaReferenceFields

public java.util.Set getJavaReferenceFields()
Returns the set of fields of the storable class that are from types StorableField.OBJECT or StorableField.CONTAINER.

Specified by:
getJavaReferenceFields in interface StorableClass
Returns:
The set of OBJECT and CONTAINER fields of the storable class.

getJavaSubclasses

public java.util.Set getJavaSubclasses()
Returns the set of subclasses of the storable class.

Specified by:
getJavaSubclasses in interface StorableClass
Returns:
The set of subclasses of the storable class.

getJavaSuperclasses

public java.util.Set getJavaSuperclasses()
Returns the set of superclasses of the storable class.

Specified by:
getJavaSuperclasses in interface StorableClass
Returns:
The set of superclasses of the storable class.

addJavaSubclass

public void addJavaSubclass(java.lang.Class aClass)
Adds a class to the set of subclasses of the storable class.

Specified by:
addJavaSubclass in interface StorableClass
Parameters:
aClass - The class to be added.

removeJavaSubclass

public void removeJavaSubclass(java.lang.Class aClass)
Removes a class to the set of subclasses of the storable class.

Specified by:
removeJavaSubclass in interface StorableClass
Parameters:
aClass - The class to be removed.

getTableName

public java.lang.String getTableName()
Returns the name of the storable class's corresponding table.

Specified by:
getTableName in interface StorableClass
Returns:
The name of the storable class's corresponding table.

getInsertStatement

public java.lang.String getInsertStatement()
Returns an insert statement for an object in the form:
insert into <table> (oid,<fields>) values (?,<?>)

Specified by:
getInsertStatement in interface StorableClass
Returns:
A string to be used in a prepared statement.

getUpdateStatement

public java.lang.String getUpdateStatement()
Returns an update statement for an object in the form:
update <table> set <fields = ?> where oid = ?

Specified by:
getUpdateStatement in interface StorableClass
Returns:
A string to be used in a prepared statement. May return null if class has no fields.

getDeleteStatement

public java.lang.String getDeleteStatement()
Returns the delete statement for an object in the form:
delete from <table> where oid = ?

Specified by:
getDeleteStatement in interface StorableClass
Returns:
A string to be used in a prepared statement.

getSelectStatement

public java.lang.String getSelectStatement(boolean summary)
Returns a select statement for an object in the form:
select <fields> from <table> where oid = ?

Specified by:
getSelectStatement in interface StorableClass
Parameters:
summary - If true only summary fields are included in the statement; otherwise all fields are included.
Returns:
A string to be used in a prepared statement. May return null if class has no fields.

check

public boolean check(StorableClass aClass)
Checks this storable class against another one.

Specified by:
check in interface StorableClass
Parameters:
aClass - The class to be checked against.
Returns:
true if check was successfull; false otherwise.

equals

public boolean equals(java.lang.Object o)
Indicates whether some other storable class is "equal to" this one.

Parameters:
o - The object with which to compare.
Returns:
true if the storable class is the same as the storable class argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the class descriptor.

Returns:
A hash code value for the class descriptor.

getField

public static java.lang.reflect.Field getField(java.lang.Class aClass,
                                               java.lang.String name)
Returns a field, or null if class does not have the field.


getCallbackMethod

public static java.lang.reflect.Method getCallbackMethod(java.lang.Class aClass,
                                                         java.lang.String method)
Returns callback method, or null if class does not have the method.


isContainerType

public boolean isContainerType()
Indicates if storable class is a container type.

Specified by:
isContainerType in interface StorableClass
Returns:
true if storable class is a collection or a map type; false otherwise.

isCollectionType

public boolean isCollectionType()
Indicates if storable class is a collection type.

Specified by:
isCollectionType in interface StorableClass
Returns:
true if storable class is a collection type; false otherwise.

isMapType

public boolean isMapType()
Indicates if storable class is a map type.

Specified by:
isMapType in interface StorableClass
Returns:
true if storable class is a map type; false otherwise.

isStorableType

public boolean isStorableType()
Indicates if storable class is a storable type.

Specified by:
isStorableType in interface StorableClass
Returns:
true if storable class is a storable type; false otherwise.

newInstance

public java.lang.Object newInstance()
                             throws StorageException
Creates new instance of storable class' target java class.

Specified by:
newInstance in interface StorableClass
Returns:
An object of storable class' target java class.
Throws:
StorageException

newProxy

public java.lang.Object newProxy(OID oid,
                                 boolean isSummary,
                                 StorageManager aManager)
                          throws StorageException
Creates a new proxy to storable class' target java class.

Specified by:
newProxy in interface StorableClass
Parameters:
oid - Target object's identification.
isSummary - If only summary fields of target object should be used.
aManager - Storage manager to which proxy will communicate.
Returns:
A proxy to storable class' target java class.
Throws:
StorageException