|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.util.StringableFactory
Class whose instances can construct new instances
of objects
of a given class using reflection.
Use of this type of factory is the preferred technique for
StringableTypedViews and GeneralViews
to create and return data models built
from user input data.
| Field Summary | |
protected SwingPropertyChangeSupport |
changeAdapter
Helper object for property change API. |
static String |
DATA_TYPE
Bound property name for the data type property. |
protected Class |
type
The class of objects to produce with this factory. |
| Constructor Summary | |
StringableFactory(Class dataType)
Constructor for a factory capable of producing objects of the given Stringable class. |
|
| Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this factory. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this factory with the given property name. |
static Stringable |
constructFrom(Class dataType,
String data)
Constructs a new Stringable object
by constructing a default instance of the given type
and setting the state of the object to the state
encapsulated by the given String. |
Stringable |
constructFrom(String data)
Returns a new instance of the stored class created using the zero-parameter constructor for the class, whose state is then set from the given String data. |
static Stringable |
decodeTypeAndData(String data)
Returns a new Stringable object
constructed from the given String
that encapsulates the type and state information
of a previously existing Stringable object. |
static String |
encodeTypeAndData(Stringable obj)
Returns a String encapsulation
of the class and state information
for the given Stringable object. |
Class |
getDataType()
Returns the class of objects produced by this factory. |
Stringable |
getDefaultInstance()
Returns a new instance of the stored class created using the zero-parameter constructor for the class. |
static boolean |
isStringable(Class dataType)
Returns true if the given class
is ,
and false if it is not. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Deregisters the given object from listening for property change events generated by this factory. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Deregisters the given object from listening for property change events generated by this factory with the given property name. |
void |
setDataType(Class dataType)
Sets the class of objects produced by this factory to the given Stringable class. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String DATA_TYPE
protected Class type
protected SwingPropertyChangeSupport changeAdapter
| Constructor Detail |
public StringableFactory(Class dataType)
Constructor for a factory capable of producing
objects of the given Stringable class.
If the class is null, this factory will
produce instances of the XString class.
If the given class is not Stringable,
then an exception of type Error will be
thrown.
dataType - the Stringable class
of objects to be produced| Method Detail |
public Stringable getDefaultInstance()
Returns a new instance of the stored class created using the zero-parameter constructor for the class.
This method will throw an exception of type
Error if a new instance cannot be
created.
constructFrom(String)
public Stringable constructFrom(String data)
throws ParseException
String data.
data - the data String
containing state information
ParseExceptionsetDataType(Class)public void setDataType(Class dataType)
Sets the class of objects produced by this factory
to the given Stringable class.
If the given class is null, this
method will not change the stored class. This behavior
represents a change from earlier versions of the method
in which a null parameter led to a change
of the stored class to XString.class. The
new behavior works better in practical usage.
If the given class is not Stringable,
then an exception of type Error will be
thrown.
dataType - the desired class of objects to producegetDataType()public Class getDataType()
setDataType(Class)public void addPropertyChangeListener(PropertyChangeListener listener)
listener - the listener to be registered
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
propertyName - the name of the desired propertylistener - the listener to be registeredpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener - the listener to be deregistered
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
propertyName - the name of the desired propertylistener - the listener to be deregisteredpublic static boolean isStringable(Class dataType)
true if the given class
is Stringable,
and false if it is not.
dataType - the class in questionpublic static String encodeTypeAndData(Stringable obj)
String encapsulation
of the class and state information
for the given Stringable object.
obj - the object to be encapsulated
public static Stringable decodeTypeAndData(String data)
throws ParseException
Stringable object
constructed from the given String
that encapsulates the type and state information
of a previously existing Stringable object.
Implementation change: As of 2.4.0 decodes the data
parameter using Strings.decode.
data - the String to be decoded
NullPointerException - if the given String
is null
ParseException - if the given String
does not contain the type and state information
required to construct a new object
public static Stringable constructFrom(Class dataType,
String data)
throws ParseException
Constructs a new Stringable object
by constructing a default instance of the given type
and setting the state of the object to the state
encapsulated by the given String.
Throws an exception of type Error if
a fundamental error occurs while instantiating a new
object.
Throws a ParseException if an object
could be instantiated but the data string could not
be used to set the object state.
dataType - the type of object to constructdata - the String to be used to
set the state of the constructed object
ParseException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||