Class ParameterFinder<P extends uk.ac.starlink.task.Parameter>


  • public abstract class ParameterFinder<P extends uk.ac.starlink.task.Parameter>
    extends java.lang.Object
    Used for obtaining a parameter qualified by an optional suffix.

    In some cases, it is desirable to allow parameters which are logically associated with a layer suffix to be specified without the suffix, for instance if you have three layers using the same table x, it's nice to write "in=x" as a shorthand for "in1=x in2=x in3=x". But if in2=x is present in the environment, that will be used in preference.

    Since:
    2 Sep 2014
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      ParameterFinder()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract P createParameter​(java.lang.String suffix)
      Concrete subclasses must implement this method to create a parameter of the right type with an arbitrary suffix.
      P findParameter​(uk.ac.starlink.task.Environment env, java.lang.String fullSuffix)
      Returns an existing parameter to use for obtaining a value associated with the given layer suffix from the given environment.
      P findParameterByName​(java.lang.String target, java.lang.String fullSuffix)
      Attempts to locate a parameter known by this finder with the given name.
      P getParameter​(uk.ac.starlink.task.Environment env, java.lang.String fullSuffix)
      Calls findParameter(uk.ac.starlink.task.Environment, java.lang.String), but if the result is null, a parameter with the full suffix is returned.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParameterFinder

        public ParameterFinder()
    • Method Detail

      • createParameter

        public abstract P createParameter​(java.lang.String suffix)
        Concrete subclasses must implement this method to create a parameter of the right type with an arbitrary suffix.
        Parameters:
        suffix - arbitrary suffix
        Returns:
        parameter of with the given suffix
      • getParameter

        public P getParameter​(uk.ac.starlink.task.Environment env,
                              java.lang.String fullSuffix)
        Calls findParameter(uk.ac.starlink.task.Environment, java.lang.String), but if the result is null, a parameter with the full suffix is returned. In that case, the environment doesn't already have a value for the parameter, but it may take steps to obtain one (like asking the user).
        Parameters:
        env - execution environment, possibly populated with values
        fullSuffix - suffix associated with the layer for which the value is required
        Returns:
        parameter for obtaining a value associated with the layer suffix, not null
      • findParameter

        public P findParameter​(uk.ac.starlink.task.Environment env,
                               java.lang.String fullSuffix)
        Returns an existing parameter to use for obtaining a value associated with the given layer suffix from the given environment. If the environment contains a value for the parameter with the given suffix, or of any shortened form of that suffix (including the empty string), that parameter is returned. Otherwise, null is returned.
        Parameters:
        env - execution environment, possibly populated with values
        fullSuffix - suffix associated with the layer for which the value is required
        Returns:
        parameter for obtaining a value associated with the layer suffix, or null
      • findParameterByName

        public P findParameterByName​(java.lang.String target,
                                     java.lang.String fullSuffix)
        Attempts to locate a parameter known by this finder with the given name. If it can't be found, return null.
        Parameters:
        target - required parameter name (not case-sensitive)
        fullSuffix - suffix associated with the layer for which the value is required
        Returns:
        parameter with name target, or null