Package de.sciss.gui

Class StringItem


  • public class StringItem
    extends java.lang.Object
    A simple structure encompassing a string and an associated value. While the string is usually used as an internal, locale-independant lookup key, the object is usually something that gets presented to the user on the GUI.
    See Also:
    PrefComboBox.addItem( Object ), AudioFileDescr.getFormatItems()
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator keyComparator  
      static java.util.Comparator valueComparator  
    • Constructor Summary

      Constructors 
      Constructor Description
      StringItem​(java.lang.String key, java.lang.Object value)
      Constructs a new immutable StringItem.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Compares this object to another object
      java.lang.String getKey()
      Queries the key.
      java.lang.Object getValue()
      Queries the value object.
      int hashCode()  
      java.lang.String toString()
      Returns a string representation of the value.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • keyComparator

        public static final java.util.Comparator keyComparator
      • valueComparator

        public static final java.util.Comparator valueComparator
    • Constructor Detail

      • StringItem

        public StringItem​(java.lang.String key,
                          java.lang.Object value)
        Constructs a new immutable StringItem.
        Parameters:
        key - lookup key
        value - associated object, usually human readable
    • Method Detail

      • getKey

        public java.lang.String getKey()
        Queries the key.
        Returns:
        the key string which was used to construct the item
      • getValue

        public java.lang.Object getValue()
        Queries the value object.
        Returns:
        the value object which was used to construct the item
      • equals

        public boolean equals​(java.lang.Object o)
        Compares this object to another object
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object which shall be compared to the StringItem
        Returns:
        true, if the provided object is a StringItem whose key and value match this item's key and value (using their respective equals methods)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a string representation of the value. This is essential, since it allows us to add StringItems directly to ComboBoxes and the like whise call this method to get a GUI representation text.
        Overrides:
        toString in class java.lang.Object
        Returns:
        basically value.toString()