org.apache.jdo.model.java
Interface JavaType

All Known Implementing Classes:
AbstractJavaType, BaseReflectionJavaType, EnhancerJavaType, ErrorType, FloatingPointType, IntegralType, JDOSupportedCollectionType, JDOSupportedMapType, MutableValueClassType, NullType, PredefinedType, PrimitiveType, ReflectionJavaType, RuntimeJavaType, ValueClassType, WrapperClassType

public interface JavaType

A JavaType instance represents a type as defined in the Java language. The interface defines interrogative methods to check whether a type is primitive, an interface or array, is a JDO supported collection or map, is a value or trackable class, is a persistence capable class, etc. Furthermore it defines methods to get detailed information about the type such as name, modifiers, superclass and the JDO meta data if this type represent a persistence capable class.

Different environments (runtime, enhancer, development) will have different JavaType implementations to provide answers to the various methods.

Since:
JDO 1.0.1
Author:
Michael Bouschen

Method Summary
 JavaType getArrayComponentType()
          Returns the JavaType representing the component type of an array.
 JavaField getJavaField(java.lang.String name)
          Returns a JavaField instance that reflects the field with the specified name of the class or interface represented by this JavaType instance.
 JDOClass getJDOClass()
          Returns the JDOClass instance if this JavaType represents a persistence capable class.
 int getModifiers()
          Returns the Java language modifiers for the field represented by this JavaType, as an integer.
 java.lang.String getName()
          Returns the name of the type.
 JavaType getSuperclass()
          Returns the JavaType representing the superclass of the entity represented by this JavaType.
 boolean isArray()
          Determines if this JavaType object represents an array type.
 boolean isCompatibleWith(JavaType javaType)
          Returns true if this JavaType is compatible with the specified JavaType.
 boolean isFloatingPoint()
          Returns true if this JavaType represents a floating point type.
 boolean isIntegral()
          Returns true if this JavaType represents an integral type.
 boolean isInterface()
          Determines if this JavaType object represents an interface type.
 boolean isJDOSupportedCollection()
          Returns true if this JavaType represents a JDO supported collection type.
 boolean isJDOSupportedMap()
          Returns true if this JavaType represents a JDO supported map type.
 boolean isOrderable()
          Returns true if this JavaType represents an orderable type as specified in JDO.
 boolean isPersistenceCapable()
          Returns true if this JavaType represents a persistence capable class.
 boolean isPrimitive()
          Returns true if this JavaType represents a primitive type.
 boolean isTrackable()
          Returns true if this JavaType represents a trackable Java class.
 boolean isValue()
          Returns true if this JavaType represents a type whose values may be treated as values rather than references during storing.
 boolean isWrapperClass()
          Returns true if this JavaType represents a Java wrapper class type.
 

Method Detail

isPrimitive

boolean isPrimitive()
Returns true if this JavaType represents a primitive type.

There are eight primitive types: boolean, byte, short, int, long, char, float, double.

Returns:
true if this JavaType represents a primitive type; false otherwise.

isIntegral

boolean isIntegral()
Returns true if this JavaType represents an integral type.

There are five are integral types: byte, short, int, long, and char.

Returns:
true if this JavaType represents an integral type; false otherwise.

isFloatingPoint

boolean isFloatingPoint()
Returns true if this JavaType represents a floating point type.

There are two are floating point types: float and double.

Returns:
true if this JavaType represents a floating point type; false otherwise.

isInterface

boolean isInterface()
Determines if this JavaType object represents an interface type.

Returns:
true if this object represents an interface type; false otherwise.

isArray

boolean isArray()
Determines if this JavaType object represents an array type.

Returns:
true if this object represents an array type; false otherwise.

isWrapperClass

boolean isWrapperClass()
Returns true if this JavaType represents a Java wrapper class type.

There are eight Java wrapper class types: java.lang.Boolean, java.lang.Byte, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Character, java.lang.Float, java.lang.Double.

