Class MacroHandler


  • public class MacroHandler
    extends java.lang.Object
    Handler for Macros
    • Constructor Summary

      Constructors 
      Constructor Description
      MacroHandler()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean containsMacros​(java.lang.String input)
      Check if input contains unresolved macros
      static int findClosingBrace​(java.lang.String input, int pos)  
      static java.lang.String replace​(MacroValueProvider macros, java.lang.String input)
      Replace macros in input
      • Methods inherited from class java.lang.Object

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

      • MacroHandler

        public MacroHandler()
    • Method Detail

      • containsMacros

        public static boolean containsMacros​(java.lang.String input)
        Check if input contains unresolved macros
        Parameters:
        input - Text that may contain macros "$(NAME)" or "${NAME}", even escaped ones because they need to be un-escaped
        Returns:
        true if there is at least one potential macro
      • replace

        public static java.lang.String replace​(MacroValueProvider macros,
                                               java.lang.String input)
                                        throws java.lang.Exception
        Replace macros in input
        Parameters:
        macros - MacroValueProvider to use
        input - Text that may contain macros "$(NAME)" or "${NAME}", also allowing nested "${{INNER}}"
        Returns:
        Text where all macros have been resolved
        Throws:
        java.lang.Exception - on error, including recursive macro that never resolves
      • findClosingBrace

        public static int findClosingBrace​(java.lang.String input,
                                           int pos)
        Parameters:
        input - Input that might contain '(..)' or '{..}'
        pos - Position of opening '(' or '{'
        Returns:
        Position of closing ')' respectively '}', or -1