Package com.yahoo.text
Class Text
- java.lang.Object
-
- com.yahoo.text.Text
-
public final class Text extends java.lang.Object
Text utility functions.- Author:
- bratseth
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isDisplayable(int codePoint)
Returns whether the given code point is displayable.static boolean
isTextCharacter(int codepoint)
Returns whether the given codepoint is a valid text character, potentially suitable for purposes such as indexing and display, see http://www.w3.org/TR/2006/REC-xml11-20060816/#charsetsstatic java.lang.String
stripInvalidCharacters(java.lang.String string)
Returns a string where any invalid characters in the input string is replaced by spacesstatic java.lang.String
truncate(java.lang.String s, int length)
Returns a string which is never larger than the given number of characters.static java.util.OptionalInt
validateTextString(java.lang.String string)
Validates that the given string value only contains text characters and returns the first illegal code point if one is found.
-
-
-
Method Detail
-
isTextCharacter
public static boolean isTextCharacter(int codepoint)
Returns whether the given codepoint is a valid text character, potentially suitable for purposes such as indexing and display, see http://www.w3.org/TR/2006/REC-xml11-20060816/#charsets
-
validateTextString
public static java.util.OptionalInt validateTextString(java.lang.String string)
Validates that the given string value only contains text characters and returns the first illegal code point if one is found.
-
isDisplayable
public static boolean isDisplayable(int codePoint)
Returns whether the given code point is displayable.
-
stripInvalidCharacters
public static java.lang.String stripInvalidCharacters(java.lang.String string)
Returns a string where any invalid characters in the input string is replaced by spaces
-
truncate
public static java.lang.String truncate(java.lang.String s, int length)
Returns a string which is never larger than the given number of characters. If the string is longer than the given length it will be truncated. If length is 4 or less the string will be truncated to length. If length is longer than 4, it will be truncated at length-4 with " ..." added at the end.
-
-