|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dasein.attributes.DataTypeFactory<V>
public abstract class DataTypeFactory<V>
Manages attribute data types and access to custom data types.
Last modified: $Date: 2009/01/30 23:01:50 $
| Nested Class Summary | |
|---|---|
static class |
DataTypeFactory.Constraint
A constraint helps narrow down the set of possible values associated with the underlying data type. |
| Constructor Summary | |
|---|---|
DataTypeFactory()
Constructs a new data type factory instance. |
|
| Method Summary | |
|---|---|
DataTypeFactory.Constraint |
getConstraint(String... typeInfo)
Provides the next constrain on this data type based on provided type info. |
Collection<DataTypeFactory.Constraint> |
getConstraints()
Implementing classes should override this method to define any governing constraints. |
abstract Translator<String> |
getDisplayName()
Provides a multi-lingual display name for this data type. |
String |
getDisplayValue(Locale loc,
Object ob)
Provides a display version of the specified value translated for the target locale. |
String |
getDisplayValue(Object ob)
Provides a display value for an instance of this data type. |
static DataTypeFactory<?> |
getInstance(String tname)
Provides access to the data type factory associated with the specified type name. |
String |
getStringValue(Object ob)
Converts the specified value to a string representation for storage. |
abstract DataType<V> |
getType(boolean ml,
boolean mv,
boolean req,
String... typeArgs)
Provides access to the underlying data type object that governs this data type. |
abstract DataType<V> |
getType(String grp,
Number idx,
boolean ml,
boolean mv,
boolean req,
String... typeArgs)
Provides access to the underlying data type object that governs this data type. |
abstract String |
getTypeName()
|
static Collection<DataTypeFactory<?>> |
getTypes()
Lists all types known to the system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DataTypeFactory()
| Method Detail |
|---|
public static DataTypeFactory<?> getInstance(String tname)
tname - the name of the data type for the desired factory
InvalidAttributeException - when an unknown type is sought outpublic static Collection<DataTypeFactory<?>> getTypes()
public DataTypeFactory.Constraint getConstraint(String... typeInfo)
Provides the next constrain on this data type based on provided type info. If no
further constraints exist, it should return null. A user interface
will repeatedly make calls to this method to help narrow down a type definition.
The first call will pass in no type info and should be identitical
to getConstraints().iterator().next(). Subsequent calls
will pass in selections based on the previous constraint.
You may override this method to customize its functionality (such as, offer
conditional constraints based on prior input). For example of overriding with
conditional constraints,
see StringFactory.getConstraint(String[]).
An example from Simplicis CMS is a
media data type. It has as constraints a media type
(such as an image, video, document, etc.) and a media group (a user
defined categorization for media assets that holds the type information for
media objects). In the CMS, when a page has an attribute of type media,
only media assets matching the type and group of the attribute are presented in
the choice box for the content owner. The UI can do this because of the constraints.
When the programmer designs the page type, they need to identify which type and group should be included in the choice box. Simplicis has a UI that enables the programmer to manually specify data types (as a result, Simplicis programmers can add new data types without having to alter the Simplicis UI). To accomplish this, the UI needs to prompt for first the media type, and then only those media groups matching the selected media type.
getStringValue(Object) of the selected typemedia group with the specified type info as a type parameter.
typeInfo - the string values from previous constraints
public Collection<DataTypeFactory.Constraint> getConstraints()
MediaAttribute data type that had values
of a specific media type. For one attribute, "images", only Media
objects that are images are allowed. For another attribute, "documents",
only documents are allowed. You would thus have a MediaTypeAttribute
data type that allowed media types (image, document, etc). That data type, in turn,
would be a constraint on your MediaAttribute data type.
public abstract Translator<String> getDisplayName()
public String getDisplayValue(Object ob)
Translator, then this method will provide the display value
for the default system locale as defined in Locale.getDefault().
ob - the value for which a display value is being sought
public String getDisplayValue(Locale loc,
Object ob)
loc - the locale for which the display should be translatedob - the target value
public String getStringValue(Object ob)
ob - the object to be converted
public abstract String getTypeName()
public abstract DataType<V> getType(boolean ml,
boolean mv,
boolean req,
String... typeArgs)
ml - is the data type multi-lingual?mv - is the data type multi-valued?req - is a value for the data type required?typeArgs - arbitrary parameters with meaning dependent on the underlying type
public abstract DataType<V> getType(String grp,
Number idx,
boolean ml,
boolean mv,
boolean req,
String... typeArgs)
grp - the group of the data type.idx - the index of the data type.ml - is the data type multi-lingual?mv - is the data type multi-valued?req - is a value for the data type required?typeArgs - arbitrary parameters with meaning dependent on the underlying type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||