diff options
author | 2014-09-18 18:26:06 +0900 | |
---|---|---|
committer | 2014-09-18 18:27:45 +0900 | |
commit | eddfe51b38755e0068e3c322868c5e209f212f6f (patch) | |
tree | 280fda5e51e269da433b9e3acccfa33025833481 /java/src/com/android/inputmethod/latin/utils/StringUtils.java | |
parent | cdabc71c6da00ea1c2254e13021973c762c79be4 (diff) | |
parent | 233a2f21c38a27049fa3b03af699593f629d1681 (diff) | |
download | latinime-eddfe51b38755e0068e3c322868c5e209f212f6f.tar.gz latinime-eddfe51b38755e0068e3c322868c5e209f212f6f.tar.xz latinime-eddfe51b38755e0068e3c322868c5e209f212f6f.zip |
resolved conflicts for merge of 233a2f21 to master
Change-Id: If391cc622367dfb4448c6a5c32b82111d352d86e
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/StringUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/utils/StringUtils.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/StringUtils.java b/java/src/com/android/inputmethod/latin/utils/StringUtils.java index 55557de9d..bbcef990d 100644 --- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java @@ -37,6 +37,14 @@ public final class StringUtils { private static final String EMPTY_STRING = ""; + private static final char CHAR_LINE_FEED = 0X000A; + private static final char CHAR_VERTICAL_TAB = 0X000B; + private static final char CHAR_FORM_FEED = 0X000C; + private static final char CHAR_CARRIAGE_RETURN = 0X000D; + private static final char CHAR_NEXT_LINE = 0X0085; + private static final char CHAR_LINE_SEPARATOR = 0X2028; + private static final char CHAR_PARAGRAPH_SEPARATOR = 0X2029; + private StringUtils() { // This utility class is not publicly instantiable. } @@ -594,4 +602,30 @@ public final class StringUtils { return sb + "]"; } } + + /** + * Returns whether the last composed word contains line-breaking character (e.g. CR or LF). + * @param text the text to be examined. + * @return {@code true} if the last composed word contains line-breaking separator. + */ + @UsedForTesting + public static boolean hasLineBreakCharacter(final String text) { + if (TextUtils.isEmpty(text)) { + return false; + } + for (int i = text.length() - 1; i >= 0; --i) { + final char c = text.charAt(i); + switch (c) { + case CHAR_LINE_FEED: + case CHAR_VERTICAL_TAB: + case CHAR_FORM_FEED: + case CHAR_CARRIAGE_RETURN: + case CHAR_NEXT_LINE: + case CHAR_LINE_SEPARATOR: + case CHAR_PARAGRAPH_SEPARATOR: + return true; + } + } + return false; + } } |