Class AbstractConfiguration
java.lang.Object
net.simplace.ui.customize.AbstractConfiguration
Abstract config file with important functions for parsing and writing Data to ASCII Configfiles
- Author:
- Andreas Enders
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates an empty configuration (for subclasses).AbstractConfiguration(File aConfigFile, org.jdom2.Element aConfiguration) Reads the lines of the file (errors are logged) and initializes the values. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()if is setModified() new Values will be written to config file.protected abstract voidWrites the values into the lines of the file; has to be implemented by FileFields.getBaseParameterName(String aKey) If specified key specifies a relative parameter value change (by %), the function returns the base parameter name.Returns the key, which specifies a relative parameter value change (by %) for the specified parameter name.protected abstract voidReads the values from the lines of the file; has to be implemented by FileFields.booleanisRelativeParameter(String aKey) Checks whether key specified a relative parameter value change (by %).protected StringreadValue(int aLineNumber, int aBeginColumnNumber, int aEndColumnNumber) voidreplaceParametersFromMap(Map<String, Object> aParamMap) Replaces the parameter tokens${...}in all lines and marks the file as modified.voidMarks the file as modified; only thencommit()writes it.voidMarks the file as unmodified, socommit()does not write it.toString()protected voidwriteValue(String aValue, int aLineNumber, int aBeginColumnNumber, int aEndColumnNumber) Replaces a character range of a line by a value, padded on the left to the width of the range.
-
Field Details
-
RELATIVE_SUFFIX
Parameter name suffix indicating a relative parameter value change (by %).- See Also:
-
iLinesOfFile
-
iFile
the configuration file -
iConfiguration
protected org.jdom2.Element iConfigurationthe XML configuration of this file
-
-
Constructor Details
-
AbstractConfiguration
Reads the lines of the file (errors are logged) and initializes the values.- Parameters:
aConfigFile- the ASCII configuration fileaConfiguration- the XML configuration of this file
-
AbstractConfiguration
protected AbstractConfiguration()Creates an empty configuration (for subclasses).
-
-
Method Details
-
initializeFileValues
protected abstract void initializeFileValues()Reads the values from the lines of the file; has to be implemented by FileFields. -
commitValues
protected abstract void commitValues()Writes the values into the lines of the file; has to be implemented by FileFields. -
commit
public void commit()if is setModified() new Values will be written to config file. -
readValue
- Parameters:
aLineNumber- line index (0-based)aBeginColumnNumber- first character (0-based, inclusive)aEndColumnNumber- last character (0-based, exclusive)- Returns:
- the characters of the line, or an empty string for a
nullline (a warning is logged)
-
writeValue
protected void writeValue(String aValue, int aLineNumber, int aBeginColumnNumber, int aEndColumnNumber) Replaces a character range of a line by a value, padded on the left to the width of the range.Note: the change is made on a copy of the line and is not stored in the lines of the file.
- Parameters:
aValue- the valueaLineNumber- line index (0-based)aBeginColumnNumber- first character (0-based, inclusive)aEndColumnNumber- last character (0-based, exclusive)
-
isRelativeParameter
Checks whether key specified a relative parameter value change (by %).- Parameters:
aKey- a key- Returns:
- TRUE when key ends with "_rel", FALSE otherwise.
-
getBaseParameterName
-
getRelativeParameterName
-
replaceParametersFromMap
-
getConfigurationParmeterValue
-
setModified
public void setModified()Marks the file as modified; only thencommit()writes it. -
setUnModified
public void setUnModified()Marks the file as unmodified, socommit()does not write it. -
toString
-