Class BaseObject

    • Constructor Detail

      • BaseObject

        public BaseObject​(String s)
        Initializes the object with the string to parse.
        Parameters:
        s - the string to parse
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the internal object.

        Default implementation does nothing.
      • compareTo

        public int compareTo​(Object o)
        Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Specified by:
        compareTo in interface Comparable
        Parameters:
        o - the object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        ClassCastException - if the specified object's type prevents it from being compared to this object.
      • equals

        public boolean equals​(Object o)
        Compares itself against the other base object.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare against
        Returns:
        true if the internal string is the same
        See Also:
        compareTo(Object)
      • hashCode

        public int hashCode()
        Hashcode so can be used as hashtable key. Returns the hashcode of the internal string.
        Overrides:
        hashCode in class Object
        Returns:
        the hashcode
      • getInternal

        public Comparable getInternal()
        Returns the internal object.
        Returns:
        the internal object
      • isValid

        public abstract boolean isValid​(String value)
        Checks whether the string value is a valid presentation for this class.
        Parameters:
        value - the string value to check
        Returns:
        true if valid
      • isValidUnicode

        public boolean isValidUnicode​(String value)
        Checks whether the string value (with escaped unicode sequences) is a valid presentation for this class.
        Parameters:
        value - the string value to check
        Returns:
        true if valid
      • setValue

        public abstract void setValue​(String value)
        Sets the string value.
        Parameters:
        value - the string value
      • getValue

        public abstract String getValue()
        Returns the current string value.
        Returns:
        the string value
      • setUnicode

        public void setUnicode​(String value)
        Sets the string value with escaped unicode sequences.
        Parameters:
        value - the string value
      • getTipText

        public abstract String getTipText()
        Returns a tool tip for the GUI editor (ignored if null is returned).
        Returns:
        the tool tip
      • toString

        public String toString()
        Returns the underlying object as string.
        Overrides:
        toString in class Object
        Returns:
        the underlying object
        See Also:
        getValue()
      • hasFavoritesSupport

        public boolean hasFavoritesSupport()
        Whether this object should have favorites support.
        Default is false.
        Returns:
        true if to support favorites
      • newInstance

        public static BaseObject newInstance​(Class cls,
                                             String s)
        Creates a new instance of the specified BaseObject-derived class and sets the specified value.
        Parameters:
        cls - the class to instantiate
        s - the value to set
        Returns:
        the instantiated object, null if class cannot be instantiated or value is invalid
      • toStringArray

        public static String[] toStringArray​(BaseObject[] array)
        Turns the BaseObject array into a string array.
        Parameters:
        array - the array to convert
        Returns:
        the generated string array
      • toStringList

        public static List<String> toStringList​(BaseObject[] array)
        Turns the BaseObject array into a string list.
        Parameters:
        array - the array to convert
        Returns:
        the generated string list
      • toObjectArray

        public static BaseObject[] toObjectArray​(String[] array,
                                                 Class cls)
        Turns the String array into a BaseObject array.
        Parameters:
        array - the array to convert
        cls - the BaseObject derived class to use
        Returns:
        the generated object array
      • toObjectArray

        public static BaseObject[] toObjectArray​(List<String> array,
                                                 Class cls)
        Turns the String array into a BaseObject array.
        Parameters:
        array - the array to convert
        cls - the BaseObject derived class to use
        Returns:
        the generated object array
      • getTemplates

        public static <T extends BaseObjectMap<String,​T> getTemplates​(Class<T> cls)
        Returns the predefined templates.
        Properties file in same location as class, e.g.:
        adams.core.base.BaseObject -> adams/core/base/BaseObject.props
        Format of props file:
         ID.display=text to display in GUI
         ID.value=value to set
         
        Returns:
        the templates