Example usage for java.lang Character isUpperCase

List of usage examples for java.lang Character isUpperCase

Introduction

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

Prototype

public static boolean isUpperCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is an uppercase character.

Usage

From source file:com.oakhole.utils.EncodeUtils.java

/**
 * jsescape./*w  w  w .  j  a va2 s.  c  o  m*/
 * 
 * @param src
 *            String
 * @return String
 */
public static String escapeJS(String src) {
    int i;
    char j;
    StringBuffer tmp = new StringBuffer();
    tmp.ensureCapacity(src.length() * UNICODE_LENGTH);

    for (i = 0; i < src.length(); i++) {
        j = src.charAt(i);

        if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j)) {
            tmp.append(j);
        } else if (j < ANSI_CHAR_CODE) {
            tmp.append("%");

            if (j < UNPRINTABLE_CHAR_CODE) {
                tmp.append("0");
            }

            tmp.append(Integer.toString(j, HEX));
        } else {
            tmp.append("%u");
            tmp.append(Integer.toString(j, HEX));
        }
    }

    return tmp.toString();
}

From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.candidate.HeuristicNamedEntityAnnotator.java

private boolean startsWithUpperCase(String token) {
    if (!token.isEmpty()) {
        return Character.isUpperCase(token.charAt(0));
    } else {/*from  w w w.  j a  va2s  . c  o m*/
        return false;
    }
}

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  ww.  ja va 2  s . co  m*/
    }
    return true;
}

From source file:ar.com.fdvs.dj.domain.builders.ReflectiveReportBuilder.java

/**
 * Calculates a column title using camel humps to separate words.
 * @param _property the property descriptor.
 * @return the column title for the given property.
 *///from  w  w w.  java 2  s  .c o m
private static String getColumnTitle(final PropertyDescriptor _property) {
    final StringBuffer buffer = new StringBuffer();
    final String name = _property.getName();
    buffer.append(Character.toUpperCase(name.charAt(0)));
    for (int i = 1; i < name.length(); i++) {
        final char c = name.charAt(i);
        if (Character.isUpperCase(c)) {
            buffer.append(' ');
        }
        buffer.append(c);
    }
    return buffer.toString();
}

From source file:net.portalblockz.portalbot.smarts.SmartListener.java

public void checkCaps(MessageEvent e) {
    if (server.getStaff().contains(e.getNick()))
        return;//from ww  w.ja va  2  s.  c  o m
    double upperCaseCount = 0;
    String message = e.getMessage();
    for (int i = 0; i < message.length(); i++) {
        if (Character.isUpperCase(message.charAt(i))) {
            upperCaseCount++;
        }
    }
    double maxPer = 50;
    double tempNum = upperCaseCount / message.length();
    double percent = tempNum * 100;
    if (percent >= maxPer && message.length() > 5) {
        IRCUser user = users.get(e.getNick().toLowerCase());
        user.setCaps(user.getCaps() + 1);
        if (user.getCaps() >= MAX_WARNS) {
            e.getChannel().kick(e.getNick(), "Please do not use so much caps!");
        } else {
            e.getSession().notice(e.getNick(),
                    Colors.RED + "Please don't use more then 50% caps in a message!");
        }
    }
}

From source file:org.axe.util.StringUtil.java

public static String camelToUnderline(String param) {
    if (param == null || "".equals(param.trim())) {
        return "";
    }/*from  w ww.  j  av  a2s.com*/
    int len = param.length();
    StringBuilder sb = new StringBuilder(len);
    for (int i = 0; i < len; i++) {
        char c = param.charAt(i);
        if (Character.isUpperCase(c)) {
            if (i > 0) {
                sb.append(UNDERLINE);
            }
            sb.append(Character.toLowerCase(c));
        } else {
            sb.append(c);
        }
    }
    return sb.toString();
}

From source file:no.sesat.search.site.config.AbstractDocumentFactory.java

