List of usage examples for java.lang Character UPPERCASE_LETTER
byte UPPERCASE_LETTER
To view the source code for java.lang Character UPPERCASE_LETTER.
Click Source Link
From source file:com.legstar.csok.client.CicsSocket.java
/** * After initial connect, the host should reply with an ack plus a bunch of * attributes used to correlate this connection with host events. * /*from w w w . j a v a 2s .co m*/ * @throws RequestException if ack cannot be received */ private void recvConnectionAck() throws RequestException { String ackString = null; try { InputStream in = mClientSocket.getInputStream(); ackString = getCharsFromHost(in, mHostProtocolCharset, MAX_PROT_REPLY_LEN); if (ackString == null || ackString.length() == 0) { throw (new RequestException("No response from host.")); } /* If this is not a valid ACK, it could be an error report */ if (REPLY_ACK_MSG_EC.compareTo(ackString.substring(0, REPLY_ACK_MSG_EC.length())) != 0) { /* * Sanity check for characters being displayable. We expect the * host error reply to start with an error code in uppercase * characters. */ if (Character.getType(ackString.charAt(0)) == Character.UPPERCASE_LETTER) { throw (new RequestException(ackString)); } else { throw (new RequestException("Unrecognized response from host.")); } } } catch (IOException e) { throw (new RequestException(e)); } if (_log.isDebugEnabled()) { _log.debug("Connection:" + mConnectionID + " Connection Ack received." + ackString); } }
From source file:XmlChars.java
private static boolean isLetter2(char c) { // [84] Letter ::= BaseChar | Ideographic // [85] BaseChar ::= ... too much to repeat // [86] Ideographic ::= ... too much to repeat // [87] CombiningChar ::= ... too much to repeat ///*from w ww.j ava2 s. c o m*/ // Optimize the typical case. // if (c >= 'a' && c <= 'z') return true; if (c == '>') return false; if (c >= 'A' && c <= 'Z') return true; // // Since the tables are too ridiculous to use in code, // we're using the footnotes here to drive this test. // switch (Character.getType(c)) { // app. B footnote says these are 'name start' // chars' ... case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl // ... and these are name characters 'other // than name start characters' case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm case Character.DECIMAL_DIGIT_NUMBER: // Nd // OK, here we just have some exceptions to check... return !isCompatibilityChar(c) // per "5.14 of Unicode", rule out some combiners && !(c >= 0x20dd && c <= 0x20e0); default: // added a character ... return c == 0x0387; } }
From source file:org.grails.datastore.bson.json.JsonWriter.java
private void writeStringHelper(final String str) throws IOException { writer.write('"'); for (final char c : str.toCharArray()) { switch (c) { case '"': writer.write("\\\""); break; case '\\': writer.write("\\\\"); break; case '\b': writer.write("\\b"); break; case '\f': writer.write("\\f"); break; case '\n': writer.write("\\n"); break; case '\r': writer.write("\\r"); break; case '\t': writer.write("\\t"); break; default:/*ww w . java2s.co m*/ switch (Character.getType(c)) { case Character.UPPERCASE_LETTER: case Character.LOWERCASE_LETTER: case Character.TITLECASE_LETTER: case Character.OTHER_LETTER: case Character.DECIMAL_DIGIT_NUMBER: case Character.LETTER_NUMBER: case Character.OTHER_NUMBER: case Character.SPACE_SEPARATOR: case Character.CONNECTOR_PUNCTUATION: case Character.DASH_PUNCTUATION: case Character.START_PUNCTUATION: case Character.END_PUNCTUATION: case Character.INITIAL_QUOTE_PUNCTUATION: case Character.FINAL_QUOTE_PUNCTUATION: case Character.OTHER_PUNCTUATION: case Character.MATH_SYMBOL: case Character.CURRENCY_SYMBOL: case Character.MODIFIER_SYMBOL: case Character.OTHER_SYMBOL: writer.write(c); break; default: writer.write("\\u"); writer.write(Integer.toHexString((c & 0xf000) >> 12)); writer.write(Integer.toHexString((c & 0x0f00) >> 8)); writer.write(Integer.toHexString((c & 0x00f0) >> 4)); writer.write(Integer.toHexString(c & 0x000f)); break; } break; } } writer.write('"'); }
From source file:com.vuze.android.remote.adapter.TorrentListAdapter.java
private static boolean isAlphabetic(int c) { // Seems to return symbolic languages // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // return Character.isAlphabetic(c); // }//from w ww . j av a 2 s . com if (!Character.isLetter(c)) { return false; } int type = Character.getType(c); return type == Character.UPPERCASE_LETTER || type == Character.LOWERCASE_LETTER; // Simple, but doesn't include letters with hats on them ;) //return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z'); }
From source file:marytts.util.string.StringUtils.java
/** * Determine whether the given codepoint is either a letter or * a modifier according to the Unicode standard. More precisely, * this returns true if codepoint belongs to one of the following categories * as defined at http://unicode.org/Public/UNIDATA/UCD.html#General_Category_Values: * <ul>/*from w w w. j a v a2 s .c o m*/ * <li>Lu Letter, Uppercase</li> * <li>Ll Letter, Lowercase</li> * <li>Lt Letter, Titlecase</li> * <li>Lm Letter, Modifier</li> * <li>Lo Letter, Other</li> * <li>Mn Mark, Nonspacing</li> * <li>Mc Mark, Spacing Combining</li> * <li>Me Mark, Enclosing</li> * </ul> * Whether a given character is associated with this category can be looked up * at http://unicode.org/Public/UNIDATA/UnicodeData.txt * @param codePoint the unicode codepoint as determined e.g. by String.codePointAt(). * @return true if the above condition is met, false otherwise */ public static boolean isLetterOrModifier(int codePoint) { int type = Character.getType(codePoint); return type == Character.UPPERCASE_LETTER || type == Character.LOWERCASE_LETTER || type == Character.TITLECASE_LETTER || type == Character.MODIFIER_LETTER || type == Character.OTHER_LETTER || type == Character.NON_SPACING_MARK || type == Character.COMBINING_SPACING_MARK || type == Character.ENCLOSING_MARK; }
From source file:org.apache.orc.impl.mask.RedactMaskFactory.java
/** * Given a UTF code point, find the replacement codepoint * @param codepoint a UTF character/* w w w . j a va 2 s . c o m*/ * @return the replacement codepoint */ int getReplacement(int codepoint) { switch (Character.getType(codepoint)) { case Character.UPPERCASE_LETTER: return UPPPER_REPLACEMENT; case Character.LOWERCASE_LETTER: return LOWER_REPLACEMENT; case Character.TITLECASE_LETTER: case Character.MODIFIER_LETTER: case Character.OTHER_LETTER: return OTHER_LETTER_REPLACEMENT; case Character.NON_SPACING_MARK: case Character.ENCLOSING_MARK: case Character.COMBINING_SPACING_MARK: return MARK_REPLACEMENT; case Character.DECIMAL_DIGIT_NUMBER: return DIGIT_CP_REPLACEMENT; case Character.LETTER_NUMBER: case Character.OTHER_NUMBER: return OTHER_NUMBER_REPLACEMENT; case Character.SPACE_SEPARATOR: case Character.LINE_SEPARATOR: case Character.PARAGRAPH_SEPARATOR: return SEPARATOR_REPLACEMENT; case Character.MATH_SYMBOL: case Character.CURRENCY_SYMBOL: case Character.MODIFIER_SYMBOL: case Character.OTHER_SYMBOL: return SYMBOL_REPLACEMENT; case Character.DASH_PUNCTUATION: case Character.START_PUNCTUATION: case Character.END_PUNCTUATION: case Character.CONNECTOR_PUNCTUATION: case Character.OTHER_PUNCTUATION: return PUNCTUATION_REPLACEMENT; default: return OTHER_REPLACEMENT; } }
From source file:com.yucheng.cmis.pub.util.NewStringUtils.java
/** * <p>Splits a String by Character type as returned by * <code>java.lang.Character.getType(char)</code>. Groups of contiguous * characters of the same type are returned as complete tokens, with the * following exception: if <code>camelCase</code> is <code>true</code>, * the character of type <code>Character.UPPERCASE_LETTER</code>, if any, * immediately preceding a token of type <code>Character.LOWERCASE_LETTER</code> * will belong to the following token rather than to the preceding, if any, * <code>Character.UPPERCASE_LETTER</code> token. * @param str the String to split, may be <code>null</code> * @param camelCase whether to use so-called "camel-case" for letter types * @return an array of parsed Strings, <code>null</code> if null String input * @since 2.4//from w w w.j a v a 2 s. c o m */ private static String[] splitByCharacterType(String str, boolean camelCase) { if (str == null) { return null; } if (str.length() == 0) { return NewArrayUtils.EMPTY_STRING_ARRAY; } char[] c = str.toCharArray(); List list = new ArrayList(); int tokenStart = 0; int currentType = Character.getType(c[tokenStart]); for (int pos = tokenStart + 1; pos < c.length; pos++) { int type = Character.getType(c[pos]); if (type == currentType) { continue; } if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) { int newTokenStart = pos - 1; if (newTokenStart != tokenStart) { list.add(new String(c, tokenStart, newTokenStart - tokenStart)); tokenStart = newTokenStart; } } else { list.add(new String(c, tokenStart, pos - tokenStart)); tokenStart = pos; } currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); return (String[]) list.toArray(new String[list.size()]); }
From source file:com.test.stringtest.StringUtils.java
/** * <p>Splits a String by Character type as returned by * <code>java.lang.Character.getType(char)</code>. Groups of contiguous * characters of the same type are returned as complete tokens, with the * following exception: if <code>camelCase</code> is <code>true</code>, * the character of type <code>Character.UPPERCASE_LETTER</code>, if any, * immediately preceding a token of type <code>Character.LOWERCASE_LETTER</code> * will belong to the following token rather than to the preceding, if any, * <code>Character.UPPERCASE_LETTER</code> token. * @param str the String to split, may be <code>null</code> * @param camelCase whether to use so-called "camel-case" for letter types * @return an array of parsed Strings, <code>null</code> if null String input * @since 2.4/*from w w w. ja v a 2s .com*/ */ private static String[] splitByCharacterType(String str, boolean camelCase) { if (str == null) { return null; } if (str.length() == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } char[] c = str.toCharArray(); List list = new ArrayList(); int tokenStart = 0; int currentType = Character.getType(c[tokenStart]); for (int pos = tokenStart + 1; pos < c.length; pos++) { int type = Character.getType(c[pos]); if (type == currentType) { continue; } if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) { int newTokenStart = pos - 1; if (newTokenStart != tokenStart) { list.add(new String(c, tokenStart, newTokenStart - tokenStart)); tokenStart = newTokenStart; } } else { list.add(new String(c, tokenStart, pos - tokenStart)); tokenStart = pos; } currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); return (String[]) list.toArray(new String[list.size()]); }
From source file:ths.commons.util.StringUtils.java
/** * <p>Splits a String by Character type as returned by * {@code java.lang.Character.getType(char)}. Groups of contiguous * characters of the same type are returned as complete tokens, with the * following exception: if {@code camelCase} is {@code true}, * the character of type {@code Character.UPPERCASE_LETTER}, if any, * immediately preceding a token of type {@code Character.LOWERCASE_LETTER} * will belong to the following token rather than to the preceding, if any, * {@code Character.UPPERCASE_LETTER} token. * @param str the String to split, may be {@code null} * @param camelCase whether to use so-called "camel-case" for letter types * @return an array of parsed Strings, {@code null} if null String input * @since 2.4//w w w.jav a 2 s .c o m */ private static String[] splitByCharacterType(String str, boolean camelCase) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING_ARRAY; } char[] c = str.toCharArray(); List<String> list = new ArrayList<String>(); int tokenStart = 0; int currentType = Character.getType(c[tokenStart]); for (int pos = tokenStart + 1; pos < c.length; pos++) { int type = Character.getType(c[pos]); if (type == currentType) { continue; } if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) { int newTokenStart = pos - 1; if (newTokenStart != tokenStart) { list.add(new String(c, tokenStart, newTokenStart - tokenStart)); tokenStart = newTokenStart; } } else { list.add(new String(c, tokenStart, pos - tokenStart)); tokenStart = pos; } currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); return list.toArray(new String[list.size()]); }
From source file:com.sjdf.platform.xss.StringUtils.java
/** * <p/>//ww w . j a v a 2 s . com * Splits a String by Character type as returned by * {@code java.lang.Character.getType(char)}. Groups of contiguous * characters of the same type are returned as complete tokens, with the * following exception: if {@code camelCase} is {@code true}, the character * of type {@code Character.UPPERCASE_LETTER}, if any, immediately preceding * a token of type {@code Character.LOWERCASE_LETTER} will belong to the * following token rather than to the preceding, if any, * {@code Character.UPPERCASE_LETTER} token. * * @param str the String to split, may be {@code null} * @param camelCase whether to use so-called "camel-case" for letter types * @return an array of parsed Strings, {@code null} if null String input * @since 2.4 */ private static String[] splitByCharacterType(String str, boolean camelCase) { if (str == null) { return new String[0]; } if (str.length() == 0) { return EMPTY_STRING_ARRAY; } char[] c = str.toCharArray(); List<String> list = new ArrayList<String>(); int tokenStart = 0; int currentType = Character.getType(c[tokenStart]); for (int pos = tokenStart + 1; pos < c.length; pos++) { int type = Character.getType(c[pos]); if (type == currentType) { continue; } if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) { int newTokenStart = pos - 1; if (newTokenStart != tokenStart) { list.add(new String(c, tokenStart, newTokenStart - tokenStart)); tokenStart = newTokenStart; } } else { list.add(new String(c, tokenStart, pos - tokenStart)); tokenStart = pos; } currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); return list.toArray(new String[list.size()]); }