Package adams.core

Class QuickInfoHelper


  • public class QuickInfoHelper
    extends Object
    Helper class for assembling quick info strings returned by classes implementing QuickInfoSupporter.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • MAX_ARRAY_STRING_LENGTH

        public static final int MAX_ARRAY_STRING_LENGTH
        the maximum length of generated array strings.
        See Also:
        Constant Field Values
      • EMPTY_ARRAY_STRING

        public static final String EMPTY_ARRAY_STRING
        the string to use for empty arrays.
        See Also:
        Constant Field Values
    • Constructor Detail

      • QuickInfoHelper

        public QuickInfoHelper()
    • Method Detail

      • hasVariable

        public static boolean hasVariable​(OptionHandler handler,
                                          String property)
        Checks whether a variable is attached to the optionhandler's property.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        Returns:
        true if a variable is attached
      • getVariable

        public static String getVariable​(OptionHandler handler,
                                         String property)
        Returns the variable attached to optionhandler's property.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        Returns:
        the variable (incl @{...}), if attached, otherwise null
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      Object current)
        Returns either the variable name attached to optionhandler's property or the current value as string.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        Returns:
        the generated string, can be null if current is null or empty string
      • toString

        protected static String toString​(Object current)
        Generates a string representation from the object (non-array).
        Parameters:
        current - the object to turn into a string
        Returns:
        the generated string
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      Object current,
                                      String prefix)
        Returns either the variable name attached to optionhandler's property or the current value as string.

        Special handling: If the object is an instance of QuickInfoSupporter the simple class name and the quick info in parentheses (if applicable) is output. Range and Index automatically have the string output. For OptionHandler classes, only the simple class name is output. For Class objects, the simple class name is output. For EnumWithCustomDisplay enums, the display string is output.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        prefix - the prefix string to prepend the variable/text with, ignored if null
        Returns:
        the generated string, can be null if current is null or empty string
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      BaseRegExp current)
        Returns either the variable name attached to optionhandler's property or the current value as string.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        Returns:
        the generated string, null if no variable or empty regexp
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      BaseRegExp current,
                                      String prefix)
        Returns either the variable name attached to optionhandler's property or the current value as string.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        prefix - the prefix string to prepend the variable/text with, ignored if null
        Returns:
        the generated string, null if no variable or empty regexp
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      BaseRegExp current,
                                      String ifEmpty,
                                      String prefix)
        Returns either the variable name attached to optionhandler's property or the current value as string.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        ifEmpty - the string to output if the regexp is empty, null to ignore
        prefix - the prefix string to prepend the variable/text with, ignored if null
        Returns:
        the generated string, null if no variable or empty regexp
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      boolean current,
                                      String text)
        Returns either the variable name attached to optionhandler's property or the text if the current value is true. In both cases, the prefix (if not null) is prepended to the result string.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        text - the text to output if no variable is set
        Returns:
        the generated string
      • toString

        public static String toString​(OptionHandler handler,
                                      String property,
                                      boolean current,
                                      String text,
                                      String prefix)
        Returns either the variable name attached to optionhandler's property or the text if the current value is true. In both cases, the prefix (if not null) is prepended to the result string.
        Parameters:
        handler - the option handler to inspect
        property - the property of the option handler to inspect
        current - the current value
        text - the text to output if no variable is set
        prefix - the prefix string to prepend the variable/text with, ignored if null
        Returns:
        the generated string
      • add

        public static boolean add​(List<String> list,
                                  String value)
        Adds the value to the list if neither null nor empty string.
        Parameters:
        list - the list to add the value to
        value - the value to add
        Returns:
        true if added
      • flatten

        public static String flatten​(List<String> list)
        Returns the flattened list with a blank prepended and in brackets if at least one item in the list. Otherwise an empty string gets returned.
        Parameters:
        list - the list of flags/options to turn into a string
        Returns:
        the generated list
      • toStringOutputArray

        public static String toStringOutputArray​(ArrayProvider handler)
        Generates a quick info string for the outputArray property.
        Parameters:
        handler - the handler to generate it for
        Returns:
        the generated string