mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
An empty string could still be returned when a non empty string is required. Related to #3381
This commit is contained in:
parent
a49f1b264a
commit
8e76fb87dc
@ -146,6 +146,11 @@ public class PreferencesData {
|
||||
return (value == null) ? defaultValue : value;
|
||||
}
|
||||
|
||||
static public String getNonEmpty(String attribute, String defaultValue) {
|
||||
String value = get(attribute, defaultValue);
|
||||
return ("".equals(value)) ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static boolean has(String key) {
|
||||
return prefs.containsKey(key);
|
||||
}
|
||||
|
@ -50,27 +50,27 @@ public class Serial implements SerialPortEventListener {
|
||||
public Serial() throws SerialException {
|
||||
this(PreferencesData.get("serial.port"),
|
||||
PreferencesData.getInteger("serial.debug_rate", 9600),
|
||||
PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public Serial(int irate) throws SerialException {
|
||||
this(PreferencesData.get("serial.port"), irate,
|
||||
PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate) throws SerialException {
|
||||
this(iname, irate, PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
this(iname, irate, PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public Serial(String iname) throws SerialException {
|
||||
this(iname, PreferencesData.getInteger("serial.debug_rate", 9600),
|
||||
PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user