Example usage for java.lang Character isLetter

List of usage examples for java.lang Character isLetter

Introduction

In this page you can find the example usage for java.lang Character isLetter.

Prototype

public static boolean isLetter(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is a letter.

Usage

From source file:org.languagetool.rules.WordRepeatRule.java

private boolean isWord(String token) {
    boolean isWord = true;
    if (StringUtils.isNumericSpace(token)) {
        isWord = false;/*from w w w.  ja va  2  s  .  c o m*/
    } else if (token.length() == 1) {
        char c = token.charAt(0);
        if (!Character.isLetter(c)) {
            isWord = false;
        }
    }
    return isWord;
}

From source file:com.manydesigns.elements.util.Util.java

static boolean isAllLowerCase(String s) {
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (Character.isLetter(c) && Character.isUpperCase(c)) {
            return false;
        }//from   w  w  w .j a va 2s.c  om
    }
    return true;
}

From source file:net.metanotion.json.JsonPath.java

private static Lexeme lexToken(final String cs, final int[] position) {
    final int c = skipWhitespace(cs, position);
    switch (c) {/*from w ww  . j av a 2s  .  co  m*/
    case -1:
        return EOF;
    case '[':
        return L_BRACE;
    case ']':
        return R_BRACE;
    case '{':
        return L_CURLY;
    case '}':
        return R_CURLY;
    case '*':
        return STAR;
    case '.':
        return DOT;
    case '\'':
        return lexString(cs, position);
    default:
        if (Character.isDigit(c) || (c == (int) '-')) {
            // Lex integer
            final StringBuilder sb = new StringBuilder(new String(Character.toChars(c)));
            int digits = Character.isDigit(c) ? 1 : 0;
            while (true) {
                final int i = read(cs, position);
                if (Character.isDigit(i)) {
                    digits++;
                    sb.append(Character.toChars(i));
                } else {
                    position[0]--;
                    if (digits == 0) {
                        throw new IllegalArgumentException("Expected at least one digit [0-9]");
                    }
                    return new Lexeme(Token.INT, Long.valueOf(sb.toString()));
                }
            }
        } else {
            // Lex identifier
            position[0]--;
            final StringBuilder sb = new StringBuilder();
            while (true) {
                final int i = read(cs, position);
                if (i == -1) {
                    return new Lexeme(Token.ID, sb.toString());
                }
                if (Character.isLetter(i) || (i == (int) '_') || Character.isDigit(i)) {
                    sb.append(Character.toChars(i));
                } else {
                    position[0]--;
                    return new Lexeme(Token.ID, sb.toString());
                }
            }
        }
    }
}

From source file:eu.crisis_economics.configuration.TypeDeclarationExpression.java

public static List<String> isExpressionOfType(String rawExpression, FromFileConfigurationContext context) {
    String expression = rawExpression.trim();
    if (expression.length() == 0)
        return null;
    boolean beginsWithUppercase = Character.isUpperCase(expression.charAt(0));
    if (!beginsWithUppercase)
        return null;
    int endOfTypename = -1;
    for (int i = 0; i < expression.length(); ++i) {
        Character charNow = expression.charAt(i);
        if (Character.isLetter(charNow) || charNow == '_')
            continue;
        endOfTypename = i;//from  ww  w. j a  v a2s .  c  o m
        break;
    }
    if (endOfTypename == -1)
        return Arrays.asList(expression); // no indexing
    if (expression.charAt(endOfTypename) == '[') {
        if (expression.charAt(expression.length() - 1) != ']')
            return null;
        String typeDeclExpression = expression.substring(0, endOfTypename);
        String indexExpression = expression.substring(endOfTypename + 1, expression.length() - 1);
        if (IntegerPrimitiveExpression.isExpressionOfType(indexExpression, context) == null)
            return null;
        // with indexing
        return Arrays.asList(typeDeclExpression, indexExpression);
    } else
        return null;
}

From source file:com.sun.faban.harness.webclient.Uploader.java