Returns:
true if this JavaType represents a Java wrapper class type; false otherwise.

isJDOSupportedCollection

boolean isJDOSupportedCollection()
Returns true if this JavaType represents a JDO supported collection type. The JDO specification allows the following collection interfaces and classes as types of persistent fields (see section 6.4.3 Persistent fields):

Returns:
true if this JavaType represents a JDO supported collection; false otherwise.

isJDOSupportedMap

boolean isJDOSupportedMap()
Returns true if this JavaType represents a JDO supported map type. The JDO specification allows the following map interfaces and classes as types of persistent fields (see section 6.4.3 Persistent fields):

Returns:
true if this JavaType represents a JDO supported map; false otherwise.

isTrackable

boolean isTrackable()
Returns true if this JavaType represents a trackable Java class. A JDO implementation may replace a persistent field of a trackable type with an assignment compatible instance of its own implementation of this type which notifies the owning FCO of any change of this field.

The following types are trackable types:

Returns:
true if this JavaType represents a trackable Java class, false otherwise.

isValue

boolean isValue()
Returns true if this JavaType represents a type whose values may be treated as values rather than references during storing. A value type is either a primitive type or a type a JDO implementation may treat as SCO and the type is not one the following types: array, JDO supported collection and JDO supported map.

The following classes are value types:

Returns:
true if this JavaType represents a value type; false otherwise.

isOrderable

boolean isOrderable()
Returns true if this JavaType represents an orderable type as specified in JDO.

The following types are orderable:

Note, this method does not check whether this JavaType implements the Comparable interface.

Returns:
true if this JavaType represents an orderable type; false otherwise.

isPersistenceCapable

boolean isPersistenceCapable()
                             throws ModelFatalException
Returns true if this JavaType represents a persistence capable class.

A ModelFatalException indicates a problem accessing the JDO meta data for this JavaType.

Returns:
true if this JavaType represents a persistence capable class; false otherwise.
Throws:
ModelFatalException - if there is a problem accessing the JDO metadata

isCompatibleWith

boolean isCompatibleWith(JavaType javaType)
Returns true if this JavaType is compatible with the specified JavaType.

Parameters:
javaType - the type this JavaType is checked with.
Returns:
true if this is compatible with the specified type; false otherwise.

getName

java.lang.String getName()
Returns the name of the type. If this type represents a class or interface, the name is fully qualified.

Returns:
type name

getModifiers

int getModifiers()
Returns the Java language modifiers for the field represented by this JavaType, as an integer. The java.lang.reflect.Modifier class should be used to decode the modifiers.

Returns:
the Java language modifiers for this JavaType

getSuperclass

JavaType getSuperclass()
Returns the JavaType representing the superclass of the entity represented by this JavaType. If this JavaType represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the JavaType instance representing the Object class is returned.

Returns:
the superclass of the class represented by this JavaType.

getJDOClass

JDOClass getJDOClass()
                     throws ModelFatalException
Returns the JDOClass instance if this JavaType represents a persistence capable class. The method returns null, if this JavaType does not represent a persistence capable class.

A ModelFatalException indicates a problem accessing the JDO meta data for this JavaType.

Returns:
the JDOClass instance if this JavaType represents a persistence capable class; null otherwise.
Throws:
ModelFatalException - if there is a problem accessing the JDO metadata

getArrayComponentType

JavaType getArrayComponentType()
Returns the JavaType representing the component type of an array. If this JavaType does not represent an array type this method returns null.

Returns:
the JavaType representing the component type of this JavaType if this class is an array; null otherwise.

getJavaField

JavaField getJavaField(java.lang.String name)
Returns a JavaField instance that reflects the field with the specified name of the class or interface represented by this JavaType instance. The method returns null, if the class or interface (or one of its superclasses) does not have a field with that name.

Parameters:
name - the name of the field
Returns:
the JavaField instance for the specified field in this class or null if there is no such field.


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