Package adams.core

Class Placeholders

    • Method Detail

      • initialize

        protected void initialize()
        loads the props file and interpretes it.
      • placeholders

        public Set<String> placeholders()
        Returns all stored placeholder keys (local + global).
        Returns:
        the placeholder keys (local + global)
      • noCollapse

        public Set<String> noCollapse()
        Returns the placeholders that are excluded from collapsing.
        Returns:
        the placeholder keys
      • has

        public boolean has​(String key)
        Checks whether the placeholder exists.
        Parameters:
        key - the (uppercase) name of the placeholder to check
        Returns:
        true if available
      • get

        public String get​(String key)
        Returns the placeholder for the given (uppercase!) key. Trailing path element separators ("/" or "\") are always stripped.
        Parameters:
        key - the (uppercase) name of the placeholder to retrieve
        Returns:
        the value, null if not found
      • set

        public String set​(String key,
                          String value)
        Sets the placeholder value under the specified key.
        Parameters:
        key - the placeholder key (uppercase!)
        value - the value of the placeholder
        Returns:
        any previously stored value for the placeholder, null if none previously stored
      • remove

        public String remove​(String key)
        Removes the placeholder value under the specified key.
        Parameters:
        key - the placeholder key (uppercase!) to remove
        Returns:
        any previously stored value for the placeholder, null if none previously stored
      • isValid

        public boolean isValid​(String s)
        Checks whether all placeholders in the given string can be expanded.
        Parameters:
        s - the string to check
        Returns:
        true if all placeholders could be expanded
      • expand

        public String expand​(String s)
        Expands all placeholders in the given string.
        Parameters:
        s - the string to expand
        Returns:
        the string with the placeholders replaced
      • doExpand

        protected String doExpand​(String s)
        Expands all placeholders in the given string.
        Parameters:
        s - the string to expand
        Returns:
        the string with the placeholders replaced
      • collapse

        public String collapse​(String s)
        Matches all placeholders against the string. The one that shortens the string most, will be used.
        Parameters:
        s - the string to process
        Returns:
        the processed string
      • toString

        public String toString()
        Returns the underlying properties storing the placeholders as simple string.
        Overrides:
        toString in class Object
        Returns:
        the properties as (simple) string
      • toProperties

        public Properties toProperties()
        Turns the global placeholders into a properties object.
        Returns:
        the generated properties
      • getSingleton

        public static Placeholders getSingleton()
        Returns the singleton instance of the Placeholders.
        Returns:
        the singleton
      • isValidStr

        public static boolean isValidStr​(String s)
        Checks whether all placeholders can be expanded.
        Parameters:
        s - the string to process
        Returns:
        true if all placeholders could be expanded
      • expandStr

        public static String expandStr​(String s)
        Expands the placeholders in the given string.
        Parameters:
        s - the string to process
        Returns:
        the processed string
      • collapseStr

        public static String collapseStr​(String s)
        Adds placeholders to the given string.
        Parameters:
        s - the string to process
        Returns:
        the processed string
      • main

        public static void main​(String[] args)
        For outputting placeholders.
        Parameters:
        args - the commandline arguments: [-env ]