private String getNextRunId(String runId) {
    RunId current = new RunId(runId);
    String seq = current.getRunSeq(); // Say "1A1"
    int i = 0;/* w  w w  .  j a v  a  2  s.  co  m*/
    for (; i < seq.length(); i++) {
        if (Character.isLetter(seq.charAt(i)))
            break;
    } // i now points to 'A'
    String origSeq = seq.substring(0, i + 1); // origSeq = "1A"
    String cDup = seq.substring(i + 1); // cDup = "1"
    String nDup = null;
    if (cDup.length() == 0) {
        nDup = "0";
    } else {
        int x = Integer.parseInt(cDup, 16); // x = (int) 1
        nDup = Integer.toHexString(++x).toUpperCase(); // nDup - "2"
    }
    RunId next = new RunId(current.getHostName(), current.getBenchName(), origSeq + nDup);
    return next.toString();
}

From source file:com.hpcloud.util.Duration.java

@JsonCreator
public static Duration of(String duration) {
    Preconditions.checkArgument(PATTERN.matcher(duration).matches(), "Invalid duration: %s", duration);
    int i = 0;// w  w  w.j ava 2  s  .c  om
    for (; i < duration.length(); i++)
        if (Character.isLetter(duration.charAt(i)))
            break;
    String unit = duration.subSequence(0, i).toString().trim();
    String dur = duration.subSequence(i, duration.length()).toString();
    return new Duration(Long.parseLong(unit), SUFFIXES.get(dur));
}

From source file:jdroidremote.ServerFrame.java

