Class AbstractConfiguration

java.lang.Object
net.simplace.ui.customize.AbstractConfiguration

public abstract class AbstractConfiguration extends Object
Abstract config file with important functions for parsing and writing Data to ASCII Configfiles
Author:
Andreas Enders
  • Field Details

    • RELATIVE_SUFFIX

      public static final String RELATIVE_SUFFIX
      Parameter name suffix indicating a relative parameter value change (by %).
      See Also:
    • iLinesOfFile

      protected Vector<String> iLinesOfFile
      the lines of the file
    • iFile

      protected File iFile
      the configuration file
    • iConfiguration

      protected org.jdom2.Element iConfiguration
      the XML configuration of this file
  • Constructor Details

    • AbstractConfiguration

      public AbstractConfiguration(File aConfigFile, org.jdom2.Element aConfiguration)
      Reads the lines of the file (errors are logged) and initializes the values.
      Parameters:
      aConfigFile - the ASCII configuration file
      aConfiguration - 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

      protected String readValue(int aLineNumber, int aBeginColumnNumber, int aEndColumnNumber)
      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 null line (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 value
      aLineNumber - line index (0-based)
      aBeginColumnNumber - first character (0-based, inclusive)
      aEndColumnNumber - last character (0-based, exclusive)
    • isRelativeParameter

      public boolean isRelativeParameter(String aKey)
      Checks whether key specified a relative parameter value change (by %).
      Parameters:
      aKey - a key
      Returns:
      TRUE when key ends with "_rel", FALSE otherwise.
    • getBaseParameterName

      public String getBaseParameterName(String aKey)
      If specified key specifies a relative parameter value change (by %), the function returns the base parameter name. Otherwise the specified key itself is returned.
      Parameters:
      aKey - a key
      Returns:
      the key without the suffix _rel
    • getRelativeParameterName

      public String getRelativeParameterName(String aKey)
      Returns the key, which specifies a relative parameter value change (by %) for the specified parameter name.
      Parameters:
      aKey - a key
      Returns:
      aKey itself if key already specifies a relative parameter change
    • replaceParametersFromMap

      public void replaceParametersFromMap(Map<String,Object> aParamMap)
      Replaces the parameter tokens ${...} in all lines and marks the file as modified.
      Parameters:
      aParamMap - the parameters
    • getConfigurationParmeterValue

      public String getConfigurationParmeterValue(String aKey)
      Parameters:
      aKey - the key
      Returns:
      the value of the XML configuration for the key, or null
    • setModified

      public void setModified()
      Marks the file as modified; only then commit() writes it.
    • setUnModified

      public void setUnModified()
      Marks the file as unmodified, so commit() does not write it.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      ASCIIConfigFile: file