org.apache.jdo.impl.sco
Class SCOHelper

java.lang.Object
  extended byorg.apache.jdo.impl.sco.SCOHelper

class SCOHelper
extends java.lang.Object

Helper class used by Tracked SCO implementations. Contains static methods to allow to simplify implementations of SCO classes in the same package without extending the same base class, which is impossible as each Tracked SCO class extends corresponding "regular" SCO.

Author:
Marina Vatkina

Field Summary
private static java.lang.String EXC_ElementClassCastException
           
private static java.lang.String EXC_ElementNullsNotAllowed
          Message keys for assertions performed.
private static java.lang.String EXC_KeyClassCastException
           
private static java.lang.String EXC_KeyNullsNotAllowed
           
private static java.lang.String EXC_ValueClassCastException
           
private static java.lang.String EXC_ValueNullsNotAllowed
           
private static org.apache.commons.logging.Log logger
          Logger for SCO classes.
private static I18NHelper msg
          I18N message handler
 
Constructor Summary
(package private) SCOHelper()
           
 
Method Summary
protected static void assertElementType(java.lang.Object o, java.lang.Class elementType)
          Verifies that the component to insert is of correct type
protected static void assertKeyType(java.lang.Object o, java.lang.Class keyType)
          Verifies that the key to insert is of correct type.
protected static void assertNullKeysAllowed(java.lang.Object o, boolean allowNulls)
          Verifies if null values are allowed for keys of an SCOMap.
protected static void assertNulls(java.lang.Object o, boolean allowNulls, java.lang.String exc)
          Verifies if nulls are allowed as instances of this SCO.
protected static void assertNullsAllowed(java.lang.Object o, boolean allowNulls)
          Verifies if null values are allowed for elements of an SCOCollection.
protected static void assertNullValuesAllowed(java.lang.Object o, boolean allowNulls)
          Verifies if null values are allowed for values of an SCOMap.
private static void assertType(java.lang.Object o, java.lang.Class type, java.lang.String exc)
          Verifies that the value to insert is of correct type.
protected static void assertValueType(java.lang.Object o, java.lang.Class valueType)
          Verifies that the value to insert is of correct type.
protected static void debug(java.lang.String name, java.lang.String msg)
          Tracing method for other SCO implementations.
protected static java.lang.String getFieldName(StateManagerInternal owner, int fieldNumber)
          Returns the field name
protected static java.lang.Object getOwner(StateManagerInternal owner)
          Returns the owner object of the SCO instance
protected static void validateResult(int l, java.lang.Throwable[] err)
          Helper method to validate errors on processing arrays of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXC_ElementNullsNotAllowed

private static final java.lang.String EXC_ElementNullsNotAllowed
Message keys for assertions performed.

See Also:
Constant Field Values

EXC_KeyNullsNotAllowed

private static final java.lang.String EXC_KeyNullsNotAllowed
See Also:
Constant Field Values

EXC_ValueNullsNotAllowed

private static final java.lang.String EXC_ValueNullsNotAllowed
See Also:
Constant Field Values

EXC_ElementClassCastException

private static final java.lang.String EXC_ElementClassCastException
See Also:
Constant Field Values

EXC_KeyClassCastException

private static final java.lang.String EXC_KeyClassCastException
See Also:
Constant Field Values

EXC_ValueClassCastException

private static final java.lang.String EXC_ValueClassCastException
See Also:
Constant Field Values

msg

private static final I18NHelper msg
I18N message handler


logger

private static final org.apache.commons.logging.Log logger
Logger for SCO classes.

Constructor Detail

SCOHelper

SCOHelper()
Method Detail

assertNullsAllowed

protected static void assertNullsAllowed(java.lang.Object o,
                                         boolean allowNulls)
Verifies if null values are allowed for elements of an SCOCollection.

Parameters:
o - the object to validate
allowNulls - true if nulls are allowed
Throws:
javax.jdo.JDOUserException - if null values are not allowed and the component to insert is null.

assertNullKeysAllowed

protected static void assertNullKeysAllowed(java.lang.Object o,
                                            boolean allowNulls)
Verifies if null values are allowed for keys of an SCOMap.

Parameters:
o - the key to validate
allowNulls - true if nulls are allowed
Throws:
javax.jdo.JDOUserException - if null values are not allowed and the key to set is null.

assertNullValuesAllowed

protected static void assertNullValuesAllowed(java.lang.Object o,
                                              boolean allowNulls)
Verifies if null values are allowed for values of an SCOMap.

Parameters:
o - the value to validate.
allowNulls - true if nulls are allowed.
Throws:
javax.jdo.JDOUserException - if null values are not allowed and the value to insert is null.

assertElementType

protected static void assertElementType(java.lang.Object o,
                                        java.lang.Class elementType)
Verifies that the component to insert is of correct type

Parameters:
o - the object to validate.
elementType - the element types allowed.
Throws:
javax.jdo.JDOUserException - if validation fails.

assertKeyType

protected static void assertKeyType(java.lang.Object o,
                                    java.lang.Class keyType)
Verifies that the key to insert is of correct type.

Parameters:
o - the key to validate.
keyType - the key types allowed.
Throws:
javax.jdo.JDOUserException - if validation fails.

assertValueType

protected static void assertValueType(java.lang.Object o,
                                      java.lang.Class valueType)
Verifies that the value to insert is of correct type.

Parameters:
o - the value to validate.
valueType - the value types allowed.
Throws:
javax.jdo.JDOUserException - if validation fails.

validateResult

protected static void validateResult(int l,
                                     java.lang.Throwable[] err)
Helper method to validate errors on processing arrays of objects.

Parameters:
l - actual size of the array
err - array of Throwable to validate
Throws:
javax.jdo.JDOUserException - if l is greater than 0.

assertNulls

protected static void assertNulls(java.lang.Object o,
                                  boolean allowNulls,
                                  java.lang.String exc)
Verifies if nulls are allowed as instances of this SCO.

Parameters:
o - the instance to validate.
allowNulls - true if nulls are allowed.
exc - message key for the exception to be thrown.
Throws:
javax.jdo.JDOUserException - if validation fails.

assertType

private static void assertType(java.lang.Object o,
                               java.lang.Class type,
                               java.lang.String exc)
Verifies that the value to insert is of correct type.

Parameters:
o - the value to validate.
type - the Class of types allowed.
exc - message key for the exception to be thrown.
Throws:
javax.jdo.JDOUserException - if validation fails.

getOwner

protected static java.lang.Object getOwner(StateManagerInternal owner)
Returns the owner object of the SCO instance

Returns:
owner object

getFieldName

protected static java.lang.String getFieldName(StateManagerInternal owner,
                                               int fieldNumber)
Returns the field name

Returns:
field name as java.lang.String

debug

protected static void debug(java.lang.String name,
                            java.lang.String msg)
Tracing method for other SCO implementations.

Parameters:
name - Class name of an instance calling the method.
msg - String to display.