package journal.reader; import java.io.FileReader; import java.io.IOException; import java.io.PrintStream; import java.io.Reader; import java.util.Properties; /* * Simple helper class to transport all options together in one block */ public class Options { public enum Names { COMPRESSED("reader.compressed", Boolean.FALSE.toString()), VERBOSE("reader.verbose", Boolean.FALSE.toString()), CASE_INSENSITIVE("reader.caseinsensitive", Boolean.FALSE.toString()), ACTION("reader.action","journal.action.JournalAction"), FILTER("reader.filter", ""), OUTPUT_FILE("reader.outputfile", ""), SQL_CLASSPATH("sql.classpath", ""), SQL_CLASSNAME("sql.classname", ""), SQL_CONNECTION("sql.connection", ""), SQL_BATCHSIZE("sql.batchsize", "100"), RENAMER_FILENAME("renamer.filename", ""), RENAMER_PATCH("renamer.patch", ""), RENAMER_USER("renamer.user", Boolean.FALSE.toString()), RENAMER_CLIENT("renamer.user", Boolean.FALSE.toString()); final String option; final String defaultValue; private Names(String option, String defaultValue) { this.option = option; this.defaultValue = defaultValue; } public String option() { return option; } public String defaultValue() { return defaultValue; } } private Properties defineDefaultProperties() { Properties prop = new Properties(); for (Options.Names o : Options.Names.values()) { prop.setProperty(o.option, o.defaultValue); } return prop; } public void loadProperties(String fileName) throws IOException { Reader reader = new FileReader(fileName); properties.load(reader); } public String getProperty(String propertyName) { return properties.getProperty(propertyName); } public String getProperty(Options.Names opt) { return properties.getProperty(opt.option); } public Options() { } public boolean compressed; public boolean verbose; public boolean caseInsensitive; public PrintStream outputStream; public PrintStream errorStream; public Properties properties = new Properties(defineDefaultProperties()); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 8027 | Sven Erik Knop |
Moved exceptions to their own package. Enabled new Action FilepathRenamer (not fully tested yet). |
||
#4 | 8023 | Sven Erik Knop |
Complete rewrite of the configuration file, now based on an ini-file format. The ini file has a general [reader] section for settings like verbose, outputFile, case-sensitivity and so on. It also allows to set up a range of Actions and Filters. The section name here is the fully classified class name, followed by settings for the particular actions. An example will make this clearer: ================================================================ [reader] verbose=true [journal.action.UserRenamer] fileName=user.txt patch=True outputFile=user.out [journal.action.ClientRenamer] fileName=client.txt outputFile=client.out patch=true ================================================================ I will provide more example set-ups in the near future. Filters are classes implementing journal.action.Filter (soon to be journal.filter.Filter) which can be chained together and are all executed before the actions. Actions are applied in order that they are given in the config file. |
||
#3 | 8020 | Sven Erik Knop | Replace public Option attributes with setters and getters. | ||
#2 | 8019 | Sven Erik Knop | Safety checks for case-sensitivity and Unicode, now provided in the checkpoint. | ||
#1 | 7527 | Sven Erik Knop |
JournalReader, now in its proper place. Documentation to follow. |