Module jamal.tools

Class OptionsStore

java.lang.Object
javax0.jamal.tools.OptionsStore
All Implemented Interfaces:
javax0.jamal.api.Identified

public class OptionsStore
extends Object
implements javax0.jamal.api.Identified
  • Nested Class Summary

    Nested classes/interfaces inherited from interface javax0.jamal.api.Identified

    javax0.jamal.api.Identified.Undefined
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static String OPTIONS_MACRO_ID  

    Fields inherited from interface javax0.jamal.api.Identified

    DEFAULT_MACRO, MACRO_NAME_ARG1, MACRO_NAME_ARG2
  • Constructor Summary

    Constructors 
    Constructor Description
    OptionsStore()  
  • Method Summary

    Modifier and Type Method Description
    void addOptions​(String... options)
    Add the options to this options store.
    void addOptions​(Set<String> options)
    Add the options to this options store.
    String getId()
    The name of the macro is `options that starts with a backtick.
    static OptionsStore getInstance​(javax0.jamal.api.Processor processor)
    Get the options store that belongs to this processor at this very moment.
    Set<String> getOptions()
    Get the set of options.
    boolean is​(String option)
    Decides if a certain option was set in this option store.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • getInstance

      public static OptionsStore getInstance​(javax0.jamal.api.Processor processor)
      Get the options store that belongs to this processor at this very moment.

      Note that this is not safe to store the result of this method for longer time, because the actual store may be changed when the scope of the processor is going up closing a macro nesting level.

      Parameters:
      processor - the processor of which we need the options store
      Returns:
      the options store. If there was no option defined for this processor then it returns a constant empty options store
    • getId

      public String getId()
      The name of the macro is `options that starts with a backtick. This is a character that is not allowed in a macro name. This way the macro instances will be stored in the macro register when it gets registered programmatically, but the macro source cannot reference it and also the built-in macro define will not overwrite it.
      Specified by:
      getId in interface javax0.jamal.api.Identified
      Returns:
      the constant string `options
    • addOptions

      public void addOptions​(String... options)
      Add the options to this options store. If an option starts with the ~ character then it will be removed from the options. This way it is possible to switch off an option.
      Parameters:
      options - the options to add to the store
    • addOptions

      public void addOptions​(Set<String> options)
      Add the options to this options store. Note that the set of options in this case come from an already existing options store, and thus the strings MUST NOT and CANNOT contain the leading ~ character.
      Parameters:
      options - the options to add to the store
    • getOptions

      public Set<String> getOptions()
      Get the set of options.
      Returns:
      the options set
    • is

      public boolean is​(String option)
      Decides if a certain option was set in this option store.
      Parameters:
      option - the option we look for
      Returns:
      true if the option was set for this store