wt.fc
Class PersistenceHelper

java.lang.Object
  extended bywt.fc.PersistenceHelper
All Implemented Interfaces:
Serializable

public class PersistenceHelper
extends Object
implements Serializable

The class contains utility methods associated with the PersistenceManager.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
static String DB_ENCODING
           
static int DB_MAX_BYTES_PER_CHAR
           
static int DB_MAX_SQL_STRING_SIZE
           
static PersistenceManager manager
          

Supported API: true
static int NAVIGATE_RESULT_LINK_INDEX
           
static int NAVIGATE_RESULT_ROLE_INDEX
           
private static String RESOURCE
           
 
Constructor Summary
PersistenceHelper()
           
 
Method Summary
static NavigateSpec buildNavigateSpec(Object source, String role, Class linkClass, boolean onlyOtherSide)
          This method builds a query specification for navigating an association.
static boolean checkStoredLength(String str, int max_length)
          Check the length of a string against a maximum length.
static boolean checkStoredLength(String str, int max_length, boolean enforce_varchar_limit)
          Check the length of a string against a maximum length.
static boolean equals(Persistable p, Object o)
          Determines if two objects are equal from a persistence perspective by comparing their ObjectIdentifiers.
static Timestamp getCreateStamp(Persistable obj)
          Retrives the create timestamp for the given Persistable object.
static Timestamp getModifyStamp(Persistable obj)
          Retrives the modify timestamp for the given Persistable object.
static ObjectIdentifier getObjectIdentifier(Persistable obj)
          Retrives the object identifier for the given Persistable object.
static int getStoredLength(Object obj, String str)
          Deprecated. Replaced by checkStoredLength(String, int)
static QueryResult getUnassignedObjects()
          Finds all Persistable objects that don't have an ObjectIdentifier with an assigned id value.
static SearchCondition getUnassignedOidSearchCondition(Class a_class)
          Creates a SearchCondition that will find all objects of a given class that don't have an ObjectIdentifier with an assigned id value.
static int hashCode(Persistable p)
          Returns a hash code based on the object's ObjectIdentifier If the object does not have an oid, then returns a hash code based on the object's memory location.
static boolean isDeleted(Persistable obj)
          Returns true if the specified persistable object is marked as deleted.
static boolean isEquivalent(Persistable obj1, Persistable obj2)
          Returns true if the two given objects are equivalent persistable object.
static boolean isPersistent(Object obj)
          Returns true if the given object is Peristable and has already been saved in the database.
static boolean isPersistent(Persistable obj)
          Returns true if the given Persistable object is saved in the datastore.
static void makeNonPersistent(Persistable obj)
          Indicate that the given object is no longer concidered to be persistent.
static QueryResult navigate(Object source, String role, Class linkClass, boolean onlyOtherSide)
          Retrieves objects related to the specfied source object(s) role and link class.
static WTList navigateToOtherSideObjectList(Object a_source, String a_role, Class a_linkClass)
          Retrieves objects related to the specified source object(s), role, and link class.
static String truncateStoredLength(Object obj, String str, int len)
          Deprecated. Replaced by truncateStoredLength(String, int)
static String truncateStoredLength(String str, int max_length)
          Return truncation of given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

manager

public static final PersistenceManager manager


Supported API: true


DB_ENCODING

public static final String DB_ENCODING

DB_MAX_BYTES_PER_CHAR

public static final int DB_MAX_BYTES_PER_CHAR

DB_MAX_SQL_STRING_SIZE

public static final int DB_MAX_SQL_STRING_SIZE

NAVIGATE_RESULT_ROLE_INDEX

public static final int NAVIGATE_RESULT_ROLE_INDEX
See Also:
Constant Field Values

NAVIGATE_RESULT_LINK_INDEX

public static final int NAVIGATE_RESULT_LINK_INDEX
See Also:
Constant Field Values
Constructor Detail

PersistenceHelper

public PersistenceHelper()
Method Detail

getCreateStamp

public static Timestamp getCreateStamp(Persistable obj)
Retrives the create timestamp for the given Persistable object.

Supported API: true

Parameters:
obj -
Returns:
Timestamp

getModifyStamp

public static Timestamp getModifyStamp(Persistable obj)
Retrives the modify timestamp for the given Persistable object.

Supported API: true

Parameters:
obj -
Returns:
Timestamp

getObjectIdentifier

public static ObjectIdentifier getObjectIdentifier(Persistable obj)
Retrives the object identifier for the given Persistable object.

Supported API: true

Parameters:
obj -
Returns:
ObjectIdentifier

isDeleted

public static boolean isDeleted(Persistable obj)
Returns true if the specified persistable object is marked as deleted.

Supported API: true

Parameters:
obj -
Returns:
boolean

isEquivalent

public static boolean isEquivalent(Persistable obj1,
                                   Persistable obj2)
Returns true if the two given objects are equivalent persistable object. Two objects are equivalent if they are Persistable and their ObjectIdentifiers are equal.

Supported API: true

Parameters:
obj1 -
obj2 -
Returns:
boolean

isPersistent

public static boolean isPersistent(Persistable obj)
Returns true if the given Persistable object is saved in the datastore.

Supported API: true

Parameters:
obj -
Returns:
boolean

isPersistent

public static boolean isPersistent(Object obj)
Returns true if the given object is Peristable and has already been saved in the database.

