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.Object
A map of properties associated with a TextTerminal.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TerminalProperties.BooleanChangeListener<TT extends TextTerminal<TT>>
static interface
TerminalProperties.ChangeListener<TT extends TextTerminal<TT>,V>
static interface
TerminalProperties.DoubleChangeListener<TT extends TextTerminal<TT>>
static interface
TerminalProperties.ExtendedChangeListener<TT extends TextTerminal<TT>>
static interface
TerminalProperties.IntChangeListener<TT extends TextTerminal<TT>>
static interface
TerminalProperties.LongChangeListener<TT extends TextTerminal<TT>>
static interface
TerminalProperties.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 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.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.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.void
addListener(TerminalProperties.ExtendedChangeListener<T> listener)
Adds a listener for this TerminalProperties instance.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.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.java.util.Set<java.lang.String>
getAllKeys()
boolean
getBoolean(java.lang.String key, boolean defaultValue)
Gets the boolean value of the property with the specified key.double
getDouble(java.lang.String key, double defaultValue)
Gets the double value of the property with the specified key.int
getInt(java.lang.String key, int defaultValue)
Gets the int value of the property with the specified key.java.util.List<TerminalProperties.ExtendedChangeListener<T>>
getListeners()
long
getLong(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.String
getString(java.lang.String key)
java.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
Gets the String value of the property with the specified key.java.lang.Object
put(java.lang.String key, java.lang.Object value)
Sets the value associated with the specified key.void
putAll(java.util.Map<java.lang.String,? extends java.lang.Object> map)
java.lang.Object
remove(java.lang.String key)
Removes the property with the specified key.boolean
removeListener(TerminalProperties.ExtendedChangeListener<T> listener)
Removes the listener passed as argument.void
setInputBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolor
with the key "input.bgcolor"void
setInputBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolor
with the key "input.bgcolor"void
setInputBold(boolean bold)
Convenience method that associates the boolean valuebold
with the key "input.bold"void
setInputColor(java.awt.Color color)
Convenience method that associates the hex representation of the specifiedcolor
with the key "input.color"void
setInputColor(java.lang.String color)
Convenience method that associates the specifiedcolor
with the key "input.color"void
setInputItalic(boolean italic)
Convenience method that associates the boolean valueitalic
with the key "input.italic"void
setInputUnderline(boolean underline)
Convenience method that associates the boolean valueunderline
with the key "input.underline"void
setPaneBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolor
with the key "pane.bgcolor"void
setPaneBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolor
with the key "pane.bgcolor"void
setPaneDimension(int width, int height)
Convenience method that associates the specifiedwidth
andheight
with the keys "pane.width" and "pane.height"void
setPaneHeight(int height)
Convenience method that associates the specifiedheight
with the key "pane.height"void
setPaneWidth(int width)
Convenience method that associates the specifiedwidth
with the key "pane.width"void
setPromptBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolor
with the key "prompt.bgcolor"void
setPromptBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolor
with the key "prompt.bgcolor"void
setPromptBold(boolean bold)
Convenience method that associates the boolean valuebold
with the key "prompt.bold"void
setPromptColor(java.awt.Color color)
Convenience method that associates the hex representation of the specifiedcolor
with the key "prompt.color"void
setPromptColor(java.lang.String color)
Convenience method that associates the specifiedcolor
with the key "prompt.color"void
setPromptItalic(boolean italic)
Convenience method that associates the boolean valueitalic
with the key "prompt.italic"void
setPromptUnderline(boolean underline)
Convenience method that associates the boolean valueunderline
with 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.ExtendedChangeListener
for 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 specifiedcolor
with the key "prompt.color"
-
setPromptColor
public void setPromptColor(java.awt.Color color)
Convenience method that associates the hex representation of the specifiedcolor
with the key "prompt.color"
-
setPromptBackgroundColor
public void setPromptBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolor
with the key "prompt.bgcolor"
-
setPromptBackgroundColor
public void setPromptBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolor
with the key "prompt.bgcolor"
-
setPromptBold
public void setPromptBold(boolean bold)
Convenience method that associates the boolean valuebold
with the key "prompt.bold"
-
setPromptItalic
public void setPromptItalic(boolean italic)
Convenience method that associates the boolean valueitalic
with the key "prompt.italic"
-
setPromptUnderline
public void setPromptUnderline(boolean underline)
Convenience method that associates the boolean valueunderline
with the key "prompt.underline"
-
setInputColor
public void setInputColor(java.lang.String color)
Convenience method that associates the specifiedcolor
with the key "input.color"
-
setInputColor
public void setInputColor(java.awt.Color color)
Convenience method that associates the hex representation of the specifiedcolor
with the key "input.color"
-
setInputBackgroundColor
public void setInputBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolor
with the key "input.bgcolor"
-
setInputBackgroundColor
public void setInputBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolor
with the key "input.bgcolor"
-
setInputBold
public void setInputBold(boolean bold)
Convenience method that associates the boolean valuebold
with the key "input.bold"
-
setInputItalic
public void setInputItalic(boolean italic)
Convenience method that associates the boolean valueitalic
with the key "input.italic"
-
setInputUnderline
public void setInputUnderline(boolean underline)
Convenience method that associates the boolean valueunderline
with the key "input.underline"
-
setPaneBackgroundColor
public void setPaneBackgroundColor(java.lang.String bgcolor)
Convenience method that associates the specifiedbgcolor
with the key "pane.bgcolor"
-
setPaneBackgroundColor
public void setPaneBackgroundColor(java.awt.Color bgcolor)
Convenience method that associates the hex representation of the specifiedbgcolor
with the key "pane.bgcolor"
-
setPaneWidth
public void setPaneWidth(int width)
Convenience method that associates the specifiedwidth
with the key "pane.width"
-
setPaneHeight
public void setPaneHeight(int height)
Convenience method that associates the specifiedheight
with the key "pane.height"
-
setPaneDimension
public void setPaneDimension(int width, int height)
Convenience method that associates the specifiedwidth
andheight
with the keys "pane.width" and "pane.height"
-
-