|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.MetaClass
public class MetaClass
A meta class using Java's reflection library. Can be used to create a single instance, or a factory, where each Class from the factory share their constructor parameters.
Nested Class Summary | |
---|---|
static class |
MetaClass.ClassCreationException
|
static class |
MetaClass.ClassFactory<T>
|
static class |
MetaClass.ConstructorNotFoundException
|
Constructor Summary | |
---|---|
MetaClass(Class<?> classname)
Creates a new MetaClass producing objects of the given type |
|
MetaClass(String classname)
Creates a new MetaClass producing objects of the given type |
Method Summary | ||
---|---|---|
static
|
cast(String value,
Type type)
Cast a String representation of an object into that object. |
|
boolean |
checkConstructor(Object... params)
|
|
static MetaClass |
create(Class<?> clazz)
Creates a new MetaClass (helper method) |
|
static MetaClass |
create(String classname)
Creates a new MetaClass (helper method) |
|
|
createFactory(Class<?>... classes)
Creates a factory for producing instances of this class from a constructor taking the given types as arguments |
|
|
createFactory(Object... objects)
Creates a factory for producing instances of this class from a constructor taking objects of the types given |
|
|
createFactory(String... classes)
Creates a factory for producing instances of this class from a constructor taking the given types as arguments |
|
|
createInstance(Class<E> type,
Object... params)
Creates an instance of the class, forcing a cast to a certain type and given an array of objects as constructor parameters NOTE: the resulting instance will [unlike java] invoke the most narrow constructor rather than the one which matches the signature passed to this function |
|
|
createInstance(Object... objects)
Create an instance of the class, inferring the type automatically, and given an array of objects as constructor parameters NOTE: the resulting instance will [unlike java] invoke the most narrow constructor rather than the one which matches the signature passed to this function |
|
boolean |
equals(Object o)
|
|
int |
hashCode()
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MetaClass(String classname)
classname
- The full classname of the objects to createpublic MetaClass(Class<?> classname)
classname
- The class to createMethod Detail |
---|
public <E> MetaClass.ClassFactory<E> createFactory(Class<?>... classes)
E
- The type of the objects to be producedclasses
- The types used in the constructor
public <E> MetaClass.ClassFactory<E> createFactory(String... classes)
E
- The type of the objects to be producedclasses
- The types used in the constructor
public <E> MetaClass.ClassFactory<E> createFactory(Object... objects)
E
- The type of the objects to be producedobjects
- Instances of the types used in the constructor
public <E> E createInstance(Object... objects)
E
- The type of the object returnedobjects
- The arguments to the constructor of the class
public <E,F extends E> F createInstance(Class<E> type, Object... params)
E
- The type of the object returnedtype
- The class of the object returnedparams
- The arguments to the constructor of the class
public boolean checkConstructor(Object... params)
public String toString()
toString
in class Object
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public static MetaClass create(String classname)
classname
- The name of the class to create
public static MetaClass create(Class<?> clazz)
clazz
- The class to create
public static final <E> E cast(String value, Type type)
E
- The type of the object returned (same as type)value
- The string representation of the objecttype
- The type (usually class) to be returned (same as E)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |