Package loci.formats
Class ClassList<T>
java.lang.Object
loci.formats.ClassList<T>
ClassList is a list of classes for use with
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:
- all text following a hash symbol # is interpreted as comments and ignored
- a key-value pair options can be specified for a given class by using the square brackets [] and an equal separator =
- multiple options can be passed for each class and need to be separated using a comma,
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.
- Author:
- Curtis Rueden ctrueden at wisc.edu
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a list of classes, initially empty.Constructs a list of classes from the given configuration file.Constructs a list of classes from the given configuration file. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given class, which must be assignable to the base class, to the list.voidAdds the given class, which must be assignable to the base class, to the list.voidAdd a key/value pair to the list of options.voidAppends a list of classes which must be assignable to the base classvoidAppends a class list which must be assignable to the base classCast the given class to something that extends the base class.Gets the list of classes as an array.Gets the list of options as a map.booleanReturns whether a given key is an allowed option.booleanDeprecated.voidParses a list of classes from a configuration file.voidParses a class from a string including options and comments.Parses one or more options from a string.voidPrepends a list of classes which must be assignable to the base classvoidPrepends a class list which must be assignable to the base classvoidremoveClass(Class<? extends T> c) Removes the given class from the list.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
KEYS
-
base
Base class to which all classes are assignable. -
classes
List of classes. -
options
List of options.
-
-
Constructor Details
-
ClassList
Constructs a list of classes, initially empty.- Parameters:
base- Base class to which all classes are assignable.
-
ClassList
Constructs a list of classes from the given configuration file.- Parameters:
file- Configuration file containing the list of classes.base- Base class to which all classes are assignable.- Throws:
IOException- if the file cannot be read.
-
ClassList
Constructs a list of classes from the given configuration file.- Parameters:
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. Ifnull, 'file' is interpreted as an absolute path name.- Throws:
IOException- if the file cannot be read.
-
-
Method Details
-
parseOptions
Parses one or more options from a string.- Parameters:
s- A string containing a series of options formatted as key1=value1,key2=value2.- Returns:
- a map populated with the parsed key/value pairs
-
parseLine
Parses a class from a string including options and comments. This function assumes the string is formatted as package.class[key1=value1,key2=value2] # comments. Options will be parsed and stored in a local map. If the class can be loaded, then each key/value pair will be stored in the options as package.class.key/value.- Parameters:
line- A string containing the class, options and comments
-
parseFile
Parses a list of classes from a configuration file.- Parameters:
file- Configuration file containing the list of classes.location- Class indicating which package to search for the file. Ifnull, 'file' is interpreted as an absolute path name.- Throws:
IOException- if the file cannot be read.
-
addClass
Adds the given class, which must be assignable to the base class, to the list. -
addClass
Adds the given class, which must be assignable to the base class, to the list. -
removeClass
Removes the given class from the list. -
append
Appends a class list which must be assignable to the base class -
append
Appends a list of classes which must be assignable to the base class -
prepend
Prepends a class list which must be assignable to the base class -
prepend
Prepends a list of classes which must be assignable to the base class -
getClasses
Gets the list of classes as an array. -
getOptions
Gets the list of options as a map. -
isWhitelistedKey
Deprecated.UseisAllowedKey(String)instead.Returns whether a given key is an allowed option. -
isAllowedKey
Returns whether a given key is an allowed option. -
addOption
Add a key/value pair to the list of options. -
cast
Cast the given class to something that extends the base class.- Parameters:
rawClass- the class to be cast
-
isAllowedKey(String)instead.