Java Code Examples for com.ibm.icu.lang.UCharacter#toLowerCase()

The following examples show how to use com.ibm.icu.lang.UCharacter#toLowerCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LowercaseTransliterator.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
@Override
public void addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) {
    synchronized (this) {
        if (sourceTargetUtility == null) {
            sourceTargetUtility = new SourceTargetUtility(new Transform<String,String>() {
                @Override
                public String transform(String source) {
                    return UCharacter.toLowerCase(locale, source);
                }
            });
        }
    }
    sourceTargetUtility.addSourceTargetSet(this, inputFilter, sourceSet, targetSet);
}
 
Example 2
Source File: StringFormatSpecifierImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param val
 *            string to be handled
 * @param option
 *            to upper case or to lower case
 * @return
 */
private String handleCase( String val, char option, ULocale locale )
{
	if ( option == '<' )
		return UCharacter.toLowerCase( locale, val );
	else if ( option == '>' )
		return UCharacter.toUpperCase( locale, val );
	else
		return val;

}
 
Example 3
Source File: StringFormatter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param val
 *            string to be handled
 * @param option
 *            to upper case or to lower case
 * @return
 */
private String handleCase( String val, char option )
{
	if ( option == '<' )
		return UCharacter.toLowerCase( locale, val );
	else if ( option == '>' )
		return UCharacter.toUpperCase( locale, val );
	else
		return val;

}
 
Example 4
Source File: Utility.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
/**
 * Parse a pattern string starting at offset pos.  Keywords are
 * matched case-insensitively.  Spaces may be skipped and may be
 * optional or required.  Integer values may be parsed, and if
 * they are, they will be returned in the given array.  If
 * successful, the offset of the next non-space character is
 * returned.  On failure, -1 is returned.
 * @param pattern must only contain lowercase characters, which
 * will match their uppercase equivalents as well.  A space
 * character matches one or more required spaces.  A '~' character
 * matches zero or more optional spaces.  A '#' character matches
 * an integer and stores it in parsedInts, which the caller must
 * ensure has enough capacity.
 * @param parsedInts array to receive parsed integers.  Caller
 * must ensure that parsedInts.length is >= the number of '#'
 * signs in 'pattern'.
 * @return the position after the last character parsed, or -1 if
 * the parse failed
 */
@SuppressWarnings("fallthrough")
public static int parsePattern(String rule, int pos, int limit,
        String pattern, int[] parsedInts) {
    // TODO Update this to handle surrogates
    int[] p = new int[1];
    int intCount = 0; // number of integers parsed
    for (int i=0; i<pattern.length(); ++i) {
        char cpat = pattern.charAt(i);
        char c;
        switch (cpat) {
        case ' ':
            if (pos >= limit) {
                return -1;
            }
            c = rule.charAt(pos++);
            if (!PatternProps.isWhiteSpace(c)) {
                return -1;
            }
            // FALL THROUGH to skipWhitespace
        case '~':
            pos = PatternProps.skipWhiteSpace(rule, pos);
            break;
        case '#':
            p[0] = pos;
            parsedInts[intCount++] = parseInteger(rule, p, limit);
            if (p[0] == pos) {
                // Syntax error; failed to parse integer
                return -1;
            }
            pos = p[0];
            break;
        default:
            if (pos >= limit) {
                return -1;
            }
            c = (char) UCharacter.toLowerCase(rule.charAt(pos++));
            if (c != cpat) {
                return -1;
            }
            break;
        }
    }
    return pos;
}
 
Example 5
Source File: Utility.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Parse a pattern string starting at offset pos.  Keywords are
 * matched case-insensitively.  Spaces may be skipped and may be
 * optional or required.  Integer values may be parsed, and if
 * they are, they will be returned in the given array.  If
 * successful, the offset of the next non-space character is
 * returned.  On failure, -1 is returned.
 * @param pattern must only contain lowercase characters, which
 * will match their uppercase equivalents as well.  A space
 * character matches one or more required spaces.  A '~' character
 * matches zero or more optional spaces.  A '#' character matches
 * an integer and stores it in parsedInts, which the caller must
 * ensure has enough capacity.
 * @param parsedInts array to receive parsed integers.  Caller
 * must ensure that parsedInts.length is >= the number of '#'
 * signs in 'pattern'.
 * @return the position after the last character parsed, or -1 if
 * the parse failed
 */
@SuppressWarnings("fallthrough")
public static int parsePattern(String rule, int pos, int limit,
        String pattern, int[] parsedInts) {
    // TODO Update this to handle surrogates
    int[] p = new int[1];
    int intCount = 0; // number of integers parsed
    for (int i=0; i<pattern.length(); ++i) {
        char cpat = pattern.charAt(i);
        char c;
        switch (cpat) {
        case ' ':
            if (pos >= limit) {
                return -1;
            }
            c = rule.charAt(pos++);
            if (!PatternProps.isWhiteSpace(c)) {
                return -1;
            }
            // FALL THROUGH to skipWhitespace
        case '~':
            pos = PatternProps.skipWhiteSpace(rule, pos);
            break;
        case '#':
            p[0] = pos;
            parsedInts[intCount++] = parseInteger(rule, p, limit);
            if (p[0] == pos) {
                // Syntax error; failed to parse integer
                return -1;
            }
            pos = p[0];
            break;
        default:
            if (pos >= limit) {
                return -1;
            }
            c = (char) UCharacter.toLowerCase(rule.charAt(pos++));
            if (c != cpat) {
                return -1;
            }
            break;
        }
    }
    return pos;
}
 
Example 6
Source File: Character.java    From juniversal with MIT License 2 votes vote down vote up
/**
 * Returns the lower case equivalent for the specified code point if it is
 * an upper case letter. Otherwise, the specified code point is returned
 * unchanged.
 * 
 * @param codePoint
 *            the code point to check.
 * @return if {@code codePoint} is an upper case character then its lower
 *         case counterpart, otherwise just {@code codePoint}.
 */
public static int toLowerCase(int codePoint) {
    return UCharacter.toLowerCase(codePoint);
}