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.jskaleel.xml.JSONObject.java

private void populateMap(Object bean) {
    Class klass = bean.getClass();

    // If klass is a System class then set includeSuperClass to false.

    boolean includeSuperClass = klass.getClassLoader() != null;

    Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
    for (int i = 0; i < methods.length; i += 1) {
        try {/*from ww  w.  java2s . com*/
            Method method = methods[i];
            if (Modifier.isPublic(method.getModifiers())) {
                String name = method.getName();
                String key = "";
                if (name.startsWith("get")) {
                    if ("getClass".equals(name) || "getDeclaringClass".equals(name)) {
                        key = "";
                    } else {
                        key = name.substring(3);
                    }
                } else if (name.startsWith("is")) {
                    key = name.substring(2);
                }
                if (key.length() > 0 && Character.isUpperCase(key.charAt(0))
                        && method.getParameterTypes().length == 0) {
                    if (key.length() == 1) {
                        key = key.toLowerCase();
                    } else if (!Character.isUpperCase(key.charAt(1))) {
                        key = key.substring(0, 1).toLowerCase() + key.substring(1);
                    }

                    Object result = method.invoke(bean, (Object[]) null);
                    if (result != null) {
                        this.map.put(key, wrap(result));
                    }
                }
            }
        } catch (Exception ignore) {
        }
    }
}

From source file:nl.minbzk.dwr.zoeken.enricher.processor.TikaProcessor.java

/**
 * Determine whether a given token breaks a line or paragraph segment.
 * /*from  w w w. jav  a 2  s  .c  o  m*/
 * @param token
 * @param nextToken
 * @return boolean
 */
private static boolean isTokenBreaksSegment(final String token, final String nextToken) {
    boolean endOfLine = token.endsWith(".");
    boolean endOfParagraph = token.contains("\n") || token.contains("\n\n");
    boolean nextTokenStartsSentence = StringUtils.isEmpty(nextToken) || endOfParagraph
            || Character.isUpperCase(nextToken.charAt(0));

    return (endOfLine || endOfParagraph) && nextTokenStartsSentence;
}

From source file:com.igormaznitsa.mvngolang.AbstractGolangMojo.java

private void warnIfContainsUC(@Nonnull final String message, @Nonnull final String str) {
    boolean detected = false;
    for (final char c : str.toCharArray()) {
        if (Character.isUpperCase(c)) {
            detected = true;//from   w  w w  . jav a  2s  .c  o m
            break;
        }
    }
    if (detected) {
        getLog().warn(message + " : " + str);
    }
}

From source file:nl.minbzk.dwr.zoeken.enricher.processor.TikaProcessor.java

/**
 * Determine the character set from a given language-charset combination. The result will be [ language, encoding ] where encoding can be null.
 * /*from   w  w  w .j av a2s. c  o m*/
 * @param value
 * @return String[]
 */
private static String[] retrieveLanguageEncoding(final String value) {
    // Strip any quotes

    String languageEncoding = value.replaceAll("\"", "");

    // Then split it up based on character encoding

    String encoding = null, language = languageEncoding;

    for (int i = 0; i < languageEncoding.length(); i++)
        if (Character.isUpperCase(languageEncoding.charAt(i))) {
            encoding = languageEncoding.substring(i);

            // This should never happen - but it could

            if (i > 0)
                language = languageEncoding.substring(0, i);
            else
                language = DEFAULT_ENCODING;

            break;
        }

    return new String[] { language != null ? language.split("-")[0].trim() : null,
            encoding != null ? encoding.toUpperCase() : null };
}

From source file:org.codehaus.groovy.grails.commons.GrailsClassUtils.java

/**
 * Returns true if the name of the method specified and the number of arguments make it a javabean property
 *
 * @param name True if its a Javabean property
 * @param args The arguments/*w  w w  .  java2 s. c o m*/
 * @return true if it is a javabean property method
 */
public static boolean isGetter(String name, Class<?>[] args) {
    if (StringUtils.isBlank(name) || args == null)
        return false;
    if (args.length != 0)
        return false;

    if (name.startsWith("get")) {
        name = name.substring(3);
        if (name.length() > 0 && Character.isUpperCase(name.charAt(0)))
            return true;
    } else if (name.startsWith("is")) {
        name = name.substring(2);
        if (name.length() > 0 && Character.isUpperCase(name.charAt(0)))
            return true;
    }
    return false;
}

From source file:de.aschoerk.javaconv.RustDumpVisitor.java

