Example usage for java.lang Character isLowerCase

List of usage examples for java.lang Character isLowerCase

Introduction

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

Prototype

public static boolean isLowerCase(int codePoint) 

Source Link

Document

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

Usage

From source file:org.mi.core.common.jdbc.QueryPageExt.java

/**
 * Title:?//from w  w w  .  j  av a2 s.c o  m
 * <p>
 * Description:
 * </p>
 * 
 * @param columName
 * @return
 */
public String coverdColumName(String columName) {
    StringBuffer str = new StringBuffer();
    for (int i = 0; i < columName.length(); i++) {
        char c = columName.charAt(i);
        if (!Character.isLowerCase(c) && c != '.') {
            str.append("_");
        }
        str.append(c);
    }
    String strco = str.toString().toLowerCase();
    return strco;
}

From source file:org.ebayopensource.turmeric.eclipse.services.ui.wizards.pages.ServiceFromNewWSDLPage.java

@Override
protected boolean dialogChanged() {
    if (super.dialogChanged() == false)
        return false;

    if (templateFileCombo != null && templateFileCombo.getSelectionIndex() == -1) {
        updateStatus(this.templateFileCombo, SOAMessages.TEMPLATE_ERR);
        return false;
    }// www  . ja  v a2  s  .  c  o m
    if (StringUtils.isNotEmpty(getResourceName()) && Character.isLowerCase(getResourceName().charAt(0))) {
        updatePageStatus(getResourceNameText(),
                EclipseMessageUtils.createStatus(SOAMessages.SVCNAME_ERR, IStatus.WARNING));
        return true;
    }
    return true;
}

From source file:org.intermine.common.swing.text.RestrictedInputDocument.java

/**
 * Insert the given text into this document, as long as it leaves the document valid.
 * /*from www .  ja  v a2s  .  co  m*/
 * @param offset The starting offset &gt;= 0.
 * @param str The string to insert; does nothing with null/empty strings.
 * @param attr The attributes for the inserted content.
 * 
 * @throws BadLocationException if the given insert position is not a valid
 * position within the document.
 *   
 * @see javax.swing.text.Document#insertString
 */
@Override
public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
    if (str == null) {
        return;
    }

    if (limit < 0 || getLength() + str.length() <= limit) {
        if (convertArray == null || convertArray.length < str.length()) {
            convertArray = new char[str.length()];
        }

        CharacterIterator iter = new StringCharacterIterator(str);
        char c = iter.first();
        int index;
        for (index = 0; c != CharacterIterator.DONE; c = iter.next()) {
            if (!overrideChecks && !StringUtils.contains(allowableCharacters, c)) {

                // At this point, c is invalid. See if a case change remedies this.

                if (caseConvert && Character.isLetter(c)) {
                    if (Character.isLowerCase(c)) {
                        c = Character.toUpperCase(c);
                    } else if (Character.isUpperCase(c)) {
                        c = Character.toLowerCase(c);
                    }
                    if (!StringUtils.contains(allowableCharacters, c)) {
                        // Don't insert but otherwise ignore.
                        return;
                    }
                } else {
                    return;
                }
            }
            convertArray[index++] = c;

        }
        super.insertString(offset, new String(convertArray, 0, index), attr);
    }
}

From source file:com.nokia.ci.integration.sqlImport.SqlSplitter.java

/**
 * @param c the char to check/*from w w  w.  j a v a  2  s .c  o  m*/
 * @return <code>true</code> if the given character is either a lower or an upperchase alphanumerical character
 */
private static boolean isAlpha(char c) {
    return Character.isUpperCase(c) || Character.isLowerCase(c);
}

From source file:com.careerly.utils.TextUtils.java

/**
 * ?a-zA-Z/*from  ww w. j  av a  2 s  .c o m*/
 *
 * @param ch ?
 * @return true
 */
public static boolean isEnglishChar(char ch) {
    return Character.isLowerCase(ch) || Character.isUpperCase(ch);
}

From source file:com.googlecode.goclipse.tooling.oracle.OraclePackageDescribeParser.java

