Package adams.core
Class QuickInfoHelper
- java.lang.Object
-
- adams.core.QuickInfoHelper
-
public class QuickInfoHelper extends Object
Helper class for assembling quick info strings returned by classes implementingQuickInfoSupporter
.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
EMPTY_ARRAY_STRING
the string to use for empty arrays.static int
MAX_ARRAY_STRING_LENGTH
the maximum length of generated array strings.
-
Constructor Summary
Constructors Constructor Description QuickInfoHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
add(List<String> list, String value)
Adds the value to the list if neither null nor empty string.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.static String
getVariable(OptionHandler handler, String property)
Returns the variable attached to optionhandler's property.static boolean
hasVariable(OptionHandler handler, String property)
Checks whether a variable is attached to the optionhandler's property.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.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.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.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.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.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.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.protected static String
toString(Object current)
Generates a string representation from the object (non-array).static String
toStringOutputArray(ArrayProvider handler)
Generates a quick info string for the outputArray property.
-
-
-
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
-
-
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 inspectproperty
- 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 inspectproperty
- 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 inspectproperty
- the property of the option handler to inspectcurrent
- 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 ofQuickInfoSupporter
the simple class name and the quick info in parentheses (if applicable) is output.Range
andIndex
automatically have the string output. ForOptionHandler
classes, only the simple class name is output. ForClass
objects, the simple class name is output. ForEnumWithCustomDisplay
enums, the display string is output.- Parameters:
handler
- the option handler to inspectproperty
- the property of the option handler to inspectcurrent
- the current valueprefix
- 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 inspectproperty
- the property of the option handler to inspectcurrent
- 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 inspectproperty
- the property of the option handler to inspectcurrent
- the current valueprefix
- 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 inspectproperty
- the property of the option handler to inspectcurrent
- the current valueifEmpty
- the string to output if the regexp is empty, null to ignoreprefix
- 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 inspectproperty
- the property of the option handler to inspectcurrent
- the current valuetext
- 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 inspectproperty
- the property of the option handler to inspectcurrent
- the current valuetext
- the text to output if no variable is setprefix
- 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 tovalue
- 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
-
-