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:org.eclipse.jubula.rc.swt.driver.RobotSwtImpl.java

/**
 * @param character/*ww w.  ja va2 s.com*/
 *            the character
 * @return the "corrected" character, e.g. for Mac OS X it has to be in
 *         lower case
 */
private static char getOSSspecificSpecBaseCharacter(char character) {
    if (EnvironmentUtils.isMacOS() && Character.isUpperCase(character)) {
        return Character.toLowerCase(character);
    }
    return character;
}

From source file:com.ng.mats.psa.mt.paga.data.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. j a  v a2s . co m
            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:lucee.commons.lang.StringUtil.java

/**
 * returns true if the input string has letters and they are all UPPERCASE
 *
 * @param str//from   ww w  .j av  a  2  s  . c  o  m
 * @return
 */
public static boolean isAllUpperCase(String str) {

    if (str == null)
        return false;

    boolean hasLetters = false;
    char c;

    for (int i = str.length() - 1; i >= 0; i--) {

        c = str.charAt(i);
        if (Character.isLetter(c)) {

            if (!Character.isUpperCase(c))
                return false;

            hasLetters = true;
        }
    }

    return hasLetters;
}

From source file:mil.army.usace.data.dataquery.rdbms.RdbmsDataQuery.java

public String getDbName(String attributeName) {
    String fieldName = "";
    for (int i = 0; i < attributeName.length(); i++) {
        if (i == 0)
            fieldName += Character.toLowerCase(attributeName.charAt(i));
        else {//from w w  w .  j a  va  2 s  .  co m
            char c = attributeName.charAt(i);
            if (Character.isUpperCase(c))
                fieldName += "_" + Character.toLowerCase(c);
            else
                fieldName += c;
        }
    }
    return fieldName;
}

From source file:com.glaf.core.util.StringTools.java

public static String toUnderLineName(String s) {
    if (s == null) {
        return null;
    }/*from  w  ww.ja  va  2  s .c  o  m*/

    StringBuilder sb = new StringBuilder();
    boolean upperCase = false;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);

        boolean nextUpperCase = true;

        if (i < (s.length() - 1)) {
            nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
        }

        if ((i >= 0) && Character.isUpperCase(c)) {
            if (!upperCase || !nextUpperCase) {
                if (i > 0)
                    sb.append(SEPARATOR);
            }
            upperCase = true;
        } else {
            upperCase = false;
        }

        sb.append(Character.toLowerCase(c));
    }

    return sb.toString();
}

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

@Override
public void visit(final MethodCallExpr n, final Object arg) {
    printJavaComment(n.getComment(), arg);
    if (n.getScope() != null) {
        n.getScope().accept(this, arg);
        if (Character.isUpperCase(n.getScope().toString().charAt(0)))
            printer.print("::");
        else/*from w w  w  .  j a v a  2s  .co m*/
            printer.print(".");
    }
    printTypeArgs(n.getTypeArgs(), arg);
    if (n.getScope() == null) {
        Optional<Pair<TypeDescription, Node>> decl = idTracker.findDeclarationNodeFor(n.getName(), n);
        if (decl.isPresent()) {
            Node declNode = decl.get().getRight();
            if (declNode != null) {
                if (declNode instanceof MethodDeclaration) {
                    MethodDeclaration methodDeclaration = (MethodDeclaration) declNode;
                    if (!ModifierSet.isStatic(methodDeclaration.getModifiers()))
                        printer.print("self.");
                    else
                        printer.print("::");
                } else {
                    printer.print("self.");
                }
            }
        }
    }
    printer.print(toSnakeIfNecessary(n.getName()));
    printArguments(n.getArgs(), arg);
}

From source file:com.prowidesoftware.swift.model.field.Field.java

/**
 * Returns true if the field name is valid. 
 * Valid field names are for example: 20, 20C, 108
 * @param name a field name to validate//from w w w  . j a v  a 2  s. com
 * @return true if valid, false otherwise
 * @since 7.8
 */
public static boolean validName(final String name) {
    if (name == null) {
        return false;
    }
    if (name.length() < 2 || name.length() > 3) {
        //log.warning("field name must be present and have 2 or 3 characters length and found: "+field);
        return false;
    }
    if (!StringUtils.isNumeric(name.substring(0, 2))) {
        //log.warning("field name should start with a numeric prefix and found: "+field.substring(0, 2));
        return false;
    }
    if ((name.length() == 3 && !(Character.isDigit(name.charAt(2)) || name.charAt(2) == 'a'
            || Character.isUpperCase(name.charAt(2))))) {
        //log.warning("letter option if present should be a single capital letter or an 'a' for all letter options, and found: "+field.charAt(2));
        return false;
    }
    return true;
}

From source file:co.id.app.sys.util.StringUtils.java