/***
* <p>The words within the bean name are deduced assuming the
* first-letter-capital (for example camel's hump) naming convention. For
* example, the words in <code>FooBar</code> are <code>foo</code>
* and <code>bar</code>.</p>
*
* <p>Then the {@link #getSeparator} property value is inserted so that it separates
* each word.</p>//  ww w .  ja  v  a  2 s.com
*
* @param beanName The name string to convert.  If a JavaBean
* class name, should included only the last part of the name
* rather than the fully qualified name (e.g. FooBar rather than
* org.example.FooBar).
* @return the bean name converted to either upper or lower case with words separated
* by the separator.
**/
public static String beanToXmlName(final String beanName) {

    final StringBuilder xmlName = new StringBuilder(beanName);
    for (int i = 0; i < xmlName.length(); ++i) {
        final char c = xmlName.charAt(i);
        if (Character.isUpperCase(c)) {
            xmlName.replace(i, i + 1, "-" + Character.toLowerCase(c));
            ++i;
        }
    }
    return xmlName.toString();
}

From source file:org.languagetool.rules.patterns.RegexPatternRule.java

@Override
public RuleMatch[] match(AnalyzedSentence sentenceObj) throws IOException {

    List<Pair<Integer, Integer>> suggestionsInMessage = getClausePositionsInMessage(suggestionPattern, message);
    List<Pair<Integer, Integer>> backReferencesInMessage = getClausePositionsInMessage(matchPattern, message);

    List<Pair<Integer, Integer>> suggestionsInSuggestionsOutMsg = getClausePositionsInMessage(suggestionPattern,
            suggestionsOutMsg);//from   w  ww.  j  a  v  a 2s  .co  m
    List<Pair<Integer, Integer>> backReferencesInSuggestionsOutMsg = getClausePositionsInMessage(matchPattern,
            suggestionsOutMsg);

    Matcher patternMatcher = pattern.matcher(new InterruptibleCharSequence(sentenceObj.getText()));
    List<RuleMatch> matches = new ArrayList<>();
    int startPos = 0;

    while (patternMatcher.find(startPos)) {
        try {
            int markStart = patternMatcher.start(markGroup);
            int markEnd = patternMatcher.end(markGroup);

            String processedMessage = processMessage(patternMatcher, message, backReferencesInMessage,
                    suggestionsInMessage, suggestionMatches);
            String processedSuggestionsOutMsg = processMessage(patternMatcher, suggestionsOutMsg,
                    backReferencesInSuggestionsOutMsg, suggestionsInSuggestionsOutMsg, suggestionMatchesOutMsg);

            boolean startsWithUpperCase = patternMatcher.start() == 0
                    && Character.isUpperCase(sentenceObj.getText().charAt(patternMatcher.start()));
            RuleMatch ruleMatch = new RuleMatch(this, sentenceObj, markStart, markEnd, processedMessage,
                    shortMessage, startsWithUpperCase, processedSuggestionsOutMsg);
            matches.add(ruleMatch);

            startPos = patternMatcher.end();
        } catch (IndexOutOfBoundsException e) {
            throw new RuntimeException(String.format(
                    "Unexpected reference to capturing group in rule with id %s.", this.getFullId()), e);
        } catch (Exception e) {
            throw new RuntimeException(String.format(
                    "Unexpected exception when processing regexp in rule with id %s.", this.getFullId()), e);
        }
    }
    return matches.toArray(new RuleMatch[0]);
}

From source file:com.google.publicalerts.cap.CapUtil.java

static String underscoreCase(String s) {
    if (s.isEmpty()) {
        return s;
    }//from  w  w w.j  ava2s  .co m
    StringBuilder sb = new StringBuilder();
    char[] chars = s.toCharArray();
    sb.append(chars[0]);
    for (int i = 1; i < chars.length; i++) {
        char ch = chars[i];
        if (Character.isUpperCase(ch) && Character.isLowerCase(chars[i - 1])) {
            sb.append('_');
        }
        sb.append(ch);
    }
    return sb.toString();
}

From source file:mrcg.utils.Utils.java

public static String toSpacedCamelCase(String s) {
    StringBuilder b = new StringBuilder(s.length() + 5);
    for (char c : s.toCharArray()) {
        if (Character.isUpperCase(c) && b.length() > 0) {
            b.append(' ');
        }/*from  ww w.j  av a  2 s .com*/
        b.append(c);
    }
    return b.toString();
}