Example usage for java.lang Character toUpperCase

List of usage examples for java.lang Character toUpperCase

Introduction

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

Prototype

public static int toUpperCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to uppercase using case mapping information from the UnicodeData file.

Usage

From source file:jp.terasoluna.fw.util.StringUtil.java

/**
 * ?????//ww  w . ja  v  a2  s .c  om
 *
 * @param str ???
 * @return ??
 */
public static String capitalizeInitial(String str) {
    if (str == null || "".equals(str)) {
        return str;
    }
    char[] chars = str.toCharArray();
    chars[0] = Character.toUpperCase(chars[0]);
    return new String(chars);
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.login.LogInScreenPresenter.java

/**
 * Prueft ob es sich um einen gltigen Nachnamen handelt. Gibt "true" fuer
 * gltig und "false" fuer nicht gltig zurueck. Ein Nachname muss mit einem
 * Grobuchstaben beginnen und darf maximal 20 Zeichen lang sein. Beginnt er nicht mit einem Grobuchstabe,
 * wird der erste Buchstabe automatisch in einen Grobuchstabe konvertiert. Weiterhin
 * ist ein Bindestrich "-" erlaubt. Bei keiner Uebereinstimmung wird zudem
 * eine Fehlermeldung an die ViewImpl zur Ausgabe zurueckgegeben.
 * /*from   w  w w  .jav a 2 s. co m*/
 * @author Marcel Rosenberger, Annika Weis, Marco Glaser
 * @return Ob es sich um einen gltigen Nachnamen handelt.
 */
private boolean validateLastName() {
    boolean validLastName;

    // hier wird der Nachname berprft
    if (Pattern.matches("^[A-Z][a-zA-Z\\ \\-]{1,19}$", lastName)) {
        validLastName = true;
        logger.debug("Nachname gltig.");
    } else if (Pattern.matches("^[a-zA-Z\\ \\-]{1,19}$", lastName)) {
        validLastName = true;
        char firstLetter = lastName.charAt(0);
        firstLetter = Character.toUpperCase(firstLetter);
        String upperCaseName = firstLetter + lastName.substring(1);
        this.lastName = upperCaseName;
    } else {
        validLastName = false;
        getView().showErrorMessage("Bitte geben Sie einen gltigen Nachnamen ein.");
        logger.debug("Nachname ungltig.");
    }

    return validLastName;
}

From source file:com.cloudera.sqoop.orm.ClassWriter.java

/**
 * @param javaType/*w w w  .  java2s. c o m*/
 * @return the name of the method of JdbcWritableBridge to write an entry
 * with a given java type.
 */
private String dbSetterForType(String javaType) {
    // TODO(aaron): Lots of unit tests needed here.
    // See dbGetterForType() for the logic used here; it's basically the same.

    String[] parts = javaType.split("\\.");
    if (parts.length == 0) {
        LOG.error("No PreparedStatement Set method for Java type " + javaType);
        return null;
    }

    String lastPart = parts[parts.length - 1];
    try {
        String setter = "write" + Character.toUpperCase(lastPart.charAt(0)) + lastPart.substring(1);
        return setter;
    } catch (StringIndexOutOfBoundsException oob) {
        // lastPart.*() doesn't work on empty strings.
        LOG.error("Could not infer PreparedStatement setter for Java type " + javaType);
        return null;
    }
}

From source file:edu.wustl.bulkoperator.processor.AbstractBulkOperationProcessor.java

private void setContainmentObjectProperty(BulkOperationClass containmentMigrationClass, Object mainObject,
        String name, Collection valueToSet) throws Exception {
    /*/* w ww  .j  a v a2 s.c  om*/
     * This method is introduced to handle List type Containment assignment
     * Do not use getField() or getDeclaredField() to simplify the below processing
     * #1 getField() doesn't fetch private fields of class
     * #2 getDeclaredField() can fetch private fields of class, but can't fetch fields that are inherited from parent class
     */

    String getterMethod = "get" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
    Method method = mainObject.getClass().getMethod(getterMethod, null);

    if (List.class.getName().equals(method.getReturnType().getName())) {
        valueToSet = new ArrayList(valueToSet);
    }

    BeanUtils.setProperty(mainObject, name, valueToSet);
}

From source file:com.liveneo.plat.utils.StringUtil.java

/**
 * Capitalizes string//from   w  w w .j a va2  s.  co  m
 * 
 * @param s
 *            String to capitalize
 * @return Capitalized string
 */
public static String capitalize(String s) {
    if (s == null || s.length() == 0) {
        return s;
    }
    char[] chars = s.toCharArray();
    chars[0] = Character.toUpperCase(chars[0]);
    return String.valueOf(chars);
}

From source file:com.orion.plugin.Plugin.java

/**
 * Return the <tt>Plugin</tt> matching the given name
 * /*from   w w w . j  av  a 2  s. co m*/
 * @author Daniele Pantaleone
 * @param  name The <tt>Plugin</tt> name
 * @throws PluginNotFoundException If the <tt>Plugin</tt> is not loaded
 * @return The pre-initialized <tt>Plugin</tt> matching the given name
 **/
public Plugin getPlugin(String name) throws PluginNotFoundException {

    if (!this.plugins.containsKey(name))
        throw new PluginNotFoundException("Unable to find plugin [ " + Character.toUpperCase(name.charAt(0))
                + name.substring(1).toLowerCase() + " ]");

    return this.plugins.get(name);

}

From source file:fi.foyt.foursquare.api.JSONFieldParser.java

/**
 * Returns setter method for a field/*from  ww  w .j av  a  2 s  .c om*/
 * 
 * @param entityClass class
 * @param fieldName field
 * @return setter method for a field
 */
private static Method getSetterMethod(Class<?> entityClass, String fieldName) {
    StringBuilder methodNameBuilder = new StringBuilder();
    methodNameBuilder.append("set");
    methodNameBuilder.append(Character.toUpperCase(fieldName.charAt(0)));
    methodNameBuilder.append(fieldName.substring(1));

    String methodName = methodNameBuilder.toString();

    List<Method> methods = getMethods(entityClass);
    for (Method method : methods) {
        if (method.getName().equals(methodName)) {
            return method;
        }
    }

    return null;
}

From source file:com.lonepulse.zombielink.proxy.Zombie.java

/**
 * <p>Accepts an object and scans it for {@link Bite} annotations. If found, a <b>thread-safe proxy</b> 
 * for the endpoint interface will be injected.</p>
 * //w ww  .  j  a  va  2 s  .c om
 * <p>Injection targets will be searched up an inheritance hierarchy until a type is found which is 
 * <b>not</b> in a package whose name starts with the given package prefixes.</p>
 * <br>
 * <b>Usage:</b>
 * <br><br>
 * <ul>
 * <li>
 * <h5>Property Injection</h5>
 * <pre>
 * <code><b>@Bite</b>
 * private GitHubEndpoint gitHubEndpoint;
 * {
 * &nbsp; &nbsp; Zombie.infect(Arrays.asList("com.example.service", "com.example.manager"), this);
 * }
 * </code>
 * </pre>
 * </li>
 * <li>
 * <h5>Setter Injection</h5>
 * <pre>
 * <code><b>@Bite</b>
 * private GitHubEndpoint gitHubEndpoint;
 * {
 * &nbsp; &nbsp; Zombie.infect(Arrays.asList("com.example.service", "com.example.manager"), this);
 * }
 * </code>
 * <code>
 * public void setGitHubEndpoint(GitHubEndpoint gitHubEndpoint) {
 * 
 * &nbsp; &nbsp; this.gitHubEndpoint = gitHubEndpoint;
 * }
 * </code>
 * </pre>
 * </li>
 * </ul>
 * 
 * @param packagePrefixes
 *          the prefixes of packages to restrict hierarchical lookup of injection targets; if {@code null} 
 *          or {@code empty}, {@link #infect(Object, Object...)} will be used
 * <br><br>
 * @param victim
 *          an object with endpoint references marked to be <i>bitten</i> and infected 
 * <br><br>
 * @param moreVictims
 *          more unsuspecting objects with endpoint references to be infected
 * <br><br>
 * @throws NullPointerException
 *          if the object supplied for endpoint injection is {@code null} 
 * <br><br>
 * @since 1.3.0
 */
public static void infect(List<String> packagePrefixes, Object victim, Object... moreVictims) {

    assertNotNull(victim);

    List<Object> injectees = new ArrayList<Object>();
    injectees.add(victim);

    if (moreVictims != null && moreVictims.length > 0) {

        injectees.addAll(Arrays.asList(moreVictims));
    }

    Class<?> endpointInterface = null;

    for (Object injectee : injectees) {

        Class<?> type = injectee.getClass();

        do {

            for (Field field : Fields.in(type).annotatedWith(Bite.class)) {

                try {

                    endpointInterface = field.getType();
                    Object proxyInstance = EndpointProxyFactory.INSTANCE.create(endpointInterface);

                    try { //1.Simple Field Injection 

                        field.set(injectee, proxyInstance);
                    } catch (IllegalAccessException iae) { //2.Setter Injection 

                        String fieldName = field.getName();
                        String mutatorName = "set" + Character.toUpperCase(fieldName.charAt(0))
                                + fieldName.substring(1);

                        try {

                            Method mutator = injectee.getClass().getDeclaredMethod(mutatorName,
                                    endpointInterface);
                            mutator.invoke(injectee, proxyInstance);
                        } catch (NoSuchMethodException nsme) { //3.Forced Field Injection

                            field.setAccessible(true);
                            field.set(injectee, proxyInstance);
                        }
                    }
                } catch (Exception e) {

                    Logger.getLogger(Zombie.class.getName()).log(Level.SEVERE,
                            new StringBuilder().append("Failed to inject the endpoint proxy instance of type ")
                                    .append(endpointInterface.getName()).append(" on property ")
                                    .append(field.getName()).append(" at ")
                                    .append(injectee.getClass().getName()).append(". ").toString(),
                            e);
                }
            }

            type = type.getSuperclass();
        } while (!hierarchyTerminal(type, packagePrefixes));
    }
}

From source file:com.madrobot.di.wizard.json.JSONDeserializer.java

private String getSetMethodName(final String fieldName, final Class<?> classType) {
    String methodName = null;// w w  w . j  a v a2s.c o  m
    if (Converter.isBoolean(classType) && fieldName.startsWith("is")) {
        methodName = "set" + Character.toUpperCase(fieldName.charAt(2)) + fieldName.substring(3);
    } else {
        methodName = "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
    }
    return methodName;
}

From source file:de.hybris.platform.test.CaseInsensitiveStringMapTest.java

private List<String> shuffleCase(final List<String> keys) {
    final List<String> shuffled = new ArrayList<String>(keys.size());
    for (final String key : keys) {
        final char[] chars = key.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            final char character = chars[i];
            if (Character.isUpperCase(character)) {
                chars[i] = Character.toLowerCase(character);
            } else if (Character.isLowerCase(character)) {
                chars[i] = Character.toUpperCase(character);
            }//from  ww  w  .  j  a  v a  2s. c om
            shuffled.add(new String(chars));
        }
    }
    return shuffled;
}