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:io.wcm.handler.richtext.impl.DataPropertyUtil.java

/**
 * Converts a HTML5 data attribute name including "data-" prefix to a headless camel case name.
 * @param html5DataName Html5 data attribute name
 * @return Headless camel case name//from w w w.ja v  a2s  . c  om
 * @throws IllegalArgumentException If parameter name is not valid
 */
public static String toHeadlessCamelCaseName(String html5DataName) {
    if (StringUtils.isEmpty(html5DataName)) {
        throw new IllegalArgumentException("Property name is empty.");
    }
    if (!isHtml5DataName(html5DataName)) {
        throw new IllegalArgumentException("This is not a valid HTML5 data property name: " + html5DataName);
    }

    String html5DataNameWithoutSuffix = StringUtils.substringAfter(html5DataName, HTML5_DATA_PREFIX);
    StringBuilder headlessCamelCaseName = new StringBuilder();
    boolean upperCaseNext = false;
    for (int i = 0; i < html5DataNameWithoutSuffix.length(); i++) {
        char c = html5DataNameWithoutSuffix.charAt(i);
        if (c == '-') {
            upperCaseNext = true;
        } else if (upperCaseNext) {
            headlessCamelCaseName.append(Character.toUpperCase(c));
            upperCaseNext = false;
        } else {
            headlessCamelCaseName.append(c);
        }
    }

    return headlessCamelCaseName.toString();
}

From source file:boa.BoaMain.java

protected static String pascalCase(final String string) {
    final StringBuilder pascalized = new StringBuilder();

    boolean upper = true;
    for (final char c : string.toCharArray())
        if (Character.isDigit(c) || c == '_') {
            pascalized.append(c);/* w w  w  .j  a  v a 2 s  . c  o  m*/
            upper = true;
        } else if (!Character.isDigit(c) && !Character.isLetter(c)) {
            upper = true;
        } else if (Character.isLetter(c)) {
            pascalized.append(upper ? Character.toUpperCase(c) : c);
            upper = false;
        }

    return pascalized.toString();
}

From source file:com.rorrell.zootest.controllers.ExhibitController.java

@RequestMapping(value = "/exhibit/save", method = RequestMethod.POST)
public String saveExhibit(@Valid Exhibit exhibit, BindingResult result) {
    if (result.hasErrors()) {
        return "exhibitform";
    }/*from w w w . j a va  2  s .  co m*/
    //make sure first letter of name is capitalized
    exhibit.setName(Character.toUpperCase(exhibit.getName().charAt(0)) + exhibit.getName().substring(1));
    exRepo.save(exhibit);
    return "redirect:/exhibits";
}

From source file:info.jtrac.web.RestMultiActionController.java

/**
 * custom MethodNameResolver is configured that checks the value of an expected
 * paramter called "method" in the request and formats the value that may be
 * in the form of  "namespace.subnamespace.action" into "namespaceSubnamespaceAction"
 * or more like a java method name//from w  w w  .ja va 2 s  .  co m
 */
public RestMultiActionController() {
    setMethodNameResolver(new MethodNameResolver() {
        @Override
        public String getHandlerMethodName(HttpServletRequest request)
                throws NoSuchRequestHandlingMethodException {
            String temp = request.getParameter("method");
            if (temp == null) {
                return null;
            }
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < temp.length(); i++) {
                char c = temp.charAt(i);
                if (c == '.') {
                    i++;
                    c = temp.charAt(i);
                    sb.append(Character.toUpperCase(c));
                } else {
                    sb.append(c);
                }
            }
            return sb.toString();
        }
    });
}

From source file:com.gargoylesoftware.htmlunit.javascript.HtmlUnitScriptable.java

/**
 * {@inheritDoc}//from   ww  w  . ja v  a 2s .  c  o m
 * Same as base implementation, but includes all methods inherited from super classes as well.
 */
@Override
public void defineProperty(final String propertyName, final Class<?> clazz, int attributes) {
    final int length = propertyName.length();
    if (length == 0) {
        throw new IllegalArgumentException();
    }
    final char[] buf = new char[3 + length];
    propertyName.getChars(0, length, buf, 3);
    buf[3] = Character.toUpperCase(buf[3]);
    buf[0] = 'g';
    buf[1] = 'e';
    buf[2] = 't';
    final String getterName = new String(buf);
    buf[0] = 's';
    final String setterName = new String(buf);

    final Method[] methods = clazz.getMethods();
    final Method getter = findMethod(methods, getterName);
    final Method setter = findMethod(methods, setterName);
    if (setter == null) {
        attributes |= ScriptableObject.READONLY;
    }
    defineProperty(propertyName, null, getter, setter, attributes);
}

From source file:com.rorrell.zootest.controllers.AnimalController.java

@RequestMapping(value = "/animal/save", method = RequestMethod.POST)
public String saveAnimal(@Valid Animal animal, BindingResult result) {
    if (result.hasErrors())
        return "animalform";
    //make sure first letter of type is capitalized
    animal.setType(Character.toUpperCase(animal.getType().charAt(0)) + animal.getType().substring(1));
    animalRepo.save(animal);/*from w  w  w  . j a v  a2  s  .  co m*/
    return "redirect:/animals";
}

From source file:URLCodec.java

/**
 * Encodes an array of bytes into an array of URL safe 7-bit 
 * characters. Unsafe characters are escaped.
 *
 * @param urlsafe bitset of characters deemed URL safe
 * @param bytes array of bytes to convert to URL safe characters
 * @return array of bytes containing URL safe characters
 *///w w w.  j a  v  a 2 s  .co  m
public static final byte[] encodeUrl(BitSet urlsafe, byte[] bytes) {
    if (bytes == null) {
        return null;
    }
    if (urlsafe == null) {
        urlsafe = WWW_FORM_URL;
    }

    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    for (int i = 0; i < bytes.length; i++) {
        int b = bytes[i];
        if (b < 0) {
            b = 256 + b;
        }
        if (urlsafe.get(b)) {
            if (b == ' ') {
                b = '+';
            }
            buffer.write(b);
        } else {
            buffer.write('%');
            char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, 16));
            char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, 16));
            buffer.write(hex1);
            buffer.write(hex2);
        }
    }
    return buffer.toByteArray();
}

From source file:com.predic8.membrane.core.util.TextUtil.java

public static Object capitalize(String english) {
    if (english.length() == 0)
        return "";
    return Character.toString(Character.toUpperCase(english.charAt(0))) + english.substring(1);
}

From source file:com.opendoorlogistics.core.utils.strings.Strings.java

public static String toFirstLetterInWordCapitalised(String s) {
    int n = s.length();
    StringBuilder builder = new StringBuilder();
    boolean lastIsSpace = true;
    for (int i = 0; i < n; i++) {
        char c = s.charAt(i);
        if (lastIsSpace) {
            builder.append(Character.toUpperCase(c));
        } else {//from w  w  w. j  a v a2 s.c o  m
            builder.append(Character.toLowerCase(c));
        }
        lastIsSpace = Character.isWhitespace(c);
    }
    return builder.toString();
}