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:com.katamaditya.apps.weather4u.weathersync.Weather4USyncAdapter.java

private String getTitle() {
    String title = WeatherUtil.getPreferredLocation(getContext());
    if (title != null) {
        title = title.trim();//www  .  ja  va 2s  .c  o m
        if (title.contains(",")) {
            String temp[] = title.split(",");
            Character c = temp[0].charAt(0);
            c = Character.toUpperCase(c);
            temp[0] = temp[0].replaceFirst(temp[0].substring(0, 1), c.toString());
            temp[1] = temp[1].toUpperCase();
            title = temp[0] + ", " + temp[1];
        }
        return getContext().getString(R.string.app_name) + " - " + title;
    }
    return getContext().getString(R.string.app_name);
}

From source file:com.btisystems.pronx.ems.AbstractMibCompiler.java

/**
 * Capitalise first character of the specified name.
 *
 * @param name the name//from   w w w.  j a va 2  s  .  co  m
 * @return the string
 */
protected final String capitalizeFirstCharacter(final String name) {
    final StringBuilder sb = new StringBuilder(name);
    final char firstChar = sb.charAt(0);
    sb.setCharAt(0, Character.toUpperCase(firstChar));
    return sb.toString();
}

From source file:org.fhcrc.cpl.viewer.gui.ProteinMatcherFrame.java

/**
 * Narrow down the displayed proteins, and remove protein and peptide selections
 *//*from w  w  w.j  av  a  2s. c o m*/
protected void filterDisplayedProteins() {
    if ("".equals(_proteinFilterString))
        _displayedProteins = _matchedProteins;
    else {
        String regexString = _proteinFilterString.toUpperCase();
        //System.err.println("Before: " +regexString);
        //wildcards
        if (_proteinFilterString.contains("*")) {
            StringBuffer regexBuf = new StringBuffer();
            for (int i = 0; i < _proteinFilterString.length(); i++) {
                char currentChar = _proteinFilterString.charAt(i);
                if (currentChar == '*') {
                    regexBuf.append(".*");
                } else
                    regexBuf.append(Character.toUpperCase(currentChar));
            }
            regexString = regexBuf.toString();
        }
        //System.err.println("after: " +regexString);

        _displayedProteins = new ArrayList<Protein>();

        for (Protein protein : _matchedProteins) {
            String currentHeader = protein.getHeader();
            if (currentHeader.toUpperCase().matches(regexString)) {
                _displayedProteins.add(protein);
            }
        }
        updateDisplayedProteins();

        //clear out dependent fields
        proteinLabel.setText("");
        _displayedFeatures = new ArrayList<Feature>(0);
        _featureTableModel.setDisplayedFeatures(_displayedFeatures);
    }
}

From source file:com.cinchapi.concourse.util.ConvertTest.java

/**
 * Randomly flip the case of all the characters in {@code string}.
 * /* w  w  w  .  j  ava2s . c o m*/
 * @param string
 * @return the case scrambled string
 */
private String scrambleCase(String string) {
    char[] chars = string.toCharArray();
    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];
        if (Random.getInt() % 2 == 0) {
            c = Character.toLowerCase(c);
        } else {
            c = Character.toUpperCase(c);
        }
        chars[i] = c;
    }
    return new String(chars);
}

From source file:cn.fql.utility.StringUtility.java

/**
 * Recover a illegal string represents a property name of POJO. Convert it to a legal name.
 *
 * @param illegalPropertyName illegal property name
 * @return legal property name/* w w  w  .j a v  a 2s. c o m*/
 */
public static String recoverIllegalPropertyName(String illegalPropertyName) {
    String _iPropertyName = StringUtility.replaceNull(illegalPropertyName);
    if (illegalPropertyName.indexOf(" ") != -1 || illegalPropertyName.indexOf("_") != -1
            || illegalPropertyName.indexOf("-") != -1) {
        char[] charArray = _iPropertyName.toCharArray();
        char[] legalCharArray = new char[charArray.length];
        int emptyCount = 0;
        for (int i = 0; i < charArray.length; i++) {
            char c = charArray[i];
            if (c == '_' || c == '-' || c == ' ') {
                if (i < charArray.length - 1) {
                    legalCharArray[i] = ' ';
                    legalCharArray[i + 1] = Character.toUpperCase(charArray[i + 1]);
                    i++;
                    emptyCount++;
                }
            } else {
                legalCharArray[i] = c;
            }
        }
        char[] _result = new char[legalCharArray.length - emptyCount];
        for (int i = 0, index = 0; i < legalCharArray.length; i++) {
            char c = legalCharArray[i];
            if (c != ' ') {
                _result[index] = c;
                index++;
            }
        }
        _iPropertyName = String.valueOf(_result);
    }
    return _iPropertyName;
}

