public class ClassList<T> extends Object
ImageReader
or
ImageWriter
, parsed from a configuration file such as readers.txt
or writers.txt.
When constructing a ClassList
object, each line of the
configuration file is parsed using the following rules:
For instance, constructing a ClassList
object using the absolute
path to a configuration file containing the following lines:
# List of classes package1.class1 package2.class2 # a simple class package3.class3[key1=value1,key2=value2] # a class with optionswill attempt to create a list of three classes . Additionally, if the last class is added, two key/value pairs will be stored in the options map: package3.class3.key1=value and package3.class3.key2=value2.
Modifier and Type | Field and Description |
---|---|
private Class<T> |
base
Base class to which all classes are assignable.
|
private List<Class<? extends T>> |
classes
List of classes.
|
private static String[] |
KEYS |
private static org.slf4j.Logger |
LOGGER |
private Map<String,String> |
options
List of options.
|
Constructor and Description |
---|
ClassList(Class<T> base)
Constructs a list of classes, initially empty.
|
ClassList(String file,
Class<T> base)
Constructs a list of classes from the given configuration file.
|
ClassList(String file,
Class<T> base,
Class<?> location)
Constructs a list of classes from the given configuration file.
|
Modifier and Type | Method and Description |
---|---|
void |
addClass(Class<? extends T> c)
Adds the given class, which must be assignable
to the base class, to the list.
|
void |
addClass(int index,
Class<? extends T> c)
Adds the given class, which must be assignable
to the base class, to the list.
|
void |
addOption(String key,
String value)
Add a key/value pair to the list of options.
|
void |
append(ClassList<T> c)
Appends a class list which must be assignable to the base class
|
void |
append(List<Class<? extends T>> l)
Appends a list of classes which must be assignable to the base class
|
private Class<? extends T> |
cast(Class<?> rawClass)
Cast the given class to something that extends the base class.
|
Class<? extends T>[] |
getClasses()
Gets the list of classes as an array.
|
Map<String,String> |
getOptions()
Gets the list of options as a map.
|
boolean |
isWhitelistedKey(String s)
Returns whether a given key is a whitelisted option.
|
void |
parseFile(String file,
Class<?> location)
Parses a list of classes from a configuration file.
|
void |
parseLine(String line)
Parses a class from a string including options and comments.
|
Map<String,String> |
parseOptions(String s)
Parses one or more options from a string.
|
void |
prepend(ClassList<T> c)
Prepends a class list which must be assignable to the base class
|
void |
prepend(List<Class<? extends T>> l)
Prepends a list of classes which must be assignable to the base class
|
void |
removeClass(Class<? extends T> c)
Removes the given class from the list.
|
private static final org.slf4j.Logger LOGGER
private static final String[] KEYS
public ClassList(Class<T> base)
base
- Base class to which all classes are assignable.public ClassList(String file, Class<T> base) throws IOException
file
- Configuration file containing the list of classes.base
- Base class to which all classes are assignable.IOException
- if the file cannot be read.public ClassList(String file, Class<T> base, Class<?> location) throws IOException
file
- Configuration file containing the list of classes.base
- Base class to which all classes are assignable.location
- Class indicating which package to search for the file.
If null
, 'file' is interpreted as an absolute path name.IOException
- if the file cannot be read.public Map<String,String> parseOptions(String s)
s
- A string containing a series of options formatted as
key1=value1,key2=value2.public void parseLine(String line)
line
- A string containing the class, options and commentspublic void parseFile(String file, Class<?> location) throws IOException
file
- Configuration file containing the list of classes.location
- Class indicating which package to search for the file.
If null
, 'file' is interpreted as an absolute path name.IOException
- if the file cannot be read.public void addClass(int index, Class<? extends T> c)
public void addClass(Class<? extends T> c)
public void append(ClassList<T> c)
public void append(List<Class<? extends T>> l)
public void prepend(ClassList<T> c)
public void prepend(List<Class<? extends T>> l)
public boolean isWhitelistedKey(String s)
public void addOption(String key, String value)
Copyright © 2016 Open Microscopy Environment