Package org.beryx.textio
Class TerminalProperties<T extends TextTerminal<T>>
- java.lang.Object
-
- org.beryx.textio.TerminalProperties<T>
-
- Type Parameters:
T- the type of the TextTerminal.
public class TerminalProperties<T extends TextTerminal<T>> extends java.lang.ObjectA map of properties associated with a TextTerminal.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTerminalProperties.BooleanChangeListener<TT extends TextTerminal<TT>>static interfaceTerminalProperties.ChangeListener<TT extends TextTerminal<TT>,V>static interfaceTerminalProperties.DoubleChangeListener<TT extends TextTerminal<TT>>static interfaceTerminalProperties.ExtendedChangeListener<TT extends TextTerminal<TT>>static interfaceTerminalProperties.IntChangeListener<TT extends TextTerminal<TT>>static interfaceTerminalProperties.LongChangeListener<TT extends TextTerminal<TT>>static interfaceTerminalProperties.StringChangeListener<TT extends TextTerminal<TT>>
-
Constructor Summary
Constructors Constructor Description TerminalProperties(T textTerminal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBooleanListener(java.lang.String key, boolean defaultValue, TerminalProperties.BooleanChangeListener<T> listener)Convenience method that adds a listener for the boolean property with the specified key.voidaddDoubleListener(java.lang.String key, double defaultValue, TerminalProperties.DoubleChangeListener<T> listener)Convenience method that adds a listener for the double property with the specified key.voidaddIntListener(java.lang.String key, int defaultValue, TerminalProperties.IntChangeListener<T> listener)Convenience method that adds a listener for the int property with the specified key.voidaddListener(TerminalProperties.ExtendedChangeListener<T> listener)Adds a listener for this TerminalProperties instance.voidaddLongListener(java.lang.String key, long defaultValue, TerminalProperties.LongChangeListener<T> listener)Convenience method that adds a listener for the long property with the specified key.voidaddStringListener(java.lang.String key, java.lang.String defaultValue, TerminalProperties.StringChangeListener<T> listener)Convenience method that adds a listener for the String property with the specified key.java.util.Set<java.lang.String>getAllKeys()booleangetBoolean(java.lang.String key, boolean defaultValue)Gets the boolean value of the property with the specified key.doublegetDouble(java.lang.String key, double defaultValue)Gets the double value of the property with the specified key.intgetInt(java.lang.String key, int defaultValue)Gets the int value of the property with the specified key.java.util.List<TerminalProperties.ExtendedChangeListener<T>>getListeners()longgetLong(java.lang.String key, long defaultValue)Gets the long value of the property with the specified key.java.util.Set<java.lang.String>getMatchingKeys(java.lang.String regex)java.util.Set<java.lang.String>getMatchingKeys(java.util.function.Predicate<java.lang.String> keyFilter)java.lang.StringgetString(java.lang.String key)java.lang.StringgetString(java.lang.String key, java.lang.String defaultValue)Gets the String value of the property with the specified key.java.lang.Objectput(java.lang.String key, java.lang.Object value)Sets the value associated with the specified key.voidputAll(java.util.Map<java.lang.String,? extends java.lang.Object> map)java.lang.Objectremove(java.lang.String key)Removes the property with the specified key.booleanremoveListener(TerminalProperties.ExtendedChangeListener<T> listener)Removes the listener passed as argument.voidsetInputBackgroundColor(java.awt.Color bgcolor)Convenience method that associates the hex representation of the specifiedbgcolorwith the key "input.bgcolor"voidsetInputBackgroundColor(java.lang.String bgcolor)Convenience method that associates the specifiedbgcolorwith the key "input.bgcolor"voidsetInputBold(boolean bold)Convenience method that associates the boolean valueboldwith the key "input.bold"voidsetInputColor(java.awt.Color color)Convenience method that associates the hex representation of the specifiedcolorwith the key "input.color"voidsetInputColor(java.lang.String color)Convenience method that associates the specifiedcolorwith the key "input.color"voidsetInputItalic(boolean italic)Convenience method that associates the boolean valueitalicwith the key "input.italic"voidsetInputUnderline(boolean underline)Convenience method that associates the boolean valueunderlinewith the key "input.underline"voidsetPaneBackgroundColor(java.awt.Color bgcolor)Convenience method that associates the hex representation of the specifiedbgcolorwith the key "pane.bgcolor"voidsetPaneBackgroundColor(java.lang.String bgcolor)Convenience method that associates the specifiedbgcolorwith the key "pane.bgcolor"voidsetPaneDimension(int width, int height)Convenience method that associates the specifiedwidthandheightwith the keys "pane.width" and "pane.height"voidsetPaneHeight(int height)Convenience method that associates the specifiedheightwith the key "pane.height"voidsetPaneWidth(int width)Convenience method that associates the specifiedwidthwith the key "pane.width"voidsetPromptBackgroundColor(java.awt.Color bgcolor)Convenience method that associates the hex representation of the specifiedbgcolorwith the key "prompt.bgcolor"voidsetPromptBackgroundColor(java.lang.String bgcolor)Convenience method that associates the specifiedbgcolorwith the key "prompt.bgcolor"voidsetPromptBold(boolean bold)Convenience method that associates the boolean valueboldwith the key "prompt.bold"voidsetPromptColor(java.awt.Color color)Convenience method that associates the hex representation of the specifiedcolorwith the key "prompt.color"voidsetPromptColor(java.lang.String color)Convenience method that associates the specifiedcolorwith the key "prompt.color"voidsetPromptItalic(boolean italic)Convenience method that associates the boolean valueitalicwith the key "prompt.italic"voidsetPromptUnderline(boolean underline)Convenience method that associates the boolean valueunderlinewith the key "prompt.underline"
-
-
-
Constructor Detail
-
TerminalProperties
public TerminalProperties(T textTerminal)
-
-
Method Detail
-
getListeners
public java.util.List<TerminalProperties.ExtendedChangeListener<T>> getListeners()
- Returns:
- the list of
TerminalProperties.ExtendedChangeListenerfor this instance of TerminalProperties.
-
remove
public java.lang.Object remove(java.lang.String key)
Removes the property with the specified key.- Parameters:
key- the key whose associated value should be removed.- Returns:
- the old value associated with the specified key.
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)Sets the value associated with the specified key.- Parameters:
key- the key with which the specified value should be associated.value- the value to be associated with the specified key.- Returns:
-
putAll
public void putAll(java.util.Map<java.lang.String,? extends java.lang.Object> map)
-
getAllKeys
public java.util.Set<java.lang.String> getAllKeys()
-
getMatchingKeys
public java.util.Set<java.lang.String> getMatchingKeys(java.lang.String regex)
-
getMatchingKeys
public java.util.Set<java.lang.String> getMatchingKeys(java.util.function.Predicate<java.lang.String> keyFilter)
-
getString
public java.lang.String getString(java.lang.String key)
- Returns:
- the value associated with the specified key.
-
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)Gets the String value of the property with the specified key.- Parameters:
key- the key whose associated value should be retrieved.defaultValue- the value to be returned if no value is associated with the specified key or the associated value is null or empty.- Returns:
- the string value of the property with the specified key.
-
getInt
public int getInt(java.lang.String key, int defaultValue)Gets the int value of the property with the specified key.- Parameters:
key- the key whose associated value should be retrieved.defaultValue- the value to be returned if no value is associated with the specified key or the string representation of the value cannot be converted to int.- Returns:
- the int value of the property with the specified key.
-
getLong
public long getLong(java.lang.String key, long defaultValue)Gets the long value of the property with the specified key.- Parameters:
key- the key whose associated value should be retrieved.defaultValue- the value to be returned if no value is associated with the specified key or the string representation of the value cannot be converted to long.- Returns:
- the long value of the property with the specified key.
-
getDouble
public double getDouble(java.lang.String key, double defaultValue)Gets the double value of the property with the specified key.- Parameters:
key- the key whose associated value should be retrieved.defaultValue- the value to be returned if no value is associated with the specified key or the string representation of the value cannot be converted to double.- Returns:
- the double value of the property with the specified key.
-
getBoolean
public boolean getBoolean(java.lang.String key, boolean defaultValue)Gets the boolean value of the property with the specified key.- Parameters:
key- the key whose associated value should be retrieved.defaultValue- the value to be returned if no value is associated with the specified key.- Returns:
- the boolean value of the property with the specified key.
-
addListener
public void addListener(TerminalProperties.ExtendedChangeListener<T> listener)
Adds a listener for this TerminalProperties instance.- Parameters:
listener- the listener to be added.
-
removeListener
public boolean removeListener(TerminalProperties.ExtendedChangeListener<T> listener)
Removes the listener passed as argument.- Parameters:
listener- the listener to be added.- Returns:
- true, if the listener has been found and removed.
-
addStringListener
public void addStringListener(java.lang.String key, java.lang.String defaultValue, TerminalProperties.StringChangeListener<T> listener)Convenience method that adds a listener for the String property with the specified key.- Parameters:
key- the key of the property for which the listener is added.defaultValue- the value to be used if the new value is null.listener- the listener to be added.
-
addIntListener
public void addIntListener(java.lang.String key, int defaultValue, TerminalProperties.IntChangeListener<T> listener)Convenience method that adds a listener for the int property with the specified key.- Parameters:
key- the key of the property for which the listener is added.defaultValue- the value to be used if the new value cannot be converted to an int.listener- the listener to be added.
-
addLongListener
public void addLongListener(java.lang.String key, long defaultValue, TerminalProperties.LongChangeListener<T> listener)Convenience method that adds a listener for the long property with the specified key.- Parameters:
key- the key of the property for which the listener is added.defaultValue- the value to be used if the new value cannot be converted to a long.listener- the listener to be added.
-
addDoubleListener
public void addDoubleListener(java.lang.String key, double defaultValue, TerminalProperties.DoubleChangeListener<T> listener)Convenience method that adds a listener for the double property with the specified key.- Parameters:
key- the key of the property for which the listener is added.defaultValue- the value to be used if the new value cannot be converted to a double.listener- the listener to be added.
-
addBooleanListener
public void addBooleanListener(java.lang.String key, boolean defaultValue, TerminalProperties.BooleanChangeListener<T> listener)Convenience method that adds a listener for the boolean property with the specified key.- Parameters:
key- the key of the property for which the listener is added.defaultValue- the value to be used if the new value is null.listener- the listener to be added.
-
setPromptColor
public void setPromptColor(java.lang.String color)
Convenience method that associates the specifiedcolorwith the key "prompt.color"
-
setPromptColor
public void setPromptColor(java.awt.Color color)
Convenience method that associates the hex representation of the specifiedcolorwith the key "prompt.color"
-
setPromptBackgroundColor
public void setPromptBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolorwith the key "prompt.bgcolor"
-
setPromptBackgroundColor
public void setPromptBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolorwith the key "prompt.bgcolor"
-
setPromptBold
public void setPromptBold(boolean bold)
Convenience method that associates the boolean valueboldwith the key "prompt.bold"
-
setPromptItalic
public void setPromptItalic(boolean italic)
Convenience method that associates the boolean valueitalicwith the key "prompt.italic"
-
setPromptUnderline
public void setPromptUnderline(boolean underline)
Convenience method that associates the boolean valueunderlinewith the key "prompt.underline"
-
setInputColor
public void setInputColor(java.lang.String color)
Convenience method that associates the specifiedcolorwith the key "input.color"
-
setInputColor
public void setInputColor(java.awt.Color color)
Convenience method that associates the hex representation of the specifiedcolorwith the key "input.color"
-
setInputBackgroundColor
public void setInputBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolorwith the key "input.bgcolor"
-
setInputBackgroundColor
public void setInputBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolorwith the key "input.bgcolor"
-
setInputBold
public void setInputBold(boolean bold)
Convenience method that associates the boolean valueboldwith the key "input.bold"
-
setInputItalic
public void setInputItalic(boolean italic)
Convenience method that associates the boolean valueitalicwith the key "input.italic"
-
setInputUnderline
public void setInputUnderline(boolean underline)
Convenience method that associates the boolean valueunderlinewith the key "input.underline"
-
setPaneBackgroundColor
public void setPaneBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolorwith the key "pane.bgcolor"
-
setPaneBackgroundColor
public void setPaneBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolorwith the key "pane.bgcolor"
-
setPaneWidth
public void setPaneWidth(int width)
Convenience method that associates the specifiedwidthwith the key "pane.width"
-
setPaneHeight
public void setPaneHeight(int height)
Convenience method that associates the specifiedheightwith the key "pane.height"
-
setPaneDimension
public void setPaneDimension(int width, int height)Convenience method that associates the specifiedwidthandheightwith the keys "pane.width" and "pane.height"
-
-