@ALDDataIOProvider public class ALDParametrizedClassDataIOCmdline extends ALDStandardizedDataIOCmdline
ALDStandardizedDataIOCmdline
it
implements the Alida syntax conventions.
For parametrized classes reading is done only for parameters annotated
with ALDClassParameter
.
Either all annotated parameters are written/formated or a
subset as specified by a format string.
For oeprators reading is done only for IN and INOUT parameters. Either all OUT and INPUT parameters are written/formated or a subset as specified by a format string.
Modifier and Type | Field and Description |
---|---|
private boolean |
debug
debug messages
|
DERIVEDCLASS_CHAR, FILEIO_CHAR
Constructor and Description |
---|
ALDParametrizedClassDataIOCmdline() |
Modifier and Type | Method and Description |
---|---|
private void |
addParameter(String name,
Object obj,
Field field,
String formatString,
StringBuffer bufstr)
Format the parameter
name of the object obj into the buffer bufstr
using formatString to determine formating. |
String |
formatAsString(Object obj)
Generic formatter to string of parametrized classes.
|
String |
formatAsString(Object obj,
String formatString)
Format all parameters of this parametrized class annotated
with
ALDClassParameter
into a string. |
static LinkedList<String> |
lookupParameternames(ALDOperator op,
String pre)
Lookup all parameter names of the operator with prefix
pre . |
Object |
parse(Field field,
Class<?> cl,
String valueString)
Parser for parametrized classes and ALDOperators.
|
Object |
parse(Field field,
Class<?> cl,
String valueString,
ALDOperator op)
Generic Parser for parametrized classes and ALDOperators.
|
Collection<Class<?>> |
providedClasses()
Interface method to announce class for which IO is provided for
|
readData, requiresNewlines, writeData
public Collection<Class<?>> providedClasses()
public Object parse(Field field, Class<?> cl, String valueString) throws ALDDataIOProviderException, ALDDataIOManagerException
ALDDataIOCmdline
.
For parametrized classes each name has to be an annotated parameter.
For operators each name has to be an IN or INOUT parameter name of the operator and receives its value from
the valueString
.
If the list of name=value pairs is empty, i.e. no parameters are to be parsed, the empty string is accepted, too.
parse
in class ALDStandardizedDataIOCmdline
field
- Field of object to be returnedcl
- Class of object to be returned.valueString
- Source from where to read data (e.g. a filename).ALDDataIOProviderException
ALDDataIOManagerException
ALDDataIOManagerCmdline
public Object parse(Field field, Class<?> cl, String valueString, ALDOperator op) throws ALDDataIOProviderException, ALDDataIOManagerException
ALDDataIOCmdline
.
For parametrized classes each name has to be an annotated parameter.
For operators each name has to be an IN or INOUT parameter name of the operator and receives its value from
the valueString
.
If the list of name=value pairs is empty, i.e. no parameters are to be parsed, the empty string is accepted, too.
For the class of the object to be read see ALDDataIOCmdline
.
As a valueString
a comma separated list of name=value pairs enclosed in curly brackets
is expected. Each name has to be a member of the class or a super class which is annotated
with ALDClassParameter
.
The readData
method of the provider for the class of the member variable
is used to read the objects value from value
.
field
- cl
- valueString
- op
- if a ALDOperator is to be parse this is an instance of this class. Ignored when parsing
a parametrized classALDDataIOProviderException
ALDDataIOManagerException
public String formatAsString(Object obj, String formatString) throws ALDDataIOProviderException, ALDDataIOManagerException
ALDClassParameter
into a string.
If formatString
starts with a curly bracket it is assume
to contained a comma seprated list of name=value pairs enclosed in a
matching curly brackets.
In this case, only the (annotated) members named in this list are formated where the value
is passed to the writeData
of the dataIO provider handling the parameter's type.
In extension, is a name equals *
all members non listed in the
formatString
are formated using the value
of this pair.
If formatString
does not start with a curly bracket all annotated
members are formated.
formatAsString
in class ALDStandardizedDataIOCmdline
obj
- parametrized class to be formatedformatString
- ALDDataIOProviderException
ALDDataIOManagerException
public String formatAsString(Object obj) throws ALDDataIOProviderException, ALDDataIOManagerException
ALDClassParameter
.formatAsString
in class ALDStandardizedDataIOCmdline
obj
- object to formatALDDataIOProviderException
ALDDataIOManagerException
private void addParameter(String name, Object obj, Field field, String formatString, StringBuffer bufstr) throws ALDDataIOProviderException, ALDDataIOManagerException
name
of the object obj
into the buffer bufstr
using formatString
to determine formating.name
- parameter to be formatedobj
- object for which to format parameterfield
- field of parameter to be formatedbufstr
- String buffer to append formated parameterALDDataIOProviderException
ALDDataIOManagerException
public static LinkedList<String> lookupParameternames(ALDOperator op, String pre)
pre
.
If one of the parameters exactly matches pre
only this single
parameter name is returned.pre
or the single parameter
exactly matching pre
Copyright © 2010–2021 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.