Class Options

java.lang.Object
ecmwf.common.text.Options

public final class Options extends Object
The Class Options.
  • Constructor Details

    • Options

      public Options()
      Instantiates a new Options with no parameters (empty).
    • Options

      public Options(String options)
      Instantiates a new Options. Parse options in the form: filesize=">1234";fileage>=24h,dateformat=yyyyMMdd;datedelta="-1d". Default delimiters are ";", "," and new line.
      Parameters:
      options - the options
    • Options

      public Options(String options, String delimiters)
      Instantiates a new Options. Parse options in the form: filesize=">1234";fileage>=24h,dateformat=yyyyMMdd;datedelta="-1d". Default delimiters are ";", "," and new line if specified delimiters is empty or null.
      Parameters:
      options - the options
      delimiters - the delimiters
    • Options

      public Options(Map<String,String> options)
      Instantiates a new options. Called from ECtransSetup to use json objects.
      Parameters:
      options - the options
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Checks if is empty.
      Returns:
      true, if is empty
    • inject

      public void inject(String name, String value)
      Inject (e.g. options.inject("$test", "myFileName")).
      Parameters:
      name - the name
      value - the value
    • inject

      public void inject(Options options)
      Inject provided options into current options. We have to order the list of keys by length otherwise a "time" and "timestep" key might clash if not taken in the right order (e.g. if $ab=12 and $abcd=15 then the string 'c=$abcd,$ab' would be translated into 'c=12cd,12' instead of 'c=15,12).
      Parameters:
      options - the options
    • replace

      public StringBuilder replace(StringBuilder target) throws IOException
      Replace parameters into provided target. We have to order the list of keys by length otherwise a "time" and "timestep" key might clash if not taken in the right order (e.g. if $ab=12 and $abcd=15 then the string 'c=$abcd,$ab' would be translated into 'c=12cd,12' instead of 'c=15,12).
      Parameters:
      target - the target
      Returns:
      the string builder
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • get

      public String get(String option, String defaultValue)
      Gets the.
      Parameters:
      option - the option
      defaultValue - the default value
      Returns:
      the string
    • get

      public int get(String option, int defaultValue)
      Gets the.
      Parameters:
      option - the option
      defaultValue - the default value
      Returns:
      the int
    • get

      public long get(String option, long defaultValue)
      Gets the.
      Parameters:
      option - the option
      defaultValue - the default value
      Returns:
      the long
    • get

      public boolean get(String option, boolean defaultValue)
      Gets the.
      Parameters:
      option - the option
      defaultValue - the default value
      Returns:
      true, if successful
    • getDuration

      public Duration getDuration(String option, Duration defaultValue)
      Gets the duration.
      Parameters:
      option - the option
      defaultValue - the default value
      Returns:
      the duration
    • getBoolean

      public Boolean getBoolean(String option, Boolean defaultValue)
      Gets the boolean.
      Parameters:
      option - the option
      defaultValue - the default value
      Returns:
      the boolean
    • getProperties

      public Properties getProperties()
      Gets the data as properties.
      Returns:
      the properties
    • matches

      public boolean matches(String option, String value)
      Matches.
      Parameters:
      option - the option
      value - the value
      Returns:
      true, if successful
    • matches

      public boolean matches(String option, String value, String defaultRegex)
      Matches.
      Parameters:
      option - the option
      value - the value
      defaultRegex - the default regex
      Returns:
      true, if successful
    • checkLong

      public boolean checkLong(String option, long currentLong)
      Check long.
      Parameters:
      option - the option
      currentLong - the current long
      Returns:
      true, if successful
    • checkDate

      public boolean checkDate(String option, long currentDate)
      Check date.
      Parameters:
      option - the option
      currentDate - the current date
      Returns:
      true, if successful