protected StructureElement parseStructureElement(JSONObject object, boolean parsingMethods)
        throws JSONException, CommonException {
    String name = readString(object, "name");

    String posString = readString(object, "pos");
    SourceFileLocation elementSourceFileLoc = SourceFileLocation.parseSourceRange(posString, ':');
    if (!isSourceElementLocation(elementSourceFileLoc.getFileLocation())) {
        return null;
    }/*  ww  w. java 2s.  co m*/
    SourceRange nameSourceRange = elementSourceFileLoc.parseSourceRangeFrom1BasedIndex(sourceLineInfo);
    SourceRange sourceRange = nameSourceRange;

    String type = readOptionalString(object, "type");

    String kindString = readOptionalString(object, "kind");

    StructureElementKind elementKind;
    if (parsingMethods) {
        elementKind = StructureElementKind.METHOD;
    } else {
        if (kindString == null) {
            throw new CommonException("No `kind` field for element: " + name);
        }
        elementKind = parseKind(kindString, type);
    }
    if (elementKind == STRUCT || elementKind == StructureElementKind.INTERFACE) {
        type = null;
    } else if (elementKind == StructureElementKind.METHOD) {
        if (name.startsWith("method ")) {
            name = name.substring("method ".length());
            if (name.startsWith("(")) {
                String fullName = StringUtil.segmentAfterMatch(name, ")");
                if (fullName != null) {
                    fullName = fullName.trim();
                    int idLength = parseIdentifierStart(fullName);
                    if (idLength > 0) {
                        name = fullName.substring(0, idLength);
                        type = "func" + fullName.substring(idLength);
                    }
                }
            }
        }
    }

    if (name.length() == 0) {
        throw new CommonException("No name provided");
    }

    EProtection protection = EProtection.PUBLIC;

    if (!parsingMethods && Character.isLowerCase(name.charAt(0))) {
        protection = EProtection.PRIVATE;
    }

    ElementAttributes elementAttributes = new ElementAttributes(protection);

    JSONArray methods = getOptionalJSONArray(object, "methods");
    Indexable<StructureElement> children = parseElements(methods, true);

    return new StructureElement(name, nameSourceRange, sourceRange, elementKind, elementAttributes, type,
            children);
}

From source file:com.gargoylesoftware.htmlunit.CodeStyleTest.java

/**
 * Checks the JavaDoc first line, it should not be empty, and should not start with lower-case.
 *///w  w  w. j  a  v  a  2 s  . com
private void javaDocFirstLine(final List<String> lines, final String relativePath) {
    for (int index = 1; index < lines.size(); index++) {
        final String previousLine = lines.get(index - 1);
        final String currentLine = lines.get(index);
        if ("/**".equals(previousLine.trim())) {
            if ("*".equals(currentLine.trim()) || currentLine.contains("*/")) {
                addFailure("Empty line in " + relativePath + ", line: " + (index + 1));
            }
            if (currentLine.trim().startsWith("*")) {
                final String text = currentLine.trim().substring(1).trim();
                if (!text.isEmpty() && Character.isLowerCase(text.charAt(0))) {
                    addFailure("Lower case start in " + relativePath + ", line: " + (index + 1));
                }
            }
        }
    }
}

From source file:org.intermine.metadata.StringUtil.java

/**
 * Reverses the capitalisation of the first character of the given String.
 *
 * @param str a String/*w  w w. ja va 2  s .  co  m*/
 * @return another String
 */
public static String reverseCapitalisation(String str) {
    if (str == null) {
        return null;
    }
    if ("".equals(str)) {
        return str;
    }
    char first = str.charAt(0);
    if (Character.isLowerCase(first)) {
        return Character.toUpperCase(first) + str.substring(1);
    }
    return Character.toLowerCase(first) + str.substring(1);
}

From source file:org.talend.dataquality.duplicating.FieldModifier.java