@Override
public void visit(final FieldAccessExpr n, final Object arg) {
    printJavaComment(n.getComment(), arg);
    int mark = printer.push();
    n.getScope().accept(this, arg);
    String scope = printer.getMark(mark);
    printer.drop();//w w  w  . j a v a 2  s. c om
    int i = StringUtils.lastIndexOfAny(StringUtils.stripEnd(scope, " "), "\n", "\t", " ", ".");
    String accessed = i <= 0 ? scope : scope.substring(i + 1);
    if (Character.isUpperCase(accessed.charAt(0)) && accessed.length() > 1
            && Character.isLowerCase(accessed.charAt(1))) {
        printer.print("::");
    } else {
        printer.print(".");
    }
    printer.print(replaceLengthAtEnd(n.getField()));
}

From source file:org.codehaus.groovy.grails.commons.GrailsClassUtils.java

private static String convertPropertyName(String prop) {
    if (prop.length() == 1) {
        return prop.toLowerCase();
    }/*from w w w . ja v a 2  s.  co m*/
    if (Character.isUpperCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) {
        return prop;
    }
    if (Character.isDigit(prop.charAt(0))) {
        return prop;
    }
    return Character.toLowerCase(prop.charAt(0)) + prop.substring(1);
}

From source file:lucee.commons.lang.StringUtil.java

/**
 * translate a string in camel notation to a string in hypen notation
 * example://  w w  w.  j  a v a  2 s .c  o  m
 * helloWorld -> hello-world
 * @param str
 * @return
 */
public static String camelToHypenNotation(String str) {
    if (isEmpty(str))
        return str;

    StringBuilder sb = new StringBuilder();
    //int len=str.length();
    char c;

    sb.append(Character.toLowerCase(str.charAt(0)));
    for (int i = 1; i < str.length(); i++) {
        c = str.charAt(i);
        if (Character.isUpperCase(c)) {
            sb.append('-');
            sb.append(Character.toLowerCase(c));
        } else
            sb.append(c);
    }
    return sb.toString();
}

From source file:org.codehaus.groovy.grails.commons.GrailsClassUtils.java

@SuppressWarnings("rawtypes")
public static boolean isSetter(String name, Class[] args) {
    if (StringUtils.isBlank(name) || args == null)
        return false;

    if (name.startsWith("set")) {
        if (args.length != 1)
            return false;
        name = name.substring(3);/*from w ww  .j  a va  2  s.  com*/
        if (name.length() > 0 && Character.isUpperCase(name.charAt(0)))
            return true;
    }

    return false;
}

From source file:it.acubelab.smaph.SmaphAnnotator.java

/**
 * Generates the Entity Selection features for an entity drawn from Source 2
 * (Normal Search)/*from  www.j  a  v a  2 s. c o  m*/
 * 
 * @param query
 *            the query that has been issued to Bing.
 * @param wid
 *            the Wikipedia page ID of the entity.
 * @param rank
 *            the position in which the entity appeared in the Bing results.
 * @param wikiWebTotal
 *            total web results found by Bing for the Wikisearch.
 * @param webTotal
 *            total web results found by Bing for the normal search.
 * @param bingBoldsWS
 *            the list of bolds spotted by Bing for the Wikisearch plus their position.
 * @param source
 *            Source id (3 for WikiSearch)
 * @return a mapping between feature name and its value.
 */
private HashMap<String, Double> generateEntitySelectionFeaturesSearch(String query, int wid, int rank,
        double webTotal, double wikiWebTotal, List<Pair<String, Integer>> bingBoldsWS, int source) {

    String sourceName = "s" + source;
    HashMap<String, Double> result = new HashMap<>();
    result.put("is_" + sourceName, 1.0);
    result.put(sourceName + "_rank", (double) rank);
    result.put(sourceName + "_webTotal", (double) webTotal);
    result.put(sourceName + "_wikiWebTotal", (double) wikiWebTotal);
    String title;
    try {
        title = wikiApi.getTitlebyId(wid);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    result.put(sourceName + "_editDistanceTitle", SmaphUtils.getMinEditDist(query, title));
    result.put(sourceName + "_editDistanceNoPar",
            SmaphUtils.getMinEditDist(query, title.replaceAll(WIKITITLE_ENDPAR_REGEX, "")));

    double minEdDist = 1.0;
    double capitalized = 0;
    double avgNumWords = 0;
    int boldsCount = 0;
    for (Pair<String, Integer> p : bingBoldsWS)
        if (p.second == rank) {
            boldsCount++;
            minEdDist = Math.min(minEdDist, SmaphUtils.getMinEditDist(query, p.first));
            if (Character.isUpperCase(p.first.charAt(0)))
                capitalized++;
            avgNumWords += p.first.split("\\W+").length;
        }
    if (boldsCount != 0)
        avgNumWords /= boldsCount;
    result.put(sourceName + "_editDistanceBolds", minEdDist);
    result.put(sourceName + "_capitalizedBolds", capitalized);
    result.put(sourceName + "_avgBoldsWords", avgNumWords);

    return result;
}