Class FWParameterContext

java.lang.Object
net.simplace.core.jexl.FWParameterContext
All Implemented Interfaces:
org.apache.commons.jexl3.JexlContext
Direct Known Subclasses:
MapParameterContext, SimVarMapParameterContext

public abstract class FWParameterContext extends Object implements org.apache.commons.jexl3.JexlContext
Source of the parameter values for FWParameterResolver: the values of the pipeline map (GUI, pipelines, data readers) or of a simulation variable map, plus the special parameters, which are the same for all sources.

As JexlContext it provides the variables of JEXL expressions (control attributes, rules). Names may use __ instead of . (as produced by JexlRuleScript from ${a.b}). Assignments within an expression only change a local variable of this context, never the source.

Special parameters (see getSpecialText(String)):

  • directories: _WORKDIR_, _DATADIR_, _PROJECTSDIR_ (also _PROJECTDIR_), _OUTPUTDIR_ (from FWSimEngine), _CACHEDIR_ (from FilePathHelper), _TEMPDIR_ (also TEMPDIR; a new random temporary directory, which is stored as parameter TEMPDIR and reused)
  • time: _DATE_, _DATETIME_, _MILLIS_
  • runtime: _MAX_MEMORY_, _FREE_MEMORY_ (both in MB), _PROCESSORS_
  • LOCAL: language of the current locale (en, de or fr; otherwise de)
  • _PROJECTLINES_: first-last project line (simulations only)
  • $name$: Java runtime property, SETTINGS...: system setting
Author:
Andreas Enders
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.commons.jexl3.JexlContext

    org.apache.commons.jexl3.JexlContext.AnnotationProcessor, org.apache.commons.jexl3.JexlContext.CancellationHandle, org.apache.commons.jexl3.JexlContext.ClassNameResolver, org.apache.commons.jexl3.JexlContext.ModuleProcessor, org.apache.commons.jexl3.JexlContext.NamespaceFunctor, org.apache.commons.jexl3.JexlContext.NamespaceResolver, org.apache.commons.jexl3.JexlContext.OptionsHandle, org.apache.commons.jexl3.JexlContext.PragmaProcessor, org.apache.commons.jexl3.JexlContext.ThreadLocal
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    name of the parameter that keeps the temporary directory of _TEMPDIR_
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
     
    get(String aName)
     
    protected Object
     
    protected abstract Object
     
    protected Integer[]
     
    Resolves a special parameter (see class description).
    protected abstract String
    getText(String aName)
     
    boolean
    has(String aName)
     
    static boolean
     
     
    void
    set(String aName, Object aValue)
     
    protected abstract void
    store(String aName, String aValue)
    Stores the temporary directory created by _TEMPDIR_ in the source.
    protected static String
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TEMPDIR

      public static final String TEMPDIR
      name of the parameter that keeps the temporary directory of _TEMPDIR_
      See Also:
  • Constructor Details

    • FWParameterContext

      public FWParameterContext()
  • Method Details

    • getText

      protected abstract String getText(String aName)
      Parameters:
      aName - parameter name
      Returns:
      the value as text for token replacement (empty for an existing parameter without value), or null if the parameter does not exist
    • getObject

      protected abstract Object getObject(String aName)
      Parameters:
      aName - parameter name
      Returns:
      the value for expressions, or null if the parameter does not exist
    • contains

      protected abstract boolean contains(String aName)
      Parameters:
      aName - parameter name
      Returns:
      true if the source has the parameter
    • store

      protected abstract void store(String aName, String aValue)
      Stores the temporary directory created by _TEMPDIR_ in the source.
      Parameters:
      aName - parameter name
      aValue - the value
    • getProjectLines

      protected Integer[] getProjectLines()
      Returns:
      the project lines of the current simulation, or null outside of simulations
    • getLogSource

      protected Object getLogSource()
      Returns:
      the object named as source in log messages
    • isSpecialName

      public static boolean isSpecialName(String aName)
      Parameters:
      aName - parameter name
      Returns:
      true if the name is reserved for special parameters: it starts with _, $ or SETTINGS, or is TEMPDIR or LOCAL
    • getSpecialText

      public String getSpecialText(String aName)
      Resolves a special parameter (see class description).
      Parameters:
      aName - parameter name
      Returns:
      the value as text, or null if the name is no known special parameter or has no value (unset property or setting)
    • resolveText

      public String resolveText(String aName)
      Parameters:
      aName - parameter name
      Returns:
      the value as text for token replacement: special parameter first, then the source; null if neither has a value
    • has

      public boolean has(String aName)
      Specified by:
      has in interface org.apache.commons.jexl3.JexlContext
    • get

      public Object get(String aName)
      Specified by:
      get in interface org.apache.commons.jexl3.JexlContext
    • set

      public void set(String aName, Object aValue)
      Specified by:
      set in interface org.apache.commons.jexl3.JexlContext
    • toParameterName

      protected static String toParameterName(String aJexlName)
      Parameters:
      aJexlName - variable name within an expression
      Returns:
      the parameter name: __ replaced by .