org.apache.jdo.impl.model.java
Class AbstractJavaType

java.lang.Object
  extended byorg.apache.jdo.impl.model.java.AbstractJavaType
All Implemented Interfaces:
JavaElement, JavaType
Direct Known Subclasses:
BaseReflectionJavaType, ErrorType, NullType

public abstract class AbstractJavaType
extends java.lang.Object
implements JavaType

Abstract super class for JavaType implementations. It provides a default implementation for all methods except getName. The methods return the Java default value of the return type.

A non-abstract subclass must implement method getName() and needs to override any of the other methods where the default implementation is not appropriate.

Note, the class implements methods equals(Object obj), hashCode() and toString()using the name of a JavaType.

Since:
JDO 1.0.1
Version:
JDO 2.0
Author:
Michael Bouschen

Constructor Summary
AbstractJavaType()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 JavaType getArrayComponentType()
          Returns the JavaType representing the component type of an array.
 JavaField[] getDeclaredJavaFields()
          Returns an array of JavaField instances representing the declared fields of the class represented by this JavaType instance.
 JavaProperty[] getDeclaredJavaProperties()
          Returns an array of JavaProperty instances representing the declared properties of the class represented by this JavaType instance.
 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.
 JavaProperty getJavaProperty(java.lang.String name)
          Returns a JavaProperty instance that reflects the property 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.
abstract  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.
 java.lang.Object getUnderlyingObject()
          Returns the environment specific instance wrapped by this JavaModel element.
 int hashCode()
          Returns a hash code value for the object.
 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.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractJavaType

public AbstractJavaType()
Method Detail

getUnderlyingObject

public java.lang.Object getUnderlyingObject()
Description copied from interface: JavaElement
Returns the environment specific instance wrapped by this JavaModel element. E.g. a runtime implementation of JavaField might use a java.lang.reflect.Field instance as the underlying object.

Specified by:
getUnderlyingObject in interface JavaElement
Returns:
the environment specific instance wrapped by this JavaModel element.

isPrimitive

public boolean isPrimitive()
Description copied from interface: JavaType
Returns true if this JavaType represents a primitive type.

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

Specified by:
isPrimitive in interface JavaType
Returns:
true if this JavaType represents a primitive type; false otherwise.

isIntegral

public boolean isIntegral()
Description copied from interface: JavaType
Returns true if this JavaType represents an integral type.

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

Specified by:
isIntegral in interface JavaType
Returns:
true if this JavaType represents an integral type; false otherwise.

isFloatingPoint

public boolean isFloatingPoint()
Description copied from interface: JavaType
Returns true if this JavaType represents a floating point type.

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

Specified by:
isFloatingPoint in interface JavaType
Returns:
true if this JavaType represents a floating point type; false otherwise.

isInterface

public boolean isInterface()
Description copied from interface: JavaType
Determines if this JavaType object represents an interface type.

Specified by:
isInterface in interface JavaType
Returns:
true if this object represents an interface type; false otherwise.

isArray

public boolean isArray()
Description copied from interface: JavaType
Determines if this JavaType object represents an array type.

Specified by:
isArray in interface JavaType
Returns:
true if this object represents an array type; false otherwise.

isWrapperClass

public boolean isWrapperClass()
Description copied from interface: JavaType
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.

Specified by:
isWrapperClass in interface JavaType
Returns:
true if this JavaType represents a Java wrapper class type; false otherwise.

isJDOSupportedCollection

public boolean isJDOSupportedCollection()
Description copied from interface: JavaType
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):

Specified by:
isJDOSupportedCollection in interface JavaType
Returns:
true if this JavaType represents a JDO supported collection; false otherwise.

isJDOSupportedMap

public boolean isJDOSupportedMap()
Description copied from interface: JavaType
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):

Specified by:
isJDOSupportedMap in interface JavaType
Returns:
true if this JavaType represents a JDO supported map; false otherwise.

isTrackable

public boolean isTrackable()
Description copied from interface: JavaType
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:

Specified by:
isTrackable in interface JavaType
Returns:
true if this JavaType represents a trackable Java class, false otherwise.

isValue

public boolean isValue()
Description copied from interface: JavaType
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:

Specified by:
isValue in interface JavaType
Returns:
true if this JavaType represents a value type; false otherwise.

isOrderable

public boolean isOrderable()
Description copied from interface: JavaType
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.

Specified by:
isOrderable in interface JavaType
Returns:
true if this JavaType represents an orderable type; false otherwise.

isPersistenceCapable

public boolean isPersistenceCapable()
Description copied from interface: JavaType
Returns true if this JavaType represents a persistence capable class.

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

Specified by:
isPersistenceCapable in interface JavaType
Returns:
true if this JavaType represents a persistence capable class; false otherwise.

isCompatibleWith

public boolean isCompatibleWith(JavaType javaType)
Description copied from interface: JavaType
Returns true if this JavaType is compatible with the specified JavaType.

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

getName

public abstract java.lang.String getName()
Description copied from interface: JavaType
Returns the name of the type. If this type represents a class or interface, the name is fully qualified.

Specified by:
getName in interface JavaType
Returns:
type name

getModifiers

public int getModifiers()
Description copied from interface: JavaType
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.

Specified by:
getModifiers in interface JavaType
Returns:
the Java language modifiers for this JavaType

getSuperclass

public JavaType getSuperclass()
Description copied from interface: JavaType
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.

Specified by:
getSuperclass in interface JavaType
Returns:
the superclass of the class represented by this JavaType.

getJDOClass

public JDOClass getJDOClass()
Description copied from interface: JavaType
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.

Specified by:
getJDOClass in interface JavaType
Returns:
the JDOClass instance if this JavaType represents a persistence capable class; null otherwise.

getArrayComponentType

public JavaType getArrayComponentType()
Description copied from interface: JavaType
Returns the JavaType representing the component type of an array. If this JavaType does not represent an array type this method returns null.

Specified by:
getArrayComponentType in interface JavaType
Returns:
the JavaType representing the component type of this JavaType if this class is an array; null otherwise.

getJavaField

public JavaField getJavaField(java.lang.String name)
Description copied from interface: JavaType
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.

Specified by:
getJavaField in interface JavaType
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.

getDeclaredJavaFields

public JavaField[] getDeclaredJavaFields()
Description copied from interface: JavaType
Returns an array of JavaField instances representing the declared fields of the class represented by this JavaType instance. Note, this method does not return JavaField instances representing inherited fields.

Specified by:
getDeclaredJavaFields in interface JavaType
Returns:
an array of declared JavaField instances.

getJavaProperty

public JavaProperty getJavaProperty(java.lang.String name)
Description copied from interface: JavaType
Returns a JavaProperty instance that reflects the property 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 property with that name.

Specified by:
getJavaProperty in interface JavaType
Parameters:
name - the name of the property
Returns:
the JavaProperty instance for the specified property in this class or null if there is no such property.

getDeclaredJavaProperties

public JavaProperty[] getDeclaredJavaProperties()
Description copied from interface: JavaType
Returns an array of JavaProperty instances representing the declared properties of the class represented by this JavaType instance. Note, this method does not return JavaProperty instances representing inherited properties.

Specified by:
getDeclaredJavaProperties in interface JavaType
Returns:
an array of declared JavaProperty instances.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Parameters:
obj - the reference object with which to compare.

This implementation compares the name of the specified object to be equal to the name of this JavaType. this

Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

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

This implementation returns the hashCode of the name of this JavaType.

Returns:
a hash code value for this object.

toString

public java.lang.String toString()
Returns a string representation of the object.

Returns:
a string representation of the object.


Copyright © 2005 Apache Software Foundation. All Rights Reserved.