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:banner.tagging.dictionary.DictionaryTagger.java

protected String transform(String str) {
    // This has been optimized for very fast operation
    String result = str;/*from w  w  w .  j  av  a2s  .  c  om*/

    if (stemTokens) {
        String stem = stemmer.stem(str);
        // System.out.println("Stemmer; original= " + str + ", stemmed= " + stem);
        str = stem;
    }
    if (normalizeMixedCase || normalizeDigits) {
        char[] chars = str.toCharArray();
        if (normalizeMixedCase) {
            boolean hasUpper = false;
            boolean hasLower = false;
            for (int i = 0; i < chars.length && (!hasUpper || !hasLower); i++) {
                hasUpper |= Character.isUpperCase(chars[i]);
                hasLower |= Character.isLowerCase(chars[i]);
            }
            if (hasUpper && hasLower)
                for (int i = 0; i < chars.length; i++)
                    chars[i] = Character.toLowerCase(chars[i]);
        }
        // Note that this only works on single digits
        if (normalizeDigits)
            for (int i = 0; i < chars.length; i++)
                if (Character.isDigit(chars[i]))
                    chars[i] = '0';
        result = new String(chars);
    }
    return result;
}

From source file:io.github.jeddict.jcode.util.StringHelper.java

/**
 *
 * @param input/*from w w  w. ja v  a2  s  . c  o  m*/
 * @return
 * @example
 *
 * BankAccount => BANK_ACCOUNT Bank_Account => BANK_ACCOUNT
 */
public static String toConstant(String input) {
    String constant = EMPTY;
    Character lastChar = null;
    for (Character curChar : input.toCharArray()) {
        if (lastChar == null) {
            // First character
            lastChar = Character.toUpperCase(curChar);
            constant = constant + lastChar;

        } else {
            if (Character.isLowerCase(lastChar)
                    && (Character.isUpperCase(curChar) || Character.isDigit(curChar))) {
                constant = constant + '_' + curChar;
            } else {
                constant = constant + Character.toUpperCase(curChar);
            }
            lastChar = curChar;
        }

    }
    return constant;
}

From source file:org.codice.ddf.catalog.ui.query.suggestion.UtmUpsCoordinateProcessor.java

/**
 * Transform the UTM string to disambiguate multiple hemisphere clues.
 *
 * @param utmOrUps the UTM string to transform.
 * @return a UTM string with a single piece of data that defines hemisphere.
 */// w  w  w.  ja  v a  2s  .c  o m
private static String normalizeCoordinate(final String utmOrUps) {
    if (!PATTERN_UTM_COORDINATE.matcher(utmOrUps).matches()) {
        LOGGER.trace("No transform necessary, coordinate [{}] was not UTM", utmOrUps);
        return utmOrUps; // Must be UPS, do nothing
    }
    final Character latBand = getLatBand(utmOrUps);
    if (latBand == null) {
        final String withDefaultNorthLatBand = useDefaultNorthLatBand(utmOrUps);
        LOGGER.trace("No lat band found on input [{}], setting it to default for north hemisphere [{}]",
                utmOrUps, withDefaultNorthLatBand);
        return withDefaultNorthLatBand;
    }
    if (Character.isLowerCase(latBand)) {
        final String asUpperCase = setLatBand(utmOrUps, Character.toUpperCase(latBand));
        LOGGER.trace("Found lower case lat band on input [{}], converting to upper case [{}]", utmOrUps,
                asUpperCase);
        return asUpperCase;
    }
    LOGGER.trace("Found lat band on input [{}]", utmOrUps);
    return utmOrUps;
}

From source file:io.uengine.util.StringUtils.java

/**
 *  ?? escape .//from   www .  jav a 2s . c  o m
 *
 * @param string Escape  ?
 * @return escape  ?
 */
public static String escape(String string) {
    int i;
    char j;
    StringBuilder builder = new StringBuilder();
    builder.ensureCapacity(string.length() * 6);
    for (i = 0; i < string.length(); i++) {
        j = string.charAt(i);
        if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j))
            builder.append(j);
        else if (j < 256) {
            builder.append("%");
            if (j < 16)
                builder.append("0");
            builder.append(Integer.toString(j, 16));
        } else {
            builder.append("%u");
            builder.append(Integer.toString(j, 16));
        }
    }
    return builder.toString();
}

From source file:org.jboss.dashboard.commons.misc.ReflectionUtils.java

/**
 * Convert the fieldName to a valid name to be append to METHOD_PREFIX_GET/SET
 *
 * @param fieldName name of the accessor property
 * @return valid name for accessor/*ww w.j  a  va 2s .c om*/
 */
private static String getValidAccessorName(String fieldName) {
    char firstChar = fieldName.charAt(0);
    String field = StringUtil.toJavaClassName(fieldName);
    if (fieldName.length() > 1) {
        //fix if firstCharacter is lowercase and second is uppercase, then create correct accessor (i.e. getter for field xXX is getxXX)
        char secondChar = fieldName.charAt(1);
        if (Character.isLowerCase(firstChar) && Character.isUpperCase(secondChar)) {
            field = field.replaceFirst(Character.toString(field.charAt(0)), Character.toString(firstChar));
        }
    }
    return field;
}

From source file:org.string_db.DbFacade.java

/**
 * Seems like items.species_names has lots of not really useful names,
 * so let's just pick short, one-word ones, that start with lower case,
 * e.g. human for 9606, mouse&mice for 10090, yeast for 4932, etc.
 *
 * @param speciesId//  w  ww . ja  va 2  s . c  o m
 * @return
 */