Supported API: true

Parameters:
obj -
Returns:
boolean

makeNonPersistent

public static void makeNonPersistent(Persistable obj)
Indicate that the given object is no longer concidered to be persistent.

Supported API: false

Parameters:
obj -

getUnassignedOidSearchCondition

public static SearchCondition getUnassignedOidSearchCondition(Class a_class)
                                                       throws QueryException
Creates a SearchCondition that will find all objects of a given class that don't have an ObjectIdentifier with an assigned id value.

Supported API: false

Parameters:
a_class -
Returns:
SearchCondition
Throws:
QueryException

getUnassignedObjects

public static QueryResult getUnassignedObjects()
                                        throws QueryException,
                                               WTException
Finds all Persistable objects that don't have an ObjectIdentifier with an assigned id value.

Supported API: false

Returns:
QueryResult
Throws:
QueryException
WTException

buildNavigateSpec

public static NavigateSpec buildNavigateSpec(Object source,
                                             String role,
                                             Class linkClass,
                                             boolean onlyOtherSide)
                                      throws WTException
This method builds a query specification for navigating an association.

Supported API: true

Parameters:
source - The source of the navigate operation. This argument can be a single Persistable object or a WTCollection of Persistable objects.
role - The role to navigate to.
linkClass - The association link class to navigate.
onlyOtherSide - Indicates that only the other side objects of the association should be returned. If false, then the link objects are returned (the other side object can be obtained via the link object's getter method).
Returns:
NavigateSpec
Throws:
WTException

navigate

public static QueryResult navigate(Object source,
                                   String role,
                                   Class linkClass,
                                   boolean onlyOtherSide)
                            throws WTException
Retrieves objects related to the specfied source object(s) role and link class.

Supported API: true

Parameters:
source - The source of the navigate operation. This argument can be a single Persistable object or a WTCollection of Persistable objects.
role - The role to navigate to.
linkClass - The association link class to navigate.
onlyOtherSide - Indicates that only the other side objects of the association should be returned. If false, then the link objects are returned (the other side object can be obtained via the link object's getter method).
Returns:
QueryResult
Throws:
WTException

navigateToOtherSideObjectList

public static WTList navigateToOtherSideObjectList(Object a_source,
                                                   String a_role,
                                                   Class a_linkClass)
                                            throws WTException
Retrieves objects related to the specified source object(s), role, and link class. The other side objects are returned directly in a WTList.

Supported API: false

Returns:
WTList of other side objects
Throws:
WTException

checkStoredLength

public static boolean checkStoredLength(String str,
                                        int max_length)
Check the length of a string against a maximum length. This check takes into account the storage characteristics of persistent strings.

Parameters:
str - string to check (may be null)
max_length - declared maximum length
Returns:
true if stored length is less than or equal to the storage limit

checkStoredLength

public static boolean checkStoredLength(String str,
                                        int max_length,
                                        boolean enforce_varchar_limit)
Check the length of a string against a maximum length. This check takes into account the storage characteristics of persistent strings.

Parameters:
str - string to check (may be null)
max_length - declared maximum length
enforce_varchar_limit - require stored string length to be <= DB_MAX_SQL_STRING_SIZE.
Returns:
true if stored length is less than or equal to the storage limit

truncateStoredLength

public static String truncateStoredLength(String str,
                                          int max_length)
Return truncation of given string. This truncation takes into account the storage characteristics of persistent strings.

Parameters:
str - string to truncate
max_length - declared maximum length
Returns:
the truncated string

getStoredLength

public static int getStoredLength(Object obj,
                                  String str)
Deprecated. Replaced by checkStoredLength(String, int)

Get the stored length of a string if it were to be persisted with the given object. This is useful for validating an attribute value against a storage size constraint that may be enforced in bytes rather than characters. If the given object is a ObjectMappable then database storage encoding is taken into consideration. If the given object is null or not a ObjectMappable, then the string length in characters is returned.

Parameters:
obj - object determining storage encoding (may be null)
str - string to measure (may be null)
Returns:
the length

truncateStoredLength

public static String truncateStoredLength(Object obj,
                                          String str,
                                          int len)
Deprecated. Replaced by truncateStoredLength(String, int)

Return truncation of given string with length specified in stored character length instead of actual character length. This is useful for truncating an attribute value against a storage size constraint that may be enforced in bytes rather than characters. If the given object is a ObjectMappable then database storage encoding is taken into consideration. If the given object is null or not a ObjectMappable, then the string is truncated normally. When truncating multi-byte character encodings, only whole characters are returned.

Parameters:
obj - object determining storage encoding (may be null)
str - string to truncate
len - stored length
Returns:
the truncated string

equals

public static boolean equals(Persistable p,
                             Object o)
Determines if two objects are equal from a persistence perspective by comparing their ObjectIdentifiers. If the objects do not have oids, or have unassigned oids, then they are considered equal if they refer to the same in-memory object.

Delegated to by the equals method of Persistables.

Parameters:
p -
o -
Returns:
True if the objects have the same oid

hashCode

public static int hashCode(Persistable p)
Returns a hash code based on the object's ObjectIdentifier If the object does not have an oid, then returns a hash code based on the object's memory location.

Delegated to by the hashCode method of Persistables.

Parameters:
p -
Returns:
The object's hash code.