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.apache.velocity.runtime.parser.node.PropertyExecutor.java

/**
 * @param clazz//from  w  w w . ja  v  a 2  s  . c o  m
 * @param property
 */
protected void discover(final Class clazz, final String property) {
    /*
     *  this is gross and linear, but it keeps it straightforward.
     */

    try {
        Object[] params = {};

        StringBuffer sb = new StringBuffer("get");
        sb.append(property);

        setMethod(introspector.getMethod(clazz, sb.toString(), params));

        if (!isAlive()) {
            /*
             *  now the convenience, flip the 1st character
             */

            char c = sb.charAt(3);

            if (Character.isLowerCase(c)) {
                sb.setCharAt(3, Character.toUpperCase(c));
            } else {
                sb.setCharAt(3, Character.toLowerCase(c));
            }

            setMethod(introspector.getMethod(clazz, sb.toString(), params));
        }
    }
    /**
     * pass through application level runtime exceptions
     */
    catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        String msg = "Exception while looking for property getter for '" + property;
        Logger.error(this, msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:com.haulmont.cuba.core.config.ConfigUtil.java

/**
 * Uncapitalize a string with support for leading acronyms. This
 * supports pretty uncapitalization of strings such as "URL" (to
 * "url") and "URLDecoder" (to "urlDecoder"). If a string begins with
 * a sequence of capital letters, all but the last are uncapitalized,
 * except in the case that the entire string is capitalized or the
 * capitals are followed by a non-letter, in which case all are
 * uncapitalized./*from w  w w. j  a va  2 s .  co m*/
 *
 * @param str The string.
 * @return The uncapitalized string.
 */
public static String extendedUncapitalize(String str) {
    // fooBar -> fooBar
    // FooBar -> fooBar
    // FOOBar -> fooBar
    // FOOBAR -> foobar
    // FOO8ar -> foo8ar
    int index = 0, length = str.length();
    while ((index < length) && Character.isUpperCase(str.charAt(index))
            && ((index == 0) || (index == length - 1) || !Character.isLowerCase(str.charAt(index + 1)))) {
        ++index;
    }
    return str.substring(0, index).toLowerCase() + str.substring(index);
}

From source file:org.gbif.portal.harvest.taxonomy.RegularExpressionToHybridTaxonName.java

/**
 * Parses the name based on the configuration
 * @param name To parse//  ww  w  .  j  a  v  a2  s  .com
 * @param parsedName to set the atomised parts on
 * @param suppliedRank rank supplied by caller - ignored by this class
 * @return boolean true if parsed or false if the reg ex doesn't match it
 */
public boolean parse(String name, TaxonName parsedName, Integer suppliedRank) {

    name = prepareName(name);

    // todo tidy...
    if (name == null) {
        return false;
    }

    int rank = 0;
    boolean genusLevel = true;

    StringTokenizer st = new StringTokenizer(name);
    for (int i = 0; st.hasMoreTokens(); i++) {
        String token = st.nextToken();

        if (token.equals("x") || token.equals("X") || token.equals("*") || token.equals("\u00D7")) {
            switch (i) {
            case 0:
                // x Aus
                rank = 6001;
                break;
            case 1:
                // Aus x bus
                if (st.hasMoreTokens() && Character.isLowerCase(st.nextToken().charAt(0))) {
                    rank = 7001;
                }
                // Aus x Bus
                else {
                    rank = 6001;
                }
                break;
            default:
                if (genusLevel) {
                    rank = 6001;
                } else if (name.indexOf(" f. ") > 0) {
                    rank = 8021;
                } else if (name.indexOf(" var. ") > 0) {
                    rank = 8011;
                } else if (name.indexOf(" subsp. ") > 0 || name.indexOf(" ssp. ") > 0
                        || name.indexOf(" sub. ") > 0) {
                    rank = 8001;
                } else {
                    // Aus bus x ...
                    rank = 7001;
                }
                break;
            }
            break;
        } else if (Character.isLowerCase(token.charAt(0))) {
            genusLevel = false;
        }
    }

    if (rank > 0) {
        parsedName.setRank(rank);
        parsedName.setCanonical(name);
        parsedName.setType(1);
    }

    return (rank > 0);
}

From source file:org.apache.velocity.runtime.parser.node.SetPropertyExecutor.java

/**
 * @param clazz//w  ww.j av  a  2s.c  om
 * @param property
 * @param arg
 */
protected void discover(final Class clazz, final String property, final Object arg) {
    Object[] params = new Object[] { arg };

    try {
        StrBuilder sb = new StrBuilder("set");
        sb.append(property);

        setMethod(introspector.getMethod(clazz, sb.toString(), params));

        if (!isAlive()) {
            /*
             *  now the convenience, flip the 1st character
             */

            char c = sb.charAt(3);

            if (Character.isLowerCase(c)) {
                sb.setCharAt(3, Character.toUpperCase(c));
            } else {
                sb.setCharAt(3, Character.toLowerCase(c));
            }

            setMethod(introspector.getMethod(clazz, sb.toString(), params));
        }
    }
    /**
     * pass through application level runtime exceptions
     */
    catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        String msg = "Exception while looking for property setter for '" + property;
        Logger.error(this, msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:bboss.org.apache.velocity.runtime.parser.node.SetPropertyExecutor.java

/**
 * @param clazz//from  w ww  .  j a v a  2  s. c om
 * @param property
 * @param arg
 */
protected void discover(final Class clazz, final String property, final Object arg) {
    Object[] params = new Object[] { arg };

    try {
        StrBuilder sb = new StrBuilder("set");
        sb.append(property);

        setMethod(introspector.getMethod(clazz, sb.toString(), params));

        if (!isAlive()) {
            /*
             *  now the convenience, flip the 1st character
             */

            char c = sb.charAt(3);

            if (Character.isLowerCase(c)) {
                sb.setCharAt(3, Character.toUpperCase(c));
            } else {
                sb.setCharAt(3, Character.toLowerCase(c));
            }

            setMethod(introspector.getMethod(clazz, sb.toString(), params));
        }
    }
    /**
     * pass through application level runtime exceptions
     */
    catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        String msg = "Exception while looking for property setter for '" + property;
        log.error(msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:com.iw.plugins.spindle.ui.wizards.fields.ComponentNameField.java

protected IStatus nameChanged() {
    SpindleStatus status = new SpindleStatus();
    String name = getTextValue();
    if ("".equals(name)) {
        status.setError("");
        return status;
    }//from w ww . ja v a 2s  .  co m
    if (name.indexOf('.') != -1) {
        status.setError(UIPlugin.getString(fName + ".error.QualifiedName"));
        return status;
    }

    IStatus val = JavaConventions.validateJavaTypeName(name);
    if (!val.isOK()) {
        if (val.getSeverity() == IStatus.ERROR) {
            String message = val.getMessage();
            message = StringUtils.replace(message, "type", "");
            status.setError(UIPlugin.getString(fName + ".error.InvalidComponentName", message));
            return status;
        } else if (val.getSeverity() == IStatus.WARNING) {
            String message = val.getMessage();
            message = StringUtils.replace(message, "Java", "Tapestry");
            message = StringUtils.replace(message, "type", "component/page");
            status.setWarning(UIPlugin.getString(fName + ".warning.ComponentNameDiscouraged", name, message));
            return status;
        }
    }
    char first = name.charAt(0);
    if (Character.isLowerCase(first)) {
        status.setWarning(UIPlugin.getString(fName + ".warning.ComponentNameDiscouraged",
                "first character is lowercase"));
    }

    return status;
}

From source file:annis.dao.autogenqueries.AutoSimpleRegexQuery.java

@Override
public void analyzingQuery(SaltProject saltProject) {

    List<String> tokens = new ArrayList<>();
    for (SCorpusGraph g : saltProject.getSCorpusGraphs()) {
        if (g != null) {
            for (SDocument doc : g.getSDocuments()) {
                SDocumentGraph docGraph = doc.getSDocumentGraph();
                EList<SNode> sNodes = docGraph.getSNodes();

                if (sNodes != null) {
                    for (SNode n : sNodes) {
                        if (n instanceof SToken) {
                            tokens.add(CommonHelper.getSpannedText((SToken) n));
                        }/*  www.j  a  v a 2 s.  c  o  m*/
                    }
                }
            }
        }
    }

    // try to find a word with which is contained twice with Capitalize letter.
    text = null;
    for (int i = 0; i < tokens.size(); i++) {
        for (int j = i + 1; j < tokens.size(); j++) {
            if (tokens.get(i).equalsIgnoreCase(tokens.get(j))) {

                if (tokens.get(i).length() > 1 && ((Character.isLowerCase(tokens.get(i).charAt(0))
                        && Character.isUpperCase(tokens.get(j).charAt(0)))
                        || (Character.isLowerCase(tokens.get(j).charAt(0))
                                && Character.isUpperCase(tokens.get(i).charAt(0))))) {
                    text = tokens.get(i);
                    break;
                }
            }
        }
    }

    if (text != null) {
        Character upperLetter = Character.toUpperCase(text.charAt(0));
        Character lowerLetter = Character.toLowerCase(text.charAt(0));
        String rest = StringUtils.substring(text, -(text.length() - 1));

        finalAQL = "/[" + upperLetter + lowerLetter + "]" + rest + "/";
    } else {
        // select one random token from the result
        int tries = 10;
        int r = new Random().nextInt(tokens.size() - 1);
        text = tokens.get(r);
        while ("".equals(text) && tries > 0) {
            r = new Random().nextInt(tokens.size() - 1);
            text = tokens.get(r);
            tries--;
        }

        if (!"".equals(text) && text.length() > 1) {
            Character upperLetter = Character.toUpperCase(text.charAt(0));
            Character lowerLetter = Character.toLowerCase(text.charAt(0));
            String rest = StringUtils.substring(text, -(text.length() - 1));

            finalAQL = "/[" + upperLetter + lowerLetter + "]" + rest + "/";
        } else {
            finalAQL = "";
        }
    }
}

From source file:bboss.org.apache.velocity.runtime.parser.node.PropertyExecutor.java

/**
 * @param clazz/*from w ww  .  jav a  2 s.  c  o  m*/
 * @param property
 */
protected void discover(final Class clazz, final String property) {
    /*
     *  this is gross and linear, but it keeps it straightforward.
     */

    try {
        Object[] params = {};

        StringBuffer sb = new StringBuffer("get");
        sb.append(property);

        setMethod(introspector.getMethod(clazz, sb.toString(), params));

        if (!isAlive()) {
            /*
             *  now the convenience, flip the 1st character
             */

            char c = sb.charAt(3);

            if (Character.isLowerCase(c)) {
                sb.setCharAt(3, Character.toUpperCase(c));
            } else {
                sb.setCharAt(3, Character.toLowerCase(c));
            }

            setMethod(introspector.getMethod(clazz, sb.toString(), params));
        }
    }
    /**
     * pass through application level runtime exceptions
     */
    catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        String msg = "Exception while looking for property getter for '" + property;
        log.error(msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:org.mule.devkit.generation.mule.studio.editor.MuleStudioUtils.java

public String formatDescription(String description) {
    if (Character.isLowerCase(description.charAt(0))) {
        description = StringUtils.capitalize(description);
    }// ww w . ja va 2 s .  co m
    if (!description.endsWith(".")) {
        description += '.';
    }
    return description.replaceAll("\\<.*?\\>", "");
}

From source file:com.slimsmart.common.util.code.EncodeUtil.java

public static String escape(String src) {
    int i;//from   ww w  . j  av  a2s. c  o m
    char j;
    StringBuffer tmp = new StringBuffer();
    tmp.ensureCapacity(src.length() * 6);

    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 < 256) {
            tmp.append("%");
            if (j < 16)
                tmp.append("0");
            tmp.append(Integer.toString(j, 16));
        } else {
            tmp.append("%u");
            tmp.append(Integer.toString(j, 16));
        }
    }
    return tmp.toString();
}