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:de.tuberlin.uebb.jbop.optimizer.ClassNodeBuilder.java

/**
 * Creates a getter for the last added field.
 * // ww  w  . j a va 2  s. c o  m
 * @return the class node builder
 */
public ClassNodeBuilder withGetter() {
    if (isInterface) {
        return this;
    }
    final String name = lastField.name;
    final String desc = lastField.desc;
    addMethod("get" + Character.toUpperCase(name.charAt(0)) + name.substring(1), "()" + desc);
    final Type type = Type.getType(desc);
    addInsn(new VarInsnNode(Opcodes.ALOAD, 0));
    addInsn(new FieldInsnNode(Opcodes.GETFIELD, classNode.name, name, desc));
    addInsn(new InsnNode(type.getOpcode(Opcodes.IRETURN)));
    return this;
}

From source file:gov.nih.nci.cananolab.util.StringUtils.java

/**
 * Convert to upper case the first letter of each word in the input. Spaces are preserved.
 * @param strWithWords/*from  w  w  w  . j  av a2 s  .  c  o  m*/
 * @return
 */
public static String getCamelCaseFormatInWords(String strWithWords) {
    if (strWithWords == null)
        return strWithWords;

    String[] words = strWithWords.split(" ");
    StringBuilder sb = new StringBuilder();
    for (String word : words) {
        char first = word.charAt(0);
        String upper = word.replaceFirst(String.valueOf(first), String.valueOf(Character.toUpperCase(first)));
        sb.append(upper).append(" ");
    }

    return sb.toString().trim();
}

From source file:net.sf.jabref.bst.BibtexCaseChanger.java

private int convertCharIfBraceLevelIsZero(char[] c, int start, StringBuilder sb, FORMAT_MODE format) {
    int i = start;
    switch (format) {
    case TITLE_LOWERS:
        if ((i == 0) || (prevColon && Character.isWhitespace(c[i - 1]))) {
            sb.append(c[i]);//  www .  j a v  a 2  s . c om
        } else {
            sb.append(Character.toLowerCase(c[i]));
        }
        if (c[i] == ':') {
            prevColon = true;
        } else if (!Character.isWhitespace(c[i])) {
            prevColon = false;
        }
        break;
    case ALL_LOWERS:
        sb.append(Character.toLowerCase(c[i]));
        break;
    case ALL_UPPERS:
        sb.append(Character.toUpperCase(c[i]));
        break;
    default:
        LOGGER.info("convertCharIfBraceLevelIsZero - Unknown format: " + format);
        break;
    }
    i++;
    return i;
}

From source file:com.insprise.common.lang.StringUtilities.java

/**
  * Capitalize the first letter letter to upper case, no other characters will be changed.
  * @param s the string to be capitalized.
  * @return the string with first letter upper-cased.
  *///from   w  w w. j a  v  a2s .c  o  m
 public static String capitalizeWord(String s) {
     if (s == null || s.length() == 0) {
         return s;
     }
     char[] chars = s.toCharArray();
     chars[0] = Character.toUpperCase(chars[0]);
     return new String(chars);
 }

From source file:com.jigsforjava.string.StringUtils.java

public static String toCamelCase(String stringValue, String delimiter) {
    StringBuffer result = new StringBuffer(stringValue.length());
    String[] strings = parseString(stringValue.toLowerCase(), delimiter);

    for (int i = 0; i < strings.length; ++i) {
        char[] characters = strings[i].toCharArray();

        if (characters.length > 0) {
            characters[0] = Character.toUpperCase(characters[0]);
            result.append(characters);/*from  w  w  w  .  j  av  a  2s  .  c o  m*/
        }
    }

    return result.toString();
}

From source file:com.tecapro.inventory.common.util.BeanUtil.java

/**
 * Perform setter method (java reflection) on bean object with parameter is Value
 * //from www. j  a  va 2s .  c  o  m
 * @param bean
 * @param propertyName
 * @param value
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
public void setBean(Object bean, String propertyName, Object value)
        throws IllegalAccessException, InvocationTargetException {

    String setMethodName = new StringBuffer().append("set")
            .append(Character.toUpperCase(propertyName.charAt(0)))
            .append(propertyName.length() > 1 ? propertyName.substring(1) : "").toString();
    Object[] args = new Object[] { value };

    for (Method method : bean.getClass().getMethods()) {
        if (method.getName().equals(setMethodName) && method.getParameterTypes().length == 1) {
            method.invoke(bean, args);
        }
    }
}

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

/**
 * @param javaType// w  ww .  j  a  v a 2 s.c  o  m
 * @return the name of the method of JdbcWritableBridge to read an entry
 * with a given java type.
 */
