Class MlStrings
- java.lang.Object
-
- org.elasticsearch.xpack.core.ml.utils.MlStrings
-
public final class MlStrings extends java.lang.ObjectAnother String utilities class. Class name is prefixed with Ml to avoid confusion with one of the myriad String utility classes out there.
-
-
Field Summary
Fields Modifier and Type Field Description static intID_LENGTH_LIMIT
-
Method Summary
Modifier and Type Method Description static java.lang.StringdoubleQuoteIfNotAlphaNumeric(java.lang.String input)Surrounds with double quotes the giveninputif it contains any non-word characters.static java.lang.StringgetParentField(java.lang.String fieldPath)Returns the path to the parent field iffieldPathis nested orfieldPathitself.static booleanhasValidLengthForId(java.lang.String id)Checks if the givenidhas a valid length.static booleanisValidId(java.lang.String id)
-
-
-
Field Detail
-
ID_LENGTH_LIMIT
public static final int ID_LENGTH_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
doubleQuoteIfNotAlphaNumeric
public static java.lang.String doubleQuoteIfNotAlphaNumeric(java.lang.String input)
Surrounds with double quotes the giveninputif it contains any non-word characters. Any double quotes contained ininputwill be escaped.- Parameters:
input- any non null string- Returns:
inputwhen it does not contain non-word characters, or a new string that containsinputsurrounded by double quotes otherwise
-
isValidId
public static boolean isValidId(java.lang.String id)
-
hasValidLengthForId
public static boolean hasValidLengthForId(java.lang.String id)
Checks if the givenidhas a valid length. We keep IDs in a length shorter or equal thanID_LENGTH_LIMITin order to avoid unfriendly errors when storing docs with more than 512 bytes.- Parameters:
id- the id- Returns:
trueif the id has a valid length
-
getParentField
public static java.lang.String getParentField(java.lang.String fieldPath)
Returns the path to the parent field iffieldPathis nested orfieldPathitself.- Parameters:
fieldPath- a field path- Returns:
- the path to the parent field if {code fieldPath} is nested or fieldPath itself
-
-