public static void typeCharacter(String letter) {
    System.out.println(letter);//from  w w  w . j av  a2  s.c o  m
    Robot robot = null;
    try {
        robot = new Robot();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    if (Character.isLetter(letter.charAt(0))) {
        try {
            boolean upperCase = Character.isUpperCase(letter.charAt(0));
            String variableName = "VK_" + letter.toUpperCase();

            KeyEvent ke = new KeyEvent(new JTextField(), 0, 0, 0, 0, ' ');
            Class clazz = ke.getClass();
            Field field = clazz.getField(variableName);
            int keyCode = field.getInt(ke);

            //System.out.println(keyCode + " = keyCode");
            robot.delay(80);

            if (upperCase) {
                robot.keyPress(KeyEvent.VK_SHIFT);
            }

            robot.keyPress(keyCode);
            robot.keyRelease(keyCode);

            if (upperCase) {
                robot.keyRelease(KeyEvent.VK_SHIFT);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    } else if (letter.equals(".")) {
        robot.keyPress(KeyEvent.VK_PERIOD); //keyCode 46
        robot.keyRelease(KeyEvent.VK_PERIOD);
    } else if (letter.equals("!")) {
        robot.keyPress(KeyEvent.VK_SHIFT); //keyCode 16
        robot.keyPress(KeyEvent.VK_1); //keycode 49
        robot.keyRelease(KeyEvent.VK_1);
        robot.keyRelease(KeyEvent.VK_SHIFT);
    } else if (letter.equals(" ")) {
        robot.keyPress(KeyEvent.VK_SPACE);
        robot.keyRelease(KeyEvent.VK_SPACE);
    } else if (letter.equals("?")) {
        robot.keyPress(KeyEvent.VK_SHIFT); //keyCode 16
        robot.keyPress(KeyEvent.VK_SLASH); //keyCode 47
        robot.keyRelease(KeyEvent.VK_SLASH);
        robot.keyRelease(KeyEvent.VK_SHIFT);
    } else if (letter.equals(",")) {
        robot.keyPress(KeyEvent.VK_COMMA);
        robot.keyRelease(KeyEvent.VK_COMMA);
    } else if (letter.equals("@enter")) {
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    } else if (letter.equals("@backspace")) {
        robot.keyPress(KeyEvent.VK_BACK_SPACE);
        robot.keyRelease(KeyEvent.VK_BACK_SPACE);
    }
}

From source file:com.towerlabs.yildizyemek.JSonProcess.java

public String[] toUpperCaseWords(String[] texts) {

    boolean isSpecialChar;
    char[] charsStr;

    for (int i = 0; i < texts.length; i++) {

        isSpecialChar = false;//from ww  w. j  ava 2 s  .c om
        charsStr = texts[i].toLowerCase(Locale.getDefault()).toCharArray();

        for (int j = 0; j < charsStr.length; j++) {

            if (Character.isLetter(charsStr[j])) {
                if (!isSpecialChar) {
                    charsStr[j] = Character.toUpperCase(charsStr[j]);
                }
                isSpecialChar = true;
            } else {
                isSpecialChar = false;
            }
        }

        texts[i] = new String(charsStr);

    }

    return texts;
}

From source file:com.ning.maven.plugins.dependencyversionscheck.version.Version.java

public Version(final String rawVersion, final String selectedVersion) {
    if (StringUtils.isBlank(rawVersion) || StringUtils.isBlank(selectedVersion)) {
        throw new NullPointerException("Version cannot be null");
    }/*from w  w w.j  a  v  a2 s  .  co m*/

    this.selectedVersion = selectedVersion;
    this.rawVersion = rawVersion;

    rawElements = StringUtils.splitPreserveAllTokens(selectedVersion, "-._");
    versionElements = new VersionElement[rawElements.length];

    // Position of the next splitter to look at.
    int charPos = 0;

    // Position to store the result in.
    int resultPos = 0;

    for (int i = 0; i < rawElements.length; i++) {
        final String rawElement = rawElements[i];

        long divider = 0L;
        final char dividerChar;

        charPos += rawElement.length();
        if (charPos < selectedVersion.length()) {
            dividerChar = selectedVersion.charAt(charPos);
            charPos++;

            if (dividerChar == '.') {
                divider |= DOT_DIVIDER;
            } else if (dividerChar == '-') {
                divider |= MINUS_DIVIDER;
            } else if (dividerChar == '_') {
                divider |= UNDERSCORE_DIVIDER;
            } else {
                divider |= OTHER_DIVIDER;
            }

        } else {
            dividerChar = 0;
            divider |= END_OF_VERSION;
        }

        final String element = StringUtils.trimToEmpty(rawElement);

        if (!StringUtils.isBlank(element)) {
            long flags = ALL_NUMBERS | ALL_LETTERS | ALL_OTHER;
            final char firstChar = element.charAt(0);
            final char lastChar = element.charAt(element.length() - 1);

            if (Character.isDigit(firstChar)) {
                flags |= STARTS_WITH_NUMBERS;
            } else if (Character.isLetter(firstChar)) {
                flags |= STARTS_WITH_LETTERS;
            } else {
                flags |= STARTS_WITH_OTHER;
            }

            if (Character.isDigit(lastChar)) {
                flags |= ENDS_WITH_NUMBERS;
            } else if (Character.isLetter(lastChar)) {
                flags |= ENDS_WITH_LETTERS;
            } else {
                flags |= ENDS_WITH_OTHER;
            }

            for (int j = 0; j < element.length(); j++) {

                if (Character.isDigit(element.charAt(j))) {
                    flags &= ~(ALL_LETTERS | ALL_OTHER);
                    flags |= NUMBERS;
                } else if (Character.isLetter(element.charAt(j))) {
                    flags &= ~(ALL_NUMBERS | ALL_OTHER);
                    flags |= LETTERS;
                } else {
                    flags &= ~(ALL_LETTERS | ALL_NUMBERS);
                    flags |= OTHER;
                }
            }

            versionElements[resultPos++] = new VersionElement(element, flags, divider, dividerChar);
        }
    }

    this.elementCount = resultPos;
}

From source file:com.ing.connector.util.WStringUtil.java

/**
 *  checkForSpecialPrefixes --> processes the known prefix:
 *                        "McX" so that the letter "X"
 *                        proceeding the prefix is
 *                        capitalized/*from   w  w w.ja va 2  s  .c o  m*/
 */
private String checkForSpecialPrefixes(String aString) {
    String lString = aString;
    int lLength = lString.length();

    if (lLength >= 3) {
        String[] lArray = new String[(lLength - 2)];

        for (int i = 0; i < lLength - 2; i++) {
            lArray[i] = lString.substring(i, i + 3);

            if (lArray[i].substring(0, 2).equalsIgnoreCase("Mc") && Character.isLetter(lString.charAt(i + 2))) {
                char[] lChar = lString.toCharArray();

                lChar[i + 2] = Character.toUpperCase(lChar[i + 2]);

                lString = new String(lChar);
            }
        }
    }

    return lString;
}