|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjestr.generic.type.TypeName
Used for printing type names a bit more descriptively than
"Class.toString()
". Supports both a Long form and
a Short form; the former prints full class names, while the latter
prints only the class name itself without the package. Short form is
the default.
Also prints arrays in a more user friendly format than Java does, complete with component type, and includes the length of the array if available.
To use this class, call "new TypeName(X).toString()
".
"X" can be either a class or an
instance. If you have the instance, it is better to pass that because arrays
can print a bit more descriptively (with the array's length); otherwise just
pass the java.lang.Class
.
Constructor Summary | |
TypeName()
|
|
TypeName(java.lang.Class c)
Constructs a TypeName for printing the given class in
Short form. |
|
TypeName(java.lang.Class c,
boolean longForm)
Constructs a TypeName for printing the given type
using the specified form. |
|
TypeName(java.lang.Object o)
Constructs a TypeName for printing the type of the given object in
Short form. |
|
TypeName(java.lang.Object o,
boolean longForm)
Constructs a TypeName for printing the type of the given object
using the specified form. |
Method Summary | |
protected java.lang.String |
classBaseName(java.lang.String name)
|
protected java.lang.String |
className(java.lang.Class c)
|
protected java.lang.String |
formatTypeName(java.lang.Class theClass)
|
protected java.lang.String |
formatTypeName(java.lang.Object obj)
|
java.lang.Class |
getClazz()
Returns the class we are printing. |
boolean |
getLongForm()
Returns whether Long form is being used. |
java.lang.Object |
getObject()
Returns the object we are printing. |
void |
setLongForm(boolean longForm)
Sets whether Long form is to be used the next time toString() is
invoked. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TypeName()
public TypeName(java.lang.Object o)
TypeName
for printing the type of the given object in
Short form.
public TypeName(java.lang.Class c)
TypeName
for printing the given class in
Short form.
public TypeName(java.lang.Object o, boolean longForm)
TypeName
for printing the type of the given object
using the specified form. If longForm
is true, Long form will be
used; else Short form will be used.
o
- - The object whose class should be printed. Can be null
in which case toString
will return the string "null
".public TypeName(java.lang.Class c, boolean longForm)
TypeName
for printing the given type
using the specified form. If longForm
is true, Long form will be
used; else Short form will be used.
c
- - The class to print. Can be null
in which case
toString
will return the string "null
".Method Detail |
public boolean getLongForm()
public void setLongForm(boolean longForm)
toString()
is
invoked. Long or Short form can be specified in the constructor, or it can
changed at any time by calling this method.
public java.lang.Class getClazz()
public java.lang.Object getObject()
Class
constructor was used
there will be no object and this method will return null
.
protected java.lang.String classBaseName(java.lang.String name)
protected java.lang.String className(java.lang.Class c)
public java.lang.String toString()
protected java.lang.String formatTypeName(java.lang.Class theClass)
protected java.lang.String formatTypeName(java.lang.Object obj)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |