diff options
author | 2014-09-18 09:40:07 +0000 | |
---|---|---|
committer | 2014-09-18 09:40:07 +0000 | |
commit | 22a4740b7d0ee1e755379bbfce86e0b549c87d7a (patch) | |
tree | 4b214a6ed9656a1a1c662ca02e20c913ed2faa5a /java/src/com/android/inputmethod/latin/utils | |
parent | 9b5afb5d1de42e1d3e98a125f8a1c2db73093369 (diff) | |
parent | eddfe51b38755e0068e3c322868c5e209f212f6f (diff) | |
download | latinime-22a4740b7d0ee1e755379bbfce86e0b549c87d7a.tar.gz latinime-22a4740b7d0ee1e755379bbfce86e0b549c87d7a.tar.xz latinime-22a4740b7d0ee1e755379bbfce86e0b549c87d7a.zip |
am eddfe51b: resolved conflicts for merge of 233a2f21 to master
* commit 'eddfe51b38755e0068e3c322868c5e209f212f6f':
Use Add-To-Dictionary indicator only
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils')
-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; + } } |