From source file:com.google.api.server.spi.config.jsonwriter.JsonConfigWriter.java

/**
 * Adds a schema for a type into an output node. For arrays, this generates nested schemas inline
 * for however many dimensions are necessary.
 *
 * @return an appropriate name for the schema if one isn't already assigned
 *//*from  w  ww. j  av  a  2 s  .co m*/
private String addTypeToNode(ObjectNode schemasNode, TypeToken<?> type, TypeToken<?> enclosingType,
        ObjectNode node, ApiConfig apiConfig, List<ApiParameterConfig> parameterConfigs)
        throws ApiConfigException {
    TypeToken<?> itemType = Types.getArrayItemType(type);

    if (typeLoader.isSchemaType(type)) {
        String basicTypeName = typeLoader.getSchemaType(type);
        addElementTypeToNode(schemasNode, type, basicTypeName, node, apiConfig);
        return basicTypeName;
    } else if (itemType != null) {
        ObjectNode items = objectMapper.createObjectNode();
        node.put("type", "array");
        node.set(Constant.ITEMS, items);

        String itemTypeName = addTypeToNode(schemasNode, itemType, enclosingType, items, apiConfig,
                parameterConfigs);
        String arraySuffix = "Collection";
        StringBuilder sb = new StringBuilder(itemTypeName.length() + arraySuffix.length());
        sb.append(itemTypeName).append(arraySuffix);
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        return sb.toString();
    } else if (type instanceof TypeVariable) {
        throw new IllegalArgumentException(String.format("Object type %s not supported.", type));
    } else {
        String typeName = addTypeToSchema(schemasNode, type, enclosingType, apiConfig, parameterConfigs);
        addElementTypeToNode(schemasNode, type, typeName, node, apiConfig);
        return typeName;
    }
}

From source file:com.adito.boot.Util.java

/**
 * Turn a constant name into an english like phrase. E.g. <i>HTTP_ERROR</i>
 * would be turned into <i>Http Error</i>.
 * //from   w  w w.j a va  2 s . c  o m
 * @param constant constant name
 * @return readable name
 */
public static String makeConstantReadable(String constant) {
    StringBuffer buf = new StringBuffer();
    char ch;
    boolean firstChar = true;
    for (int i = 0; i < constant.length(); i++) {
        ch = constant.charAt(i);
        if (ch == '_') {
            ch = ' ';
            firstChar = true;
        } else {
            if (firstChar) {
                ch = Character.toUpperCase(ch);
                firstChar = false;
            } else {
                ch = Character.toLowerCase(ch);
            }
        }
        buf.append(ch);
    }
    return buf.toString();
}

From source file:org.gvnix.service.roo.addon.addon.util.WsdlParserUtils.java

/**
 * Converts a wsdl name to a valid Java format in Document.
 * <p>//from  w ww . ja  va 2 s . com
 * Valid chars are letters, numbers and $. '-', '_', ':' and '.' chars are
 * replaced with none. Other chars are replaced by unicode value with format
 * "_002f". New words in name always will be start by uppercase.
 * </p>
 * 
 * @param name A wsdl name
 * @return Valid java name
 */
private static String convertDocumentNameToJavaFormat(String name) {

    Validate.notNull(name, "Name required");

    StringBuffer ostr = new StringBuffer();

    // First character, uppercase
    boolean upper = true;
    for (int i = 0; i < name.length(); i++) {

        char ch = name.charAt(i);

        // Letter, number or $
        if ((ch >= 'a') && (ch <= 'z') || (ch >= 'A') && (ch <= 'Z') || (ch >= '0') && (ch <= '9')
                || ch == '$') {

            if (upper) {

                ostr.append(Character.toUpperCase(ch));

            } else {

                ostr.append(ch);
            }

            if ((ch >= '0') && (ch <= '9') || ch == '$') {

                // Next character to number or $ will be uppercase
                upper = true;

            } else {

                upper = false;
            }
        } else {

            // Next characters will be replace by none, others to Unicode
            if (ch != '-' && ch != '_' && ch != ':' && ch != '.') {

                // Unicode prefix
                ostr.append("_");

                // Unicode value
                String hex = Integer.toHexString(name.charAt(i) & 0xFFFF);
                for (int j = 0; j < 4 - hex.length(); j++) {

                    // Prepend zeros because unicode requires 4 digits
                    ostr.append("0");
                }

                // Standard unicode format
                ostr.append(hex.toLowerCase());
            }

            // Next character will be uppercase
            upper = true;
        }
    }

    return (new String(ostr));
}

