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:Main.java

/**
 * NameStartChar ::=   ":" | [A-Z] | "_" | [a-z]
 * @param charV/*w ww .  j  a va2 s  .c  om*/
 * @return
 */
private static boolean isStartChar(char charV) {
    if (Character.isLetter(charV))
        return true;
    if (charV == ':')
        return true;
    if (charV == '_')
        return true;
    return false;
}

From source file:com.SCI.centraltoko.utility.UtilityTools.java

public static void setAutoUpperCase(final JTextField textField) {
    textField.addKeyListener(new KeyAdapter() {

        @Override/* w  ww . ja va  2  s.  co m*/
        public void keyReleased(KeyEvent e) {
            if (Character.isLetter(e.getKeyChar())) {
                convertToUpperCase((JTextField) e.getSource());
            }
        }

    });
}

From source file:org.sventon.model.DirEntryNameSplitter.java

/**
 * @return Space delimited fragments without punctuation.
 *///from w  w w  .j a  va  2 s. c o  m
public List<String> split() {
    final String strippedName = removePunctuationCharacters();
    final List<String> fragments = new ArrayList<String>();
    final StringBuilder tempBuf = new StringBuilder();
    boolean start = false;

    for (int i = 0; i < strippedName.length(); i++) {
        final Character c = strippedName.charAt(i);
        if (Character.isWhitespace(c)) {
            start = addFragment(fragments, tempBuf);
        } else if (Character.isUpperCase(c) || !Character.isLetter(c)) {
            if (!start) {
                start = addFragment(fragments, tempBuf);
            }
            tempBuf.append(c);
        } else {
            if (start)
                start = false;
            tempBuf.append(c);
        }
    }
    addFragment(fragments, tempBuf);
    return fragments;
}

From source file:Anagram.java

/**
 * Removes punctuation & spaces -- everything except 
 * letters from the passed-in string.//from  w  w  w.  ja v  a  2 s  .c o  m
 * 
 * @return a stripped copy of the passed-in string
 */
protected static String removeJunk(String string) {
    int i, len = string.length();
    StringBuilder dest = new StringBuilder(len);
    char c;

    for (i = (len - 1); i >= 0; i--) {
        c = string.charAt(i);
        if (Character.isLetter(c)) {
            dest.append(c);
        }
    }

    return dest.toString();
}

From source file:pl.edu.icm.cermine.bibref.parsing.features.IsDashBetweenWordsFeature.java

@Override
public double calculateFeatureValue(CitationToken object, Citation context) {
    String text = object.getText();
    if (text.length() != 1 || object.getStartIndex() <= 0
            || object.getEndIndex() >= context.getText().length()) {
        return 0;
    }//w w  w. j a  v  a2s. c o  m
    if (!ArrayUtils.contains(DASH_CHARS, text.charAt(0))) {
        return 0;
    }
    return (Character.isLetter(context.getText().charAt(object.getStartIndex() - 1))
            && Character.isLetter(context.getText().charAt(object.getEndIndex()))) ? 1 : 0;
}

From source file:org.sonar.php.checks.utils.AbstractCommentContainsPatternCheck.java

private boolean isLetterAround(String line) {
    int start = StringUtils.indexOfIgnoreCase(line, pattern());
    int end = start + pattern().length();

    boolean pre = start > 0 && Character.isLetter(line.charAt(start - 1));
    boolean post = end < line.length() - 1 && Character.isLetter(line.charAt(end));

    return pre || post;
}

From source file:com.SCI.centraltoko.utility.UtilityTools.java

public static void setAutoUpperCase(final JTextArea textArea) {
    textArea.addKeyListener(new KeyAdapter() {

        @Override/* w  w w. j  ava 2 s. c  o m*/
        public void keyReleased(KeyEvent e) {
            if (Character.isLetter(e.getKeyChar())) {
                convertToUpperCase((JTextArea) e.getSource());
            }
        }

    });
}

From source file:com.iflytek.spider.metadata.SpellCheckedMetadata.java

/**
 * Normalizes String./*from  ww w.  java  2s . c  om*/
 * 
 * @param str
 *          the string to normalize
 * @return normalized String
 */
private static String normalize(final String str) {
    char c;
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < str.length(); i++) {
        c = str.charAt(i);
        if (Character.isLetter(c)) {
            buf.append(Character.toLowerCase(c));
        }
    }
    return buf.toString();
}

From source file:com.github.jferard.pgloaderutils.sniffer.csv.RowSignaturesAnalyzer.java

/**
 * @param s/*from  w ww. j ava  2 s. c  om*/
 * @return the type of the value : 'D' for digits only value, 'd' for 80%
 *         digits values and at least one char, '?' else
 */
public char getType(final String s) {
    int digits = 0;
    int letters = 0;
    for (int i = 0; i < s.length(); i++) {
        final char c = s.charAt(i);
        if (Character.isLetter(c))
            letters++;
        else if (Character.isDigit(c))
            digits++;
        // else ignore
    }
    if (digits > 0) {
        if (letters == 0)
            return 'D';
        else if (digits >= 4 * letters)
            return 'd';
    }

    return '?';
}

From source file:XMLTreeView.java

public void characters(char[] data, int start, int end) {
    String str = new String(data, start, end);
    if (!str.equals("") && Character.isLetter(str.charAt(0)))
        currentNode.add(new DefaultMutableTreeNode(str));
}