Package org.elasticsearch.common
Class Booleans
- java.lang.Object
-
- org.elasticsearch.common.Booleans
-
public final class Booleans extends java.lang.Object
-
-
Method Summary
Modifier and Type Method Description static booleanisBoolean(char[] text, int offset, int length)returns true iff the sequence of chars is one of "true","false".static booleanisBoolean(java.lang.String value)static booleanisBooleanLenient(char[] text, int offset, int length)Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.static booleanisFalse(java.lang.String value)static booleanisTrue(java.lang.String value)static booleanparseBoolean(char[] text, int offset, int length, boolean defaultValue)Parses a char[] representation of a boolean value toboolean.static booleanparseBoolean(java.lang.String value)Parses a string representation of a boolean value toboolean.static booleanparseBoolean(java.lang.String value, boolean defaultValue)static java.lang.BooleanparseBoolean(java.lang.String value, java.lang.Boolean defaultValue)static booleanparseBooleanLenient(char[] text, int offset, int length, boolean defaultValue)Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.static booleanparseBooleanLenient(java.lang.String value, boolean defaultValue)Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.static java.lang.BooleanparseBooleanLenient(java.lang.String value, java.lang.Boolean defaultValue)Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices.
-
-
-
Method Detail
-
parseBoolean
public static boolean parseBoolean(char[] text, int offset, int length, boolean defaultValue)Parses a char[] representation of a boolean value toboolean.- Returns:
trueiff the sequence of chars is "true",falseiff the sequence of chars is "false" or the provided default value iff either text isnullor length == 0.- Throws:
java.lang.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
public static boolean isBoolean(java.lang.String value)
-
parseBoolean
public static boolean parseBoolean(java.lang.String value)
Parses a string representation of a boolean value toboolean.- Returns:
trueiff the provided value is "true".falseiff the provided value is "false".- Throws:
java.lang.IllegalArgumentException- if the string cannot be parsed to boolean.
-
parseBoolean
public static boolean parseBoolean(java.lang.String value, boolean defaultValue)- Parameters:
value- text to parse.defaultValue- The default value to return if the provided value isnull.- Returns:
- see
parseBoolean(String)
-
parseBoolean
public static java.lang.Boolean parseBoolean(java.lang.String value, java.lang.Boolean defaultValue)
-
parseBooleanLenient
@Deprecated public static java.lang.Boolean parseBooleanLenient(java.lang.String value, java.lang.Boolean defaultValue)Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices. UseparseBoolean(String, Boolean)instead.Returnsfalseif text is in "false", "0", "off", "no"; else,true.
-
parseBooleanLenient
@Deprecated public static boolean parseBooleanLenient(java.lang.String value, boolean defaultValue)Deprecated.Only kept to provide automatic upgrades for pre 6.0 indices. UseparseBoolean(String, boolean)instead.Returnsfalseif text is in "false", "0", "off", "no"; else,true.
-
isFalse
public static boolean isFalse(java.lang.String value)
- Returns:
trueiff the value is "false", otherwisefalse.
-
isTrue
public static boolean isTrue(java.lang.String value)
- Returns:
trueiff 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)insteadReturnsfalseif text is in "false", "0", "off", "no"; else,true.
-
isBooleanLenient
@Deprecated public static boolean isBooleanLenient(char[] text, int offset, int length)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
-
-