Request for more values identified as boolean for the boolean field type - `no`, closes #984.

This commit is contained in:
kimchy 2011-05-31 20:18:46 +03:00
parent 8267a76747
commit 1f17e9d49d
1 changed files with 5 additions and 2 deletions

View File

@ -31,6 +31,9 @@ public class Booleans {
if (length == 1) { if (length == 1) {
return text[offset] != '0'; return text[offset] != '0';
} }
if (length == 2) {
return !(text[offset] == 'n' && text[offset + 1] == 'o');
}
if (length == 3) { if (length == 3) {
return !(text[offset] == 'o' && text[offset + 1] == 'f' && text[offset + 2] == 'f'); return !(text[offset] == 'o' && text[offset + 1] == 'f' && text[offset + 2] == 'f');
} }
@ -44,13 +47,13 @@ public class Booleans {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
return !(value.equals("false") || value.equals("0") || value.equals("off")); return !(value.equals("false") || value.equals("0") || value.equals("off") || value.equals("no"));
} }
public static Boolean parseBoolean(String value, Boolean defaultValue) { public static Boolean parseBoolean(String value, Boolean defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
return !(value.equals("false") || value.equals("0") || value.equals("off")); return !(value.equals("false") || value.equals("0") || value.equals("off") || value.equals("no"));
} }
} }