public Collection<String> loadSpeciesNames(Integer speciesId) {
    final Map<String, Set<String>> all = queryProcessor.selectTwoColumns("official_name", "species_name",
            "items.species_names", TwoColumnRowMapper.<String, String>multiValMapper(),
            "species_id = :species_id and species_name not like '% %';",
            new MapSqlParameterSource("species_id", speciesId));
    List<String> names = new ArrayList<>();
    final Iterator<String> iterator = all.keySet().iterator();
    if (!iterator.hasNext()) {
        //some species don't have synonyms so need to get the official one:
        names.add(loadSpeciesName(speciesId));
        return names;
    }
    final String official = iterator.next();
    names.add(official);
    for (String name : all.get(official)) {
        if (Character.isLowerCase(name.charAt(0))) {
            names.add(name);
        }
    }
    return names;

}

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

@Override
public RuleMatch[] match(List<AnalyzedSentence> sentences) throws IOException {
    String lastParagraphString = "";
    List<RuleMatch> ruleMatches = new ArrayList<>();
    if (sentences.size() == 1 && sentences.get(0).getTokens().length == 2) {
        // Special case for a single "sentence" with a single word - it's not useful
        // to complain about this (and might hide a typo error):
        return toRuleMatchArray(ruleMatches);
    }//  w w w . ja va2 s  .  c om
    int pos = 0;
    for (AnalyzedSentence sentence : sentences) {
        AnalyzedTokenReadings[] tokens = getSentenceWithImmunization(sentence).getTokensWithoutWhitespace();
        if (tokens.length < 2) {
            return toRuleMatchArray(ruleMatches);
        }
        int matchTokenPos = 1; // 0 = SENT_START
        AnalyzedTokenReadings firstTokenObj = tokens[matchTokenPos];
        String firstToken = firstTokenObj.getToken();
        String secondToken = null;
        String thirdToken = null;
        // ignore quote characters:
        if (tokens.length >= 3 && isQuoteStart(firstToken)) {
            matchTokenPos = 2;
            secondToken = tokens[matchTokenPos].getToken();
        }
        String firstDutchToken = dutchSpecialCase(firstToken, secondToken, tokens);
        if (firstDutchToken != null) {
            thirdToken = firstDutchToken;
            matchTokenPos = 3;
        }

        String checkToken = firstToken;
        if (thirdToken != null) {
            checkToken = thirdToken;
        } else if (secondToken != null) {
            checkToken = secondToken;
        }

        String lastToken = tokens[tokens.length - 1].getToken();
        if (WHITESPACE_OR_QUOTE.matcher(lastToken).matches()) {
            // ignore trailing whitespace or quote
            lastToken = tokens[tokens.length - 2].getToken();
        }

        boolean preventError = false;
        if (lastParagraphString.equals(",") || lastParagraphString.equals(";")) {
            preventError = true;
        }
        if (!SENTENCE_END1.matcher(lastParagraphString).matches() && !isSentenceEnd(lastToken)) {
            preventError = true;
        }

        lastParagraphString = lastToken;

        //allows enumeration with lowercase letters: a), iv., etc.
        if (matchTokenPos + 1 < tokens.length && NUMERALS_EN.matcher(tokens[matchTokenPos].getToken()).matches()
                && (tokens[matchTokenPos + 1].getToken().equals(".")
                        || tokens[matchTokenPos + 1].getToken().equals(")"))) {
            preventError = true;
        }

        if (isUrl(checkToken) || isEMail(checkToken) || firstTokenObj.isImmunized()) {
            preventError = true;
        }

        if (checkToken.length() > 0) {
            char firstChar = checkToken.charAt(0);
            if (!preventError && Character.isLowerCase(firstChar)) {
                RuleMatch ruleMatch = new RuleMatch(this, sentence, pos + tokens[matchTokenPos].getStartPos(),
                        pos + tokens[matchTokenPos].getEndPos(), messages.getString("incorrect_case"));
                ruleMatch.setSuggestedReplacement(StringTools.uppercaseFirstChar(checkToken));
                ruleMatches.add(ruleMatch);
            }
        }
        pos += sentence.getText().length();
    }
    return toRuleMatchArray(ruleMatches);
}

From source file:stg.utils.RandomStringGenerator.java

/**
 * Sets the lower case alphabets array.//www .j  av a  2  s  .c  om
 * The default lower case character array contains a to z characters.
 *  
 * @param lowerCaseAlphabetsArray
 */
public void setLowerCaseAlphabets(char[] lowerCaseAlphabetsArray) {
    if (lowerCaseAlphabetsArray == null) {
        throw new NullPointerException();
    }
    ArrayList<Character> list = new ArrayList<Character>();
    for (int i = 0; i < lowerCaseAlphabetsArray.length; i++) {
        if (!Character.isLowerCase(lowerCaseAlphabetsArray[i])) {
            throw new IllegalArgumentException("Must be a lower case alphabet");
        }
        list.add(lowerCaseAlphabetsArray[i]);
    }
    lowerCaseCharsList.clear();
    lowerCaseCharsList.addAll(list);
}

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

/**
 * ?a-zA-Z0-9//ww w  .j  ava  2  s.c o m
 *
 * @param ch ?
 * @return  true
 */
public static boolean isDigitOrEngilishChar(char ch) {
    return Character.isLowerCase(ch) || Character.isUpperCase(ch) || Character.isDigit(ch);
}

From source file:com.liferay.cucumber.util.StringUtil.java

public static boolean isUpperCase(String s) {
    if (s == null) {
        return false;
    }//  w  w w  . jav a2 s.  c  o  m

    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);

        // Fast path for ascii code, fallback to the slow unicode detection

        if (c <= 127) {
            if ((c >= CharPool.LOWER_CASE_A) && (c <= CharPool.LOWER_CASE_Z)) {

                return false;
            }

            continue;
        }

        if (Character.isLetter(c) && Character.isLowerCase(c)) {
            return false;
        }
    }

    return true;
}