Package org.apache.uima.util.impl
Class Settings_impl
- java.lang.Object
-
- org.apache.uima.util.impl.Settings_impl
-
- All Implemented Interfaces:
Settings
public class Settings_impl extends java.lang.Object implements Settings
Class that reads properties files containing external parameter overrides used by the ExternalOverrideSettings_impl class. Similar to java.util.Properties but: supports UTF-8 files reverses priority in that duplicate key values are ignored, i.e. values cannot be changed arrays are represented as strings, e.g. '[elem1,elem2]', and can span multiple lines '\' can be used to escape $ [ , ] and the line-end
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.regex.PatternevalPatternprotected static java.lang.StringLOG_RESOURCE_BUNDLEprivate java.util.Map<java.lang.String,java.lang.String>mapprivate java.io.BufferedReaderrdrprivate java.lang.ThreadLocal<java.util.HashMap<java.lang.String,java.lang.Integer>>tlResolving
-
Constructor Summary
Constructors Constructor Description Settings_impl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanendsWithEscape(java.lang.String line)private java.lang.StringextendLine(java.lang.String line)private java.lang.StringgetArray(java.lang.String line)java.util.Set<java.lang.String>getKeys()Return a set of keys of all properties in the mapprivate java.lang.StringgetLine()java.lang.StringgetSetting(java.lang.String name)Get the value of an external override setting.java.lang.String[]getSettingArray(java.lang.String name)Get the array of values for an external override setting.private booleanisEscaped(java.lang.String line, int ichar)voidload(java.io.InputStream in)Load properties from an input stream.voidloadSystemDefaults()Load properties from the comma-separated list of resources specified in the system property UimaExternalOverrides Resource names may be specified with a prefix of "file:" or "path:".java.lang.StringlookUp(java.lang.String name)Look up the value for a property.private java.lang.StringlookUp(java.lang.String from, java.lang.String name)java.lang.Stringresolve(java.lang.String value)Replace variable references in a string.private java.lang.Stringresolve(java.lang.String from, java.lang.String value)private java.lang.Stringunescape(java.lang.String token)
-
-
-
Field Detail
-
LOG_RESOURCE_BUNDLE
protected static final java.lang.String LOG_RESOURCE_BUNDLE
- See Also:
- Constant Field Values
-
rdr
private java.io.BufferedReader rdr
-
map
private java.util.Map<java.lang.String,java.lang.String> map
-
tlResolving
private java.lang.ThreadLocal<java.util.HashMap<java.lang.String,java.lang.Integer>> tlResolving
-
evalPattern
private java.util.regex.Pattern evalPattern
-
-
Method Detail
-
getKeys
public java.util.Set<java.lang.String> getKeys()
Return a set of keys of all properties in the map
-
load
public void load(java.io.InputStream in) throws java.io.IOExceptionLoad properties from an input stream. Existing properties are not changed and a warning is logged if the new value is different. May be called multiple times, so effective search is in load order. Arrays are enclosed in [] and the elements may be separated by,or new-line, so can span multiple lines without using a final \
-
loadSystemDefaults
public void loadSystemDefaults() throws ResourceConfigurationExceptionLoad properties from the comma-separated list of resources specified in the system property UimaExternalOverrides Resource names may be specified with a prefix of "file:" or "path:". If the prefix is "path:" the name must use the Java-style dotted format, similar to an import by name. The name is converted to a URL with a suffix of ".settings" and is looked up in the datapath and classpath. If the prefix is "file:" or is omitted the filesystem is searched. Resources are loaded in list order. Duplicate properties are ignored so entries in a file override any in following files.- Specified by:
loadSystemDefaultsin interfaceSettings- Throws:
ResourceConfigurationException- wraps IOException
-
lookUp
public java.lang.String lookUp(java.lang.String name) throws ResourceConfigurationExceptionLook up the value for a property. Recursively evaluate the value replacing references ${key} with the value of the key. Nested references such as ${name-${suffix}} are supported. Exceptions are thrown for circular references and undefined references. To avoid evaluation and get ${key} in the output escape the $ or {, e.g. \${key} Arrays are returned as a comma-separated string, e.g. "[elem1,elem2]" Note: escape characters are not removed as they may affect array separators. Used by getSetting and getSettingArray- Specified by:
lookUpin interfaceSettings- Parameters:
name- - name to look up- Returns:
- - value of property
- Throws:
ResourceConfigurationException- if the value references an undefined property
-
lookUp
private java.lang.String lookUp(java.lang.String from, java.lang.String name) throws ResourceConfigurationException- Throws:
ResourceConfigurationException
-
resolve
public java.lang.String resolve(java.lang.String value) throws java.lang.ExceptionReplace variable references in a string.- Parameters:
value- - String to scan for variable references- Returns:
- - value with all references resolved and escapes processed
- Throws:
java.lang.Exception- -
-
resolve
private java.lang.String resolve(java.lang.String from, java.lang.String value) throws ResourceConfigurationException- Throws:
ResourceConfigurationException
-
getSetting
public java.lang.String getSetting(java.lang.String name) throws ResourceConfigurationExceptionDescription copied from interface:SettingsGet the value of an external override setting.- Specified by:
getSettingin interfaceSettings- Parameters:
name- - the name of the parameter- Returns:
- - the value found in the settings file(s), or null if missing.
- Throws:
ResourceConfigurationException- if the value references an undefined property, or the value is an array- See Also:
Settings.getSetting(java.lang.String)
-
getSettingArray
public java.lang.String[] getSettingArray(java.lang.String name) throws ResourceConfigurationExceptionDescription copied from interface:SettingsGet the array of values for an external override setting.- Specified by:
getSettingArrayin interfaceSettings- Parameters:
name- - the name of the parameter- Returns:
- - an array of values found in the settings file(s), or null if missing.
- Throws:
ResourceConfigurationException- if the value references an undefined property, or the value is not an array- See Also:
Settings.getSettingArray(java.lang.String)
-
unescape
private java.lang.String unescape(java.lang.String token)
-
endsWithEscape
private boolean endsWithEscape(java.lang.String line)
-
getArray
private java.lang.String getArray(java.lang.String line) throws java.io.IOException- Throws:
java.io.IOException
-
getLine
private java.lang.String getLine() throws java.io.IOException- Throws:
java.io.IOException
-
extendLine
private java.lang.String extendLine(java.lang.String line) throws java.io.IOException- Throws:
java.io.IOException
-
isEscaped
private boolean isEscaped(java.lang.String line, int ichar)
-
-