From source file:com.adito.boot.Util.java

/**
 * Turn a key into an english like phrase. E.g. <i>webForwardURL</i>
 * would be turned into <i>Web Forward URL</i>.
 * //from  ww  w. j av a2s  .  c  o m
 * @param constant constant name
 * @return readable name
 */
public static String makeKeyReadable(String constant) {
    // vFSPath
    StringBuffer buf = new StringBuffer();
    char ch;
    char lastChar = 0;
    for (int i = 0; i < constant.length(); i++) {
        ch = constant.charAt(i);
        if (i == 0) {
            ch = Character.toUpperCase(ch);
        } else {
            if (Character.isUpperCase(ch)) {
                if (!Character.isUpperCase(lastChar)) {
                    buf.append(" ");
                }
            }
        }
        buf.append(ch);
        lastChar = ch;
    }
    return buf.toString();
}

From source file:com.legstar.cob2xsd.XsdDataItem.java

/**
 * Turn a COBOL name to an XSD element name.
 * <p/>/*from  ww  w  . jav  a2s .c o  m*/
 * COBOL names look ugly in XML schema. They are often uppercased and use
 * hyphens extensively. XML schema names they will have to be transformed
 * later to java identifiers so we try to get as close as possible to a
 * naming convention that suits XML Schema as well as Java.
 * <p>
 * So we remove hyphens. We lower case all characters which are not word
 * breakers. Word breakers are hyphens and numerics. This creates Camel
 * style names. Element names customarily start with a lowercase character.
 * <p/>
 * COBOL FILLERs are a particular case because there might be more than one
 * in the same parent group. So what we do is systematically append the
 * COBOL source line number so that these become unique names.
 * <p/>
 * COBOL names can start with a digit which is illegal for XML element
 * names. In this case we prepend a "C" character.
 * <p/>
 * Since Enterprise COBOL V4R1, underscores can be used (apart from first
 * character). We treat them as hyphens here, they are not propagated to the
 * XSD name but are used as word breakers.
 * <p/>
 * Once an element name is identified, we make sure it is unique among
 * siblings within the same parent.
 * 
 * @param cobolDataItem the original COBOL data item
 * @param nonUniqueCobolNames a list of non unique COBOL names used to
 *            detect name collisions
 * @param model the translator options
 * @param parent used to resolve potential name conflict
 * @param order order within parent to disambiguate siblings
 * @return an XML schema element name
 */
public static String formatElementName(final CobolDataItem cobolDataItem,
        final List<String> nonUniqueCobolNames, final Cob2XsdModel model, final XsdDataItem parent,
        final int order) {

    String cobolName = getXmlCompatibleCobolName(cobolDataItem.getCobolName());
    if (cobolName.equalsIgnoreCase("FILLER")) {
        String filler = (model.elementNamesStartWithUppercase()) ? "Filler" : "filler";
        return filler + cobolDataItem.getSrceLine();
    }

    StringBuilder sb = new StringBuilder();
    boolean wordBreaker = (model.elementNamesStartWithUppercase()) ? true : false;
    for (int i = 0; i < cobolName.length(); i++) {
        char c = cobolName.charAt(i);
        if (c != '-' && c != '_') {
            if (Character.isDigit(c)) {
                sb.append(c);
                wordBreaker = true;
            } else {
                if (wordBreaker) {
                    sb.append(Character.toUpperCase(c));
                } else {
                    sb.append(Character.toLowerCase(c));
                }
                wordBreaker = false;
            }
        } else {
            wordBreaker = true;
        }
    }

    String elementName = sb.toString();
    if (parent != null) {
        int siblingsWithSameName = 0;
        for (CobolDataItem child : parent.getCobolChildren()) {
            if (child.getCobolName().equals(cobolDataItem.getCobolName())) {
                siblingsWithSameName++;
            }
        }
        if (siblingsWithSameName > 1) {
            elementName += order;
        }
    }

    return elementName;
}