Arch4J 1.1

org.arch4j.generator
Class JavaIdentifier

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

public class JavaIdentifier
extends Object

This class represents a Java identifier. An identifier has a name, a type and, if it is an array, the dimension of the array. An identifier can be used to define a field, the name and return type for a method, and the name and type for a formal parameter in a method definition.

The number of constructors are meant to make it easy to define an identifier with as few statements as possible.

Version:
1.0
Author:
Ross E. Greinke

Constructor Summary
JavaIdentifier(JavaType type, int arrayDimension, String name)
          Constructs a JavaIdentifier with the specified type, name, and array dimension (if any).
JavaIdentifier(JavaType type, String name)
          Constructs a JavaIdentifier with the specified type and name.
JavaIdentifier(String typeName, int arrayDimension, String name)
          Constructs a JavaIdentifier with the specified type name, identifier name, and array dimension (if any).
JavaIdentifier(String typeName, String name)
          Constructs a JavaIdentifier with the specified type name and identifier name.
JavaIdentifier(String packageName, String typeName, int arrayDimension, String name)
          Constructs a JavaIdentifier with the specified package name, type name, identifier name, and array dimension (if any).
JavaIdentifier(String packageName, String typeName, String name)
          Constructs a JavaIdentifier with the specified package name, type name, and identifier name.
 
Method Summary
 int getArrayDimension()
          Returns how many dimensions the array has, assuming the identifier is an array.
 JavaType getJavaType()
          Returns the identifier's underlying type object.
 String getName()
          Returns the identifier's name.
 String getPackageName()
          Returns the identifier's package name.
 String getType()
          Returns a String object representing the identifier's type.
 String getType(boolean includePackage)
          Returns a String object representing the identifier's type.
 String getTypeName()
          Returns the identifier's type name.
 boolean hasPackageName()
          Returns whether the identifier has a package name or not.
 boolean isArray()
          Returns whether the identifier is an array or not.
 String toString()
          Returns a String object representing this JavaIdentifier.
 String toString(boolean includePackage)
          Returns a String object representing this JavaIdentifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaIdentifier

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

Parameters:
typeName - The identifier's type name.
name - The identifier's name.

JavaIdentifier

public JavaIdentifier(JavaType type,
                      String name)
Constructs a JavaIdentifier with the specified type and name.

Parameters:
type - The identifier's type.
name - The identifier's name.

JavaIdentifier

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

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

JavaIdentifier

public JavaIdentifier(String typeName,
                      int arrayDimension,
                      String name)
Constructs a JavaIdentifier with the specified type name, identifier name, and array dimension (if any). If it is an array, the array dimension must be greater than zero. If the type name is a class name, it can include the full package name.

Parameters:
typeName - The identifier's type name.
arrayDimension - The number of dimensions the array has.
name - The identifier's name.

JavaIdentifier

public JavaIdentifier(String packageName,
                      String typeName,
                      int arrayDimension,
                      String name)
Constructs a JavaIdentifier with the specified package name, type name, identifier name, and array dimension (if any). If it is an array, the array dimension must be greater than zero.

Parameters:
packageName - The identifier's package name.
typeName - The identifier's type name.
arrayDimension - The number of dimensions the array has.
name - The identifier's name.

JavaIdentifier

public JavaIdentifier(JavaType type,
                      int arrayDimension,
                      String name)
Constructs a JavaIdentifier with the specified type, name, and array dimension (if any). If it is an array, the array dimension must be greater than zero.

Parameters:
type - The identifier's type.
arrayDimension - The number of dimensions the array has.
name - The identifier's name.
Method Detail

getJavaType

public JavaType getJavaType()
Returns the identifier's underlying type object.

Returns:
The identifier's underlying type object.

getType

public String getType()
Returns a String object representing the identifier's type. If the type is an array, array brackets are included.

Returns:
A String object representing the identifier's type.

getType

public String getType(boolean includePackage)
Returns a String object representing the identifier's type. If includePackage is true, the package name is included. If the type is an array, array brackets are included.

Returns:
A String object representing the identifier's type.

hasPackageName

public boolean hasPackageName()
Returns whether the identifier has a package name or not.

Returns:
true if the identifier has a package name.

getPackageName

public String getPackageName()
Returns the identifier's package name.

Returns:
The identifier's package name.

getTypeName

public String getTypeName()
Returns the identifier's type name.

Returns:
The identifier's type name.

isArray

public boolean isArray()
Returns whether the identifier is an array or not.

Returns:
true if the identifier is an array.
See Also:
getArrayDimension()

getArrayDimension

public int getArrayDimension()
Returns how many dimensions the array has, assuming the identifier is an array.

Returns:
The number of dimensions in the array.
See Also:
isArray()

getName

public String getName()
Returns the identifier's name.

Returns:
The identifier's name.

toString

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

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

toString

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

Returns:
A String object representing this JavaIdentifier.

Arch4J 1.1

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