org.apache.jdo.impl.jdoql.jdoqlc
Class TypeSupport

java.lang.Object
  extended by org.apache.jdo.impl.jdoql.jdoqlc.TypeSupport

public class TypeSupport
extends java.lang.Object

Provides query convenience methods to deal with Java/JDO metadata.

Since:
JDO 1.0.1
Author:
Michael Bouschen

Field Summary
protected  org.apache.jdo.model.java.JavaModel applicationJavaModel
          The JavaModel for the class loader of the candidate class.
 
Constructor Summary
TypeSupport()
           
 
Method Summary
static org.apache.jdo.model.java.JavaType binaryNumericPromotion(org.apache.jdo.model.java.JavaType left, org.apache.jdo.model.java.JavaType right)
          Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2
 org.apache.jdo.model.java.JavaType checkType(java.lang.Class clazz)
          Checks for the Java Type with the specified class object.
 org.apache.jdo.model.java.JavaType checkType(java.lang.String name)
          Returns the JavaType representation for the type with the specified name.
static java.lang.reflect.Field getAccessibleField(org.apache.jdo.model.java.JavaField javaField)
          Returns a accessible java.lang.reflect.Field instance for the specified JavaField.
static org.apache.jdo.model.java.JavaType getElementType(org.apache.jdo.model.java.JavaField field)
           
static int getFieldNumber(org.apache.jdo.model.java.JavaField javaField, javax.jdo.PersistenceManager pm, java.lang.Object object)
          Returns the fieldNumber of the specified field.
static java.lang.Object getFieldValue(java.lang.reflect.Field field, java.lang.Object object)
          Get field value via reflection
static java.lang.Object getFieldValue(int fieldNumber, org.apache.jdo.pm.PersistenceManagerInternal pm, java.lang.Object object)
          field value of a managed field.
static java.lang.Class getJavaClass(org.apache.jdo.model.java.JavaType type)
          Returns the java.lang.Class instance for the specified type.
static org.apache.jdo.model.jdo.JDOField getJDOField(org.apache.jdo.model.java.JavaField javaField)
           
 void initApplicationJavaModel(java.lang.ClassLoader classLoader)
          This methods sets the application JavaModel to the JavaModel instance for the specified ClassLoader.
static boolean isBooleanType(org.apache.jdo.model.java.JavaType type)
          Returns true if the specified type is boolean or java.lang.Boolean.
static boolean isCharType(org.apache.jdo.model.java.JavaType type)
          Returns true if the specified type is char or java.lang.Character
static boolean isIntegralType(org.apache.jdo.model.java.JavaType type)
          Returns true if the specified type is an interal type or a Java wrapper class for an interal type.
static boolean isMathType(org.apache.jdo.model.java.JavaType type)
          Returns true if the specified type is either java.math.BigDecimal or java.math.BigInteger.
static boolean isNumberType(org.apache.jdo.model.java.JavaType type)
          Returns true if specified type is a number type:
a numeric primitive
a numeric wrapper class
java.math.BigDecimal, java.math.BigInteger.
static boolean isNumericType(org.apache.jdo.model.java.JavaType type)
          Returns true if the specified type is a either a integral or a floating point type.
static boolean isNumericWrapperClassType(org.apache.jdo.model.java.JavaType type)
          Returns true if the specified type is a Java wrapper class type for a numeric primitive type.
static boolean isStaticField(org.apache.jdo.model.java.JavaField field)
           
static org.apache.jdo.model.java.JavaType unaryNumericPromotion(org.apache.jdo.model.java.JavaType type)
          Implements unray numeric promotion as defined in the Java Language Specification section 5.6.1
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applicationJavaModel

protected org.apache.jdo.model.java.JavaModel applicationJavaModel
The JavaModel for the class loader of the candidate class.

Constructor Detail

TypeSupport

public TypeSupport()
Method Detail

initApplicationJavaModel

public void initApplicationJavaModel(java.lang.ClassLoader classLoader)
This methods sets the application JavaModel to the JavaModel instance for the specified ClassLoader.

Parameters:
classLoader - the class loader of the candidate class.

checkType

public org.apache.jdo.model.java.JavaType checkType(java.lang.String name)
Returns the JavaType representation for the type with the specified name. This method uses the application JavaModel for the type lookup. This means any type is checked in the context of the JavaModel for the class loader of the candidate class.