/**
 * Return a field label string from the given field name. For example:
 * <pre class="codeHtml">//from   w  w w  .  j a v a  2 s  . co  m
 * <span class="blue">faxNumber</span> &nbsp; -&gt; &nbsp; <span class="red">Fax Number</span> </pre>
 *
 * @param name the field name
 * @return a field label string from the given field name
 */
public static String toLabel(String name) {
    if (name == null) {
        throw new IllegalArgumentException("Null name parameter");
    }

    HtmlStringBuffer buffer = new HtmlStringBuffer();

    for (int i = 0, size = name.length(); i < size; i++) {
        char aChar = name.charAt(i);

        if (i == 0) {
            buffer.append(Character.toUpperCase(aChar));

        } else {
            buffer.append(aChar);

            if (i < name.length() - 1) {
                char nextChar = name.charAt(i + 1);
                if (Character.isLowerCase(aChar)
                        && (Character.isUpperCase(nextChar) || Character.isDigit(nextChar))) {
                    buffer.append(" ");
                }
            }
        }
    }

    return buffer.toString();
}

From source file:io.fabric8.kubernetes.api.KubernetesHelper.java

/**
 * Validates that the given value is valid according to the kubernetes ID parsing rules, throwing an exception if not.
 *//*from  ww  w .  j a va2s .c  om*/
public static String validateKubernetesId(String currentValue, String description)
        throws IllegalArgumentException {
    if (isNullOrBlank(currentValue)) {
        throw new IllegalArgumentException("No " + description + " is specified!");
    }
    int size = currentValue.length();
    for (int i = 0; i < size; i++) {
        char ch = currentValue.charAt(i);
        if (Character.isUpperCase(ch)) {
            throw new IllegalArgumentException("Invalid upper case letter '" + Character.valueOf(ch)
                    + "' at index " + i + " for " + description + " value: " + currentValue);
        }
    }
    return currentValue;
}

From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java

protected String buildHqlPageOrderClause(WGPageOrderSet order, Map<String, Object> params)
        throws WGAPIException {

    List<String> hqlTerms = new ArrayList<String>();
    WGDocumentImpl langDoc = null;/*from  www .  j ava 2s .c  om*/
    String contentLanguage = order.getContentLanguage();
    if (contentLanguage == null) {
        contentLanguage = _db.getDefaultLanguage();
    }

    langDoc = (WGDocumentImpl) getDesignObject(WGDocument.TYPE_LANGUAGE, contentLanguage, null);
    if (langDoc == null) {
        throw new WGIllegalArgumentException("Undefined language: " + contentLanguage);
    }

    int itemNameIdx = 0;
    for (WGColumnSet.Term term : order.getTerms()) {

        String clause = null;

        if (Character.isUpperCase(term.getName().charAt(0))) {

            StringBuffer clauseTerm = new StringBuffer();

            WGColumnSet.ColumnMeta columnMeta = WGColumnSet.COLUMN_METAS.get(term.getName());
            if (columnMeta == null) {
                throw new WGIllegalArgumentException("Unknown column meta name: " + term.getName());
            }
            for (Class<? extends WGDocument> loc : columnMeta.getLocations()) {
                if (loc == WGStructEntry.class) {
                    clauseTerm.append("struct");
                } else if (loc == WGContent.class) {
                    params.put("langentity", langDoc.getEntity());
                    clauseTerm.append("struct.releasedcontent[:langentity]");
                } else if (loc == WGContentType.class) {
                    clauseTerm.append("struct.contenttype");
                } else if (loc == WGLanguage.class) {
                    params.put("langentity", langDoc.getEntity());
                    clauseTerm.append("struct.releasedcontent[:langentity].language");
                } else {
                    continue;
                }

                clauseTerm.append(".").append(columnMeta.getMetaName().toLowerCase());

                // Metas with special data structures
                if (loc == WGStructEntry.class && term.getName().equals("PAGEPUBLISHED")) {
                    params.put("lang", contentLanguage);
                    clauseTerm.append("[:lang]");
                }

                clause = clauseTerm.toString();
                break;

            }

        } else {
            itemNameIdx++;
            params.put("itemname" + itemNameIdx, term.getName());
            String property = term.getFlags().containsKey("type") ? term.getFlags().get("type") : "text";
            params.put("langentity", langDoc.getEntity());
            clause = "struct.releasedcontent[:langentity].items[:itemname" + itemNameIdx + "]." + property;
        }

        if (clause != null) {
            if ("true".equals(term.getFlags().get("ci"))) {
                clause = "lower(" + clause + ")";
            }
            if ("true".equals(term.getFlags().get("desc"))) {
                clause += " desc";
            } else {
                clause += " asc";
            }
            hqlTerms.add(clause);
        }

    }
    String completeClause = WGUtils.serializeCollection(hqlTerms, ", ");
    return completeClause;

}