Package org.elasticsearch.core
Class Booleans
java.lang.Object
org.elasticsearch.core.Booleans
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isBoolean
(char[] text, int offset, int length) returns true iff the sequence of chars is one of "true","false".static boolean
static boolean
isBooleanLenient
(char[] text, int offset, int length) Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.static boolean
static boolean
static boolean
parseBoolean
(char[] text, int offset, int length, boolean defaultValue) Parses a char[] representation of a boolean value toboolean
.static boolean
parseBoolean
(String value) Parses a string representation of a boolean value toboolean
.static boolean
parseBoolean
(String value, boolean defaultValue) static Boolean
parseBoolean
(String value, Boolean defaultValue) static boolean
parseBooleanLenient
(char[] text, int offset, int length, boolean defaultValue) Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.static boolean
parseBooleanLenient
(String value, boolean defaultValue) Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.static Boolean
parseBooleanLenient
(String value, Boolean defaultValue) Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.
-
Method Details
-
parseBoolean
public static boolean parseBoolean(char[] text, int offset, int length, boolean defaultValue) Parses a char[] representation of a boolean value toboolean
.- Returns:
true
iff the sequence of chars is "true",false
iff the sequence of chars is "false" or the provided default value iff either text isnull
or length == 0.- Throws:
IllegalArgumentException
- if the string cannot be parsed to boolean.
-
isBoolean
public static boolean isBoolean(char[] text, int offset, int length) returns true iff the sequence of chars is one of "true","false".- Parameters:
text
- sequence to checkoffset
- offset to startlength
- length to check
-
isBoolean
-
parseBoolean
Parses a string representation of a boolean value toboolean
.- Returns:
true
iff the provided value is "true".false
iff the provided value is "false".- Throws:
IllegalArgumentException
- if the string cannot be parsed to boolean.
-
parseBoolean
- Parameters:
value
- text to parse.defaultValue
- The default value to return if the provided value isnull
.- Returns:
- see
parseBoolean(String)
-
parseBoolean
-
parseBooleanLenient
Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices. UseparseBoolean(String, Boolean)
instead.Returnsfalse
if text is in "false", "0", "off", "no"; else,true
. -
parseBooleanLenient
Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices. UseparseBoolean(String, boolean)
instead.Returnsfalse
if text is in "false", "0", "off", "no"; else,true
. -
isFalse
- Returns:
true
iff the value is "false", otherwisefalse
.
-
isTrue
- Returns:
true
iff the value is "true", otherwisefalse
.
-
parseBooleanLenient
@Deprecated public static boolean parseBooleanLenient(char[] text, int offset, int length, boolean defaultValue) Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices. UseparseBoolean(char[], int, int, boolean)
insteadReturnsfalse
if text is in "false", "0", "off", "no"; else,true
. -
isBooleanLenient
Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices. UseisBoolean(char[], int, int)
instead.returns true if the a sequence of chars is one of "true","false","on","off","yes","no","0","1"- Parameters:
text
- sequence to checkoffset
- offset to startlength
- length to check
-