|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.CreateClass
public class CreateClass
This is a try to allow dynamic creation of classes without methods using a description. This is only a very crude work-around and not really a dynamical class definition. The other way, writing a ClassLoader appears to be too sophisticated for this simple task. Still, remeber that using this interface may not be the fastest choice, since it completely relies on standard java methods, like Hashtable and the Wrapper classes for the prmitive data types.
| Field Summary | |
|---|---|
private static Class |
KEY
|
private static String[] |
NAME
|
private Hashtable<String,Class> |
Names
|
private static Class |
NUMBER
|
private static char[] |
SHORT
|
private static Class[] |
TYPE
|
private Hashtable<String,Object> |
Values
|
| Constructor Summary | |
|---|---|
private |
CreateClass(int size)
|
| Method Summary | |
|---|---|
void |
clearField(String name)
Removes the definition of the field with the given name. |
Object |
clone()
Clone this instance of CreateClass. |
private boolean |
compareHashtable(Hashtable one,
Hashtable two)
Check, if keys/values in the two Hashtables match. |
boolean |
equals(Object that)
Test for equal CreateClass objects. |
boolean |
equalType(Object that)
Test for equal type of CreateClass objects. |
Enumeration |
getAllNames()
Returns an Enumeration of all fields found in this CreateClass. |
Object |
getField(String name)
This method retrieves values by field names. |
static CreateClass |
getInstance(String[] name,
char[] type)
This method retrives a new Instance of createClass. |
static CreateClass |
getInstance(String[] name,
Class[] type)
This method retrives a new Instance of createClass. |
static CreateClass |
getInstance(String[] name,
String[] type)
This method retrives a new Instance of createClass. |
Enumeration |
getNames()
Returns an Enumeration of all fields assigned a value. |
Class |
getType(String name)
This method retrieves the prototype class of the field with the given name. |
void |
loadField(String name,
String value)
This method assigns a value to a named field. |
String |
toString()
Returns a String representation of this CreateClass. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static Class KEY
private static Class NUMBER
private static final char[] SHORT
private static final String[] NAME
private static Class[] TYPE
private Hashtable<String,Class> Names
private Hashtable<String,Object> Values
| Constructor Detail |
|---|
private CreateClass(int size)
| Method Detail |
|---|
public static CreateClass getInstance(String[] name,
char[] type)
loadField(java.lang.String, java.lang.String),
getField(java.lang.String)
public static CreateClass getInstance(String[] name,
String[] type)
public static CreateClass getInstance(String[] name,
Class[] type)
loadField(java.lang.String, java.lang.String),
getField(java.lang.String)public Object clone()
clone in class ObjectHashtable.clone()public void clearField(String name)
name - The field to unset.Hashtable.remove(java.lang.Object)
public void loadField(String name,
String value)
name - The field namevalue - The value that should be assigned to the fieldpublic Object getField(String name)
name - The name of the field to retrieve.getType(java.lang.String)public Class getType(String name)
name - The name of the field to retrieve.getField(java.lang.String)public Enumeration getNames()
public Enumeration getAllNames()
private boolean compareHashtable(Hashtable one,
Hashtable two)
public boolean equalType(Object that)
that - The CreateClass instance to be compared to.public boolean equals(Object that)
equals in class Objectthat - The CreateClass instance to be compared to.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||