private String dbGetterForType(String javaType) {
    // All Class-based types (e.g., java.math.BigDecimal) are handled with
    // "readBar" where some.package.foo.Bar is the canonical class name.  Turn
    // the javaType string into the getter type string.

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

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

From source file:fr.inria.atlanmod.neoemf.data.blueprints.BlueprintsPersistenceBackendFactory.java

private PropertiesConfiguration getOrCreateBlueprintsConfiguration(File directory, Map<?, ?> options)
        throws InvalidDataStoreException {
    PropertiesConfiguration configuration;

    // Try to load previous configurations
    Path path = Paths.get(directory.getAbsolutePath()).resolve(BLUEPRINTS_CONFIG_FILE);
    try {//  ww  w.j  ava  2s.c  om
        configuration = new PropertiesConfiguration(path.toFile());
    } catch (ConfigurationException e) {
        throw new InvalidDataStoreException(e);
    }

    // Initialize value if the config file has just been created
    if (!configuration.containsKey(BlueprintsResourceOptions.GRAPH_TYPE)) {
        configuration.setProperty(BlueprintsResourceOptions.GRAPH_TYPE,
                BlueprintsResourceOptions.GRAPH_TYPE_DEFAULT);
    } else if (options.containsKey(BlueprintsResourceOptions.GRAPH_TYPE)) {
        // The file already existed, check that the issued options are not conflictive
        String savedGraphType = configuration.getString(BlueprintsResourceOptions.GRAPH_TYPE);
        String issuedGraphType = options.get(BlueprintsResourceOptions.GRAPH_TYPE).toString();
        if (!Objects.equals(savedGraphType, issuedGraphType)) {
            NeoLogger.error("Unable to create graph as type {0}, expected graph type was {1})", issuedGraphType,
                    savedGraphType);
            throw new InvalidDataStoreException("Unable to create graph as type " + issuedGraphType
                    + ", expected graph type was " + savedGraphType + ')');
        }
    }

    // Copy the options to the configuration
    for (Entry<?, ?> e : options.entrySet()) {
        configuration.setProperty(e.getKey().toString(), e.getValue().toString());
    }

    // Check we have a valid graph type, it is needed to get the graph name
    String graphType = configuration.getString(BlueprintsResourceOptions.GRAPH_TYPE);
    if (isNull(graphType)) {
        throw new InvalidDataStoreException("Graph type is undefined for " + directory.getAbsolutePath());
    }

    // Define the configuration
    String[] segments = graphType.split("\\.");
    if (segments.length >= 2) {
        String graphName = segments[segments.length - 2];
        String upperCaseGraphName = Character.toUpperCase(graphName.charAt(0)) + graphName.substring(1);
        String configClassName = MessageFormat.format("InternalBlueprints{0}Configuration", upperCaseGraphName);
        String configClassQualifiedName = MessageFormat
                .format("fr.inria.atlanmod.neoemf.data.blueprints.{0}.config.{1}", graphName, configClassName);

        try {
            ClassLoader classLoader = BlueprintsPersistenceBackendFactory.class.getClassLoader();
            Class<?> configClass = classLoader.loadClass(configClassQualifiedName);
            Method configClassInstanceMethod = configClass.getMethod("getInstance");
            InternalBlueprintsConfiguration blueprintsConfig = (InternalBlueprintsConfiguration) configClassInstanceMethod
                    .invoke(configClass);
            blueprintsConfig.putDefaultConfiguration(configuration, directory);
        } catch (ClassNotFoundException e) {
            NeoLogger.warn(e, "Unable to find the configuration class {0}", configClassQualifiedName);
        } catch (NoSuchMethodException e) {
            NeoLogger.warn(e, "Unable to find configuration methods in class {0}", configClassName);
        } catch (InvocationTargetException | IllegalAccessException e) {
            NeoLogger.warn(e, "An error occurs during the execution of a configuration method");
        }
    } else {
        NeoLogger.warn("Unable to compute graph type name from {0}", graphType);
    }

    return configuration;
}

From source file:hydrograph.ui.expression.editor.sourceviewer.SourceViewer.java

private void handleVerifyKeyPressed(VerifyEvent event) {
    if (!event.doit) {
        return;/*  w w  w . j a v  a  2s. co  m*/
    }
    try {
        KeyStroke triggerKeyStroke = HotKeyUtil.getHotKey(HotKeyUtil.contentAssist);
        if (triggerKeyStroke != null) {

            if ((triggerKeyStroke.getModifierKeys() == KeyStroke.NO_KEY
                    && triggerKeyStroke.getNaturalKey() == event.character)
                    || (((triggerKeyStroke.getNaturalKey() == event.keyCode)
                            || (Character.toLowerCase(triggerKeyStroke.getNaturalKey()) == event.keyCode)
                            || (Character.toUpperCase(triggerKeyStroke.getNaturalKey()) == event.keyCode))
                            && ((triggerKeyStroke.getModifierKeys() & event.stateMask) == triggerKeyStroke
                                    .getModifierKeys()))) {

                doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                event.doit = false;
                return;
            }
        }
    } catch (Exception e) {
    }

    if (event.stateMask != SWT.CTRL) {
        return;
    }

    switch (event.character) {
    case ' ':
        doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
        event.doit = false;
        break;

    case '.':
        doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
        event.doit = false;
        break;
    case 'y' - 'a' + 1:
        doOperation(ITextOperationTarget.REDO);
        event.doit = false;
        break;
    case 'z' - 'a' + 1:
        doOperation(ITextOperationTarget.UNDO);
        event.doit = false;
        break;
    default:
    }
}

From source file:com.rabbitframework.commons.utils.StringUtils.java

/**
 * _,-,@,$,#,' ',/,&?//from   ww w .j  av a  2  s .co  m
 * <p/>
 * :hello_world ?helloWorld
 *
 * @param inputString
 * @param firstCharacterUppercase
 *            ??
 * @return
 */
public static String toCamelCase(String inputString, boolean firstCharacterUppercase) {
    StringBuilder sb = new StringBuilder();
    boolean nextUpperCase = false;
    for (int i = 0; i < inputString.length(); i++) {
        char c = inputString.charAt(i);
        switch (c) {
        case '_':
        case '-':
        case '@':
        case '$':
        case '#':
        case ' ':
        case '/':
        case '&':
            if (sb.length() > 0) {
                nextUpperCase = true;
            }
            break;
        default:
            if (nextUpperCase) {
                sb.append(Character.toUpperCase(c));
                nextUpperCase = false;
            } else {
                sb.append(Character.toLowerCase(c));
            }
            break;
        }
    }

    if (firstCharacterUppercase) {
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    }

    return sb.toString();
}