|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Parser<T>
Provides a mechanism for parsing and rendering string representations of objects.
Specifically, this interface embodies three related capabilties:
For custom-written (as opposed to third-party) value types, the ability for the Parser to provide a
title responsibilities overlap with other conventions for domain objects. Specifically, normally we write a
title() method to return a title. In such cases a typical implementation of Parser would
just delegate to the value type itself to obtain the title (ie invoking the title() method
directly rather than having the framework do this).
Similarly, the ability to return a typical length also overlaps with the TypicalLength annotation;
which is why TypicalLength cannot be applied to types, only to properties and parameters.
For third-party value types, eg Time-and-Money there is no
ability to write title() methods or annotated with TypicalLength; so this is the main
reason that this interface has to deal with titles and lengths.
This interface is used in two complementary ways:
Parseable annotation, allowing a class that needs to be
parseable to indicate how it can be parsed. Whatever the class that implements this interface, it must also expose either a public no-arg constructor, or (for implementations that also are Facets) a public constructor that accepts a single FacetHolder. This constructor allows the framework to instantiate the object reflectively.
DefaultsProvider,
EncoderDecoder,
ValueSemanticsProvider| Method Summary | |
|---|---|
java.lang.String |
displayTitleOf(T object)
The title of the object. |
java.lang.String |
parseableTitleOf(T existing)
A title for the object that is valid but which may be easier to edit than the title provided by a org.nakedobjects.metamodel.facets.object.ident.TitleFacet. |
T |
parseTextEntry(T context,
java.lang.String entry)
Parses a string to an instance of the object. |
int |
typicalLength()
The typical length of objects that can be parsed. |
| Method Detail |
|---|
T parseTextEntry(T context,
java.lang.String entry)
Note that here the implementing class is acting as a factory for itself.
context - -
the context in which the text is being parsed. For example +3 might mean add 3 to the
current number.int typicalLength()
java.lang.String displayTitleOf(T object)
java.lang.String parseableTitleOf(T existing)
org.nakedobjects.metamodel.facets.object.ident.TitleFacet.
The idea here is that the viewer can display a parseable title for an existing object when, for
example, the user initially clicks in the field. So, a date might be rendered via a TitleFacet
as May 2, 2007, but its editable form might be 20070502.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||