public abstract class ALDStandardizedDataIOCmdline extends Object implements ALDDataIOCmdline
These conventions are detailed in the documentation if the methods readData and writeData in this class below.
They handle IO from/to file and reading derived classes of the class handled by an dataIO provider.
Classes extending this class are expected to override the methods parse and
formatAsString which do the actual reading/parsing or writing/formating
subsequent to generic handling of Alida convention with respect to derived classes
and IO form/to file.
| Modifier and Type | Field and Description |
|---|---|
static char |
DERIVEDCLASS_CHAR
As a convention this character starts a derived class name,
and is terminated by ':'
|
static char |
FILEIO_CHAR
As a convention a parameter value starting with this character indicates
that the actual parameter should be read from or writen to a file.
|
| Constructor and Description |
|---|
ALDStandardizedDataIOCmdline() |
| Modifier and Type | Method and Description |
|---|---|
abstract String |
formatAsString(Object obj)
Returns the string representations of this object
This method is assumed to directly format the
obj into the string return and make no
prior interpretation regarding a file to be used. |
String |
formatAsString(Object obj,
String formatString)
Returns the external representations of this object using a formatString.
|
abstract Object |
parse(Field field,
Class<?> cl,
String valueString)
Returns an object instantiated from valueString.
|
Object |
readData(Field field,
Class<?> cl,
String valueString)
Read an object using
valueString. |
String |
writeData(Object obj,
String formatString)
Return a string representation of given object value or print it to a file.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprovidedClassespublic static final char FILEIO_CHAR
public static final char DERIVEDCLASS_CHAR
public abstract Object parse(Field field, Class<?> cl, String valueString) throws ALDDataIOProviderException, ALDDataIOManagerException
ALDDataIOManagerCmdline.readData(Field,Class,String).
This method is assumed to directly parse the valueString and make no
prior interpretation regarding a file to use or derived class to return.field - Field of object to be returnedcl - Class of object to be returned.valueString - Source from where to read data (e.g. a filename).ALDDataIOProviderExceptionALDDataIOManagerExceptionALDDataIOManagerCmdlinepublic abstract String formatAsString(Object obj) throws ALDDataIOManagerException, ALDDataIOProviderException
obj into the string return and make no
prior interpretation regarding a file to be used.obj - object to formatALDDataIOManagerExceptionALDDataIOProviderExceptionpublic String formatAsString(Object obj, String formatString) throws ALDDataIOManagerException, ALDDataIOProviderException
formatString may be used define parts of the object to be formated
or specify format charateristics.
However, formatString should not interpreted in order to decide to
output the object directly to a file (as this is handled by writeData).
The default implementation is equivalent to formatAsString(obj).
obj - object to formatALDDataIOManagerExceptionALDDataIOProviderExceptionpublic Object readData(Field field, Class<?> cl, String valueString) throws ALDDataIOProviderException, ALDDataIOManagerException
valueString.
For the class of the object to be read see ALDDataIOCmdline.
If valueString starts with FILEIO_CHAR the value is read from a file
where the name of this file is the remaining string of valueString.
subsequent to FILEIO_CHAR.
The next step in interpreting the value string is scrutinze
whether an instance of a class deriving the class defined in field or
the class cl is to be returned.
This is indicated by starting the value string (either passed directly via valueString
or the string read from file) with DERIVEDCLASS_CHAR.
by field
If this is the case all charaters up, but excluding, the next colon are
interpreted as this fully qualified class name.
Next it is checked if this class indeed is a proper extension
which in turn required this class to be annotated with ALDDerivedClass.
If this check passes
a dataIO provider of this class is looked up and its readData
invoked with the value string after the deliminating colon.
If no deriving class is requested, the parse method of the
class defined in field or
the class cl is invoked on the value string.
readData in interface ALDDataIOCmdlinefield - Field of object to be returned.cl - Class of object to be returned.valueString - Source from where to read data (e.g. a filename).ALDDataIOProviderExceptionALDDataIOManagerExceptionpublic String writeData(Object obj, String formatString) throws ALDDataIOManagerException, ALDDataIOProviderException
If the given formatString starts with FILEIO_CHAR standard out is used as
target location, otherwise the string remaining subsequent to FILEIO_CHAR is interpreted as file name.
In turn, if the remaining string starts with + the output is apended to the file (with +
removed as filename).
writeData in interface ALDDataIOCmdlineobj - Object to be saved.formatString - String indicated whether to return the value of where to write the value to.ALDDataIOManagerExceptionALDDataIOProviderExceptionALDDataIOManagerCmdlineCopyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.