public String generateDuplicateString(String str, Function function, int modifCount, String extraParameter) {
    StringBuilder sb = new StringBuilder(str);
    switch (function) {
    case REPLACE_LETTER:
        if (sb.length() > 0) {
            for (int i = 0; i < modifCount; i++) {
                int pos = random.nextInt(sb.length());
                int idx = random.nextInt(LETTER.length());
                sb.setCharAt(pos, LETTER.charAt(idx));
            }// w w  w .j  a v a  2s. c  o m
        }
        break;
    case ADD_LETTER:
        for (int i = 0; i < modifCount; i++) {
            int pos = sb.length() == 0 ? 0 : random.nextInt(sb.length());
            int idx = random.nextInt(LETTER.length());
            sb.insert(pos, LETTER.charAt(idx));
        }
        break;
    case REPLACE_DIGIT:
        if (sb.length() > 0) {
            for (int i = 0; i < modifCount; i++) {
                int pos = random.nextInt(sb.length());
                int idx = random.nextInt(DIGIT.length());
                sb.setCharAt(pos, DIGIT.charAt(idx));
            }
        }
        break;
    case ADD_DIGIT:
        for (int i = 0; i < modifCount; i++) {
            int pos = sb.length() == 0 ? 0 : random.nextInt(sb.length());
            int idx = random.nextInt(DIGIT.length());
            if (pos == 0) {
                idx = random.nextInt(DIGIT.length() - 1) + 1;
            }
            sb.insert(pos, DIGIT.charAt(idx));
        }
        break;
    case REMOVE_LETTER:
        for (int i = 0; i < modifCount; i++) {
            if (sb.length() > 0) {
                int pos = random.nextInt(sb.length());
                sb.deleteCharAt(pos);
            }
        }
        break;
    case REMOVE_DIGIT:
        for (int i = 0; i < modifCount; i++) {
            if (sb.length() > 1) {
                int pos = random.nextInt(sb.length());
                sb.deleteCharAt(pos);
            }
        }
        break;
    case EXCHANGE_CHAR:
        if (sb.length() > 1) {
            for (int i = 0; i < modifCount; i++) {
                int pos1 = random.nextInt(sb.length());
                int pos2 = random.nextInt(sb.length());
                if (pos1 != pos2) {
                    char ch1 = sb.charAt(pos1);
                    char ch2 = sb.charAt(pos2);
                    sb.setCharAt(pos1, ch2);
                    sb.setCharAt(pos2, ch1);
                }
            }
        }
        break;
    case SOUNDEX_REPLACE:
        if (sb.length() > 0) {
            Set<Character> charSet = new HashSet<Character>();
            for (int i = 0; i < modifCount; i++) {
                int pos = random.nextInt(sb.length());
                char charToReplace = sb.charAt(pos);
                int idx = Character.toUpperCase(charToReplace) - 'A';
                if (idx >= 0 && idx < 26) {
                    Set<Character> soundexSet = getInverseSoundexMap().get(soundexMap[idx]);
                    if (soundexSet != null) {
                        charSet.clear();
                        charSet.addAll(soundexSet);
                        charSet.remove(charToReplace);
                        if (charSet.size() > 0) {
                            Character[] charArray = charSet.toArray(new Character[charSet.size()]);
                            Character newChar = charArray[random.nextInt(charArray.length)];
                            if (Character.isLowerCase(charToReplace)) {
                                newChar = Character.toLowerCase(newChar);
                            }
                            sb.setCharAt(pos, newChar);
                        }
                    }
                }
            }
        }
        break;
    case SYNONYM_REPLACE:
        // if (str.length() > 0) {
        // SynonymIndexSearcher searcher = getSynonymSearcherMap().get(extraParameter);
        // if (searcher == null) {
        // searcher = new SynonymIndexSearcher(extraParameter);
        // synonymSearcherMap.put(extraParameter, searcher);
        // }
        // try {
        // TopDocs docs = searcher.searchDocumentBySynonym(str);
        // if (docs.totalHits > 0) {
        // Document doc = searcher.getDocument(docs.scoreDocs[0].doc);
        // List<String> replaceList = new ArrayList<String>();
        // String word = doc.getValues(SynonymIndexSearcher.F_WORD)[0];
        // if (!word.equalsIgnoreCase(str)) {
        // replaceList.add(word);
        // }
        // String[] synonyms = doc.getValues(SynonymIndexSearcher.F_SYN);
        // for (String syn : synonyms) {
        // if (!syn.equalsIgnoreCase(str)) {
        // replaceList.add(syn);
        // }
        // }
        // if (replaceList.isEmpty()) {
        // return str;
        // } else {
        // return replaceList.get(random.nextInt(replaceList.size()));
        // }
        // }
        // } catch (ParseException e) {
        // e.printStackTrace();
        // } catch (IOException e) {
        // e.printStackTrace();
        // }
        // }
        // break;
        return str;
    default:
        return str;
    }

    return sb.toString();
}

From source file:forge.card.CardType.java

@Override
public boolean hasStringType(String t) {
    if (t.isEmpty()) {
        return false;
    }/* w w w.ja va 2 s . com*/
    if (hasSubtype(t)) {
        return true;
    }
    final char firstChar = t.charAt(0);
    if (Character.isLowerCase(firstChar)) {
        t = Character.toUpperCase(firstChar) + t.substring(1); //ensure string is proper case for enum types
    }
    final CoreType type = stringToCoreType.get(t);
    if (type != null) {
        return hasType(type);
    }
    final Supertype supertype = stringToSupertype.get(t);
    if (supertype != null) {
        return hasSupertype(supertype);
    }
    return false;
}