Parameters:
name - the name of the type to be checked.
Returns:
the JavaType object representing the type with the specified name or null when the type was not found.

checkType

public org.apache.jdo.model.java.JavaType checkType(java.lang.Class clazz)
Checks for the Java Type with the specified class object.

Parameters:
clazz - the clazz object of the type to be checked.
Returns:
the TypeDescriptor object representing the type

binaryNumericPromotion

public static org.apache.jdo.model.java.JavaType binaryNumericPromotion(org.apache.jdo.model.java.JavaType left,
                                                                        org.apache.jdo.model.java.JavaType right)
Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2


unaryNumericPromotion

public static org.apache.jdo.model.java.JavaType unaryNumericPromotion(org.apache.jdo.model.java.JavaType type)
Implements unray numeric promotion as defined in the Java Language Specification section 5.6.1


getJavaClass

public static java.lang.Class getJavaClass(org.apache.jdo.model.java.JavaType type)
Returns the java.lang.Class instance for the specified type.

Parameters:
type - the type to be checked
Returns:
the corresponding class instance.

isBooleanType

public static boolean isBooleanType(org.apache.jdo.model.java.JavaType type)
Returns true if the specified type is boolean or java.lang.Boolean.

Parameters:
type - the type to be checked
Returns:
true if type is boolean or java.lang.Boolean; false otherwise.

isCharType

public static boolean isCharType(org.apache.jdo.model.java.JavaType type)
Returns true if the specified type is char or java.lang.Character

Parameters:
type - the type to be checked
Returns:
true if type is char or java.lang.Character false otherwise.

isIntegralType

public static boolean isIntegralType(org.apache.jdo.model.java.JavaType type)
Returns true if the specified type is an interal type or a Java wrapper class for an interal type.

Parameters:
type - the type to be checked
Returns:
true if type is an integral type or a Java wrapper for an integral type; false otherwise.

isNumberType

public static boolean isNumberType(org.apache.jdo.model.java.JavaType type)
Returns true if specified type is a number type:
a numeric primitive
a numeric wrapper class
java.math.BigDecimal, java.math.BigInteger.

Parameters:
type - the type to be checked
Returns:
true if type is a number type; false otherwise.

isNumericWrapperClassType

public static boolean isNumericWrapperClassType(org.apache.jdo.model.java.JavaType type)
Returns true if the specified type is a Java wrapper class type for a numeric primitive type.

Parameters:
type - the type to be checked
Returns:
true if type is a numeric wrapper class type; false otherwise.

isNumericType

public static boolean isNumericType(org.apache.jdo.model.java.JavaType type)
Returns true if the specified type is a either a integral or a floating point type.

Parameters:
type - the type to be checked
Returns:
true if type is a numeric type; false otherwise.

isMathType

public static boolean isMathType(org.apache.jdo.model.java.JavaType type)
Returns true if the specified type is either java.math.BigDecimal or java.math.BigInteger.

Parameters:
type - the type to be checked
Returns:
true if type is BigDecimal or BigInteger; false otherwise.

isStaticField

public static boolean isStaticField(org.apache.jdo.model.java.JavaField field)

getJDOField

public static org.apache.jdo.model.jdo.JDOField getJDOField(org.apache.jdo.model.java.JavaField javaField)

getElementType

public static org.apache.jdo.model.java.JavaType getElementType(org.apache.jdo.model.java.JavaField field)

getFieldValue

public static java.lang.Object getFieldValue(int fieldNumber,
                                             org.apache.jdo.pm.PersistenceManagerInternal pm,
                                             java.lang.Object object)
field value of a managed field. Not using reflection.


getFieldValue

public static java.lang.Object getFieldValue(java.lang.reflect.Field field,
                                             java.lang.Object object)
Get field value via reflection


getFieldNumber

public static int getFieldNumber(org.apache.jdo.model.java.JavaField javaField,
                                 javax.jdo.PersistenceManager pm,
                                 java.lang.Object object)
Returns the fieldNumber of the specified field.

Returns:
field number

getAccessibleField

public static java.lang.reflect.Field getAccessibleField(org.apache.jdo.model.java.JavaField javaField)
Returns a accessible java.lang.reflect.Field instance for the specified JavaField. Note, this method gets a new Field instance from reflection and sets the accessibility. The method requires the caller to have the permission ReflectPermission("suppressAccessChecks").

Parameters:
javaField - the JavaField
Returns:
accessible Field instance


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.