Arch4J 1.1

org.arch4j.generator
Class JavaType

java.lang.Object
  |
  +--org.arch4j.generator.JavaType

public class JavaType
extends Object

This class represents a Java data type. The primitive data types are available as static fields available via this class name. Also, the void return type and the commonly used String data type each have a static representation. Additionally, a static method is available to find the appropriate primitive data type via a keyword string, such as int.

Version:
1.0
Author:
Ross E. Greinke

Field Summary
static JavaType BOOLEAN_TYPE
          The boolean primitive data type.
static JavaType BYTE_TYPE
          The byte primitive data type.
static JavaType CHAR_TYPE
          The char primitive data type.
static JavaType DOUBLE_TYPE
          The double primitive data type.
static JavaType FLOAT_TYPE
          The float primitive data type.
static JavaType INT_TYPE
          The int primitive data type.
static JavaType LONG_TYPE
          The long primitive data type.
static JavaType SHORT_TYPE
          The short primitive data type.
static JavaType STRING_TYPE
          The commonly used String data type.
static JavaType VOID_TYPE
          The commonly used void return type.
 
Constructor Summary
JavaType(String typeName)
          Constructs a JavaType with the specified type name.
JavaType(String packageName, String typeName)
          Constructs a JavaType with the specified package name and type name.
 
Method Summary
 boolean equals(Object obj)
          Returns true if this data type is equal to another object.
 String getPackage()
          Returns the type's package name.
 String getType()
          Returns the type's name.
 int hashCode()
          Returns a hash code value for this JavaType.
 boolean hasPackage()
          Returns whether the type has a package specified or not.
 String toString()
          Returns a String object representing this JavaType.
 String toString(boolean includePackage)
          Returns a String object representing this JavaType.
static JavaType typeFor(String typeName)
          Returns an appropriate JavaType for the given type name string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOLEAN_TYPE

public static final JavaType BOOLEAN_TYPE
The boolean primitive data type.


BYTE_TYPE

public static final JavaType BYTE_TYPE
The byte primitive data type.


CHAR_TYPE

public static final JavaType CHAR_TYPE
The char primitive data type.


DOUBLE_TYPE

public static final JavaType DOUBLE_TYPE
The double primitive data type.


FLOAT_TYPE

public static final JavaType FLOAT_TYPE
The float primitive data type.


INT_TYPE

public static final JavaType INT_TYPE
The int primitive data type.


LONG_TYPE

public static final JavaType LONG_TYPE
The long primitive data type.


SHORT_TYPE

public static final JavaType SHORT_TYPE
The short primitive data type.


STRING_TYPE

public static final JavaType STRING_TYPE
The commonly used String data type.


VOID_TYPE

public static final JavaType VOID_TYPE
The commonly used void return type.

Constructor Detail

JavaType

public JavaType(String typeName)
Constructs a JavaType with the specified type name. If the type name is a class name, it can include the full package name.

Parameters:
typeName - The type's name.

JavaType

public JavaType(String packageName,
                String typeName)
Constructs a JavaType with the specified package name and type name.

Parameters:
packageName - The type's package name.
typeName - The type's name.
Method Detail

typeFor

public static JavaType typeFor(String typeName)
Returns an appropriate JavaType for the given type name string. If a null string is given, the void return type will be returned. If the given type name string is one of the primitive data types or it is the string "String", the appropriate static field will be returned. If the given type name is not a primitive data type and is a class name, it can include the full package name.

Parameters:
typeName - The data type to get.

hasPackage

public boolean hasPackage()
Returns whether the type has a package specified or not.

Returns:
true if the type has a package specified.

getPackage

public String getPackage()
Returns the type's package name. If the type is a primitive data type, null is returned.

Returns:
The type's package name.

getType

public String getType()
Returns the type's name.

Returns:
The type's name.

equals

public boolean equals(Object obj)
Returns true if this data type is equal to another object. A JavaType is deemed equal to another if they both specify the same package and type names.

Overrides:
equals in class Object
Parameters:
obj - The object to compare with.
Returns:
true if this data type is equal to the specified object.

hashCode

public int hashCode()
Returns a hash code value for this JavaType.

Overrides:
hashCode in class Object
Returns:
The hash code value for this JavaType.

toString

public String toString()
Returns a String object representing this JavaType.

Overrides:
toString in class Object
Returns:
A String object representing this JavaType.

toString

public String toString(boolean includePackage)
Returns a String object representing this JavaType. If includePackage is true, include the package name.

Returns:
A String object representing this JavaType.

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.