Class AbstractDirectiveHandler

java.lang.Object
com.igormaznitsa.jcp.directives.AbstractDirectiveHandler
Direct Known Subclasses:
AbortDirectiveHandler, ActionDirectiveHandler, BreakDirectiveHandler, CommentNextLineDirectiveHandler, ContinueDirectiveHandler, DefineDirectiveHandler, EchoDirectiveHandler, ElseDirectiveHandler, EndDirectiveHandler, EndIfDirectiveHandler, ErrorDirectiveHandler, ExcludeIfDirectiveHandler, ExitDirectiveHandler, ExitIfDirectiveHandler, FlushDirectiveHandler, GlobalDirectiveHandler, GlobalElseDirectiveHandler, GlobalEndIfDirectiveHandler, GlobalIfDirectiveHandler, IfDefinedDirectiveHandler, IfDirectiveHandler, IncludeDirectiveHandler, LocalDirectiveHandler, MsgDirectiveHandler, NoAutoFlushHandler, OutDirDirectiveHandler, OutDisabledDirectiveHandler, OutEnabledDirectiveHandler, OutNameDirectiveHandler, PostfixDirectiveHandler, PrefixDirectiveHandler, WhileDirectiveHandler

public abstract class AbstractDirectiveHandler extends Object
The class is the abstract parent for all classes process preprocessor directives
  • Field Details

    • DIRECTIVE_PREFIX

      public static final String DIRECTIVE_PREFIX
      The common preprocessor prefix for all directives
      See Also:
    • PREFIX_FOR_KEEPING_LINES

      public static final String PREFIX_FOR_KEEPING_LINES
      The prefix for lines to be kept by preprocessor
      See Also:
    • PREFIX_FOR_KEEPING_LINES_PROCESSED_DIRECTIVES

      public static final String PREFIX_FOR_KEEPING_LINES_PROCESSED_DIRECTIVES
      The prefix for lines to be kept by preprocessor, which contain processed directives
      See Also:
    • ONE_LINE_COMMENT

      public static final String ONE_LINE_COMMENT
      The prefix for one line comment
      See Also:
    • DIRECTIVES

      public static final AbstractDirectiveHandler[] DIRECTIVES
      The array contains all directives of the preprocessor
    • GLOBAL_DIRECTIVES

      public static final AbstractDirectiveHandler[] GLOBAL_DIRECTIVES
      The array contains preprocessor directives active only during the global preprocessing phase
  • Constructor Details

    • AbstractDirectiveHandler

      public AbstractDirectiveHandler()
  • Method Details

    • getName

      public abstract String getName()
      Get the name of the directive without prefix
      Returns:
      the directive name, must not be null
    • getReference

      public abstract String getReference()
      Get the directive reference, it will be printed for a help request
      Returns:
      the directive reference as a String, must not be null
    • getFullName

      public String getFullName()
      Get the directive name with prefix
      Returns:
      the full directive name (it including prefix)
    • getArgumentType

      public DirectiveArgumentType getArgumentType()
      Get the argument type needed by the directive
      Returns:
      the argument type needed by the directive, it can't be null
    • execute

      public abstract AfterDirectiveProcessingBehaviour execute(String tailString, PreprocessorContext context)
      Execute directive
      Parameters:
      tailString - the tail of the string where the directive has been met, must not be null but can be empty
      context - the preprocessor context
      Returns:
      the needed preprocessor behavior, must not be null
    • executeOnlyWhenExecutionAllowed

      public boolean executeOnlyWhenExecutionAllowed()
      Shows that the directive can be executed only when the preprocessing n active state i.e. if it is in active block //#if..//#endif of //#while
      Returns:
      true if the directive can be executed only if it is in active block, else the directive will be called in any case
    • isGlobalPhaseAllowed

      public boolean isGlobalPhaseAllowed()
      Shows that the directive can be executed during a global preprocessing phase
      Returns:
      true if the directive allows the global directive phase, false if the directive must be ignored during that phase
    • isPreprocessingPhaseAllowed

      public boolean isPreprocessingPhaseAllowed()
      Shows that the directive can be executed during the second preprocessing phase
      Returns:
      true uf the directive can be executed during the second preprocessing phase else false if the directive must be ignored
    • isDeprecated

      public boolean isDeprecated()
      Check that the directive is deprecated one and can be removed in a next release
      Returns:
      true if the directive is deprecated, false otherwise