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:org.apache.uima.ruta.resource.TreeWordList.java

private boolean recursiveContains(TextNode pointer, String text, int index, boolean ignoreCase,
        boolean fragment, char[] ignoreChars, int maxIgnoreChars, boolean ignoreWS) {
    if (pointer == null) {
        return false;
    }//from  w w  w  .  j  a  v  a2 s . c om
    if (index == text.length()) {
        return fragment || pointer.isWordEnd();
    }
    char charAt = text.charAt(index);
    boolean charAtIgnored = false;
    if (ignoreChars != null) {
        for (char each : ignoreChars) {
            if (each == charAt) {
                charAtIgnored = true;
                maxIgnoreChars--;
                break;
            }
        }
        charAtIgnored &= index != 0;
        if (maxIgnoreChars < 0) {
            return false;
        }
    }
    int next = ++index;

    boolean result = false;

    if (ignoreCase) {
        TextNode childNodeL = pointer.getChildNode(Character.toLowerCase(charAt));
        TextNode childNodeU = pointer.getChildNode(Character.toUpperCase(charAt));

        TextNode wsNode = pointer.getChildNode(' ');
        if (ignoreWS && wsNode != null) {
            result |= recursiveContains(wsNode, text, --next, ignoreCase, fragment, ignoreChars, maxIgnoreChars,
                    ignoreWS);
        }

        if (childNodeL == null && ignoreWS) {
            childNodeL = skipWS(pointer, charAt);
        }
        if (childNodeU == null && ignoreWS) {
            childNodeU = skipWS(pointer, charAt);
        }
        if (charAtIgnored && childNodeL == null && childNodeU == null) {
            result |= recursiveContains(pointer, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars,
                    ignoreWS);
        } else {
            result |= recursiveContains(childNodeL, text, next, ignoreCase, fragment, ignoreChars,
                    maxIgnoreChars, ignoreWS)
                    | recursiveContains(childNodeU, text, next, ignoreCase, fragment, ignoreChars,
                            maxIgnoreChars, ignoreWS);
        }
    } else {
        TextNode wsNode = pointer.getChildNode(' ');
        if (ignoreWS && wsNode != null) {
            result |= recursiveContains(wsNode, text, --next, ignoreCase, fragment, ignoreChars, maxIgnoreChars,
                    ignoreWS);
        }

        TextNode childNode = pointer.getChildNode(charAt);
        if (childNode == null && ignoreWS) {
            childNode = skipWS(pointer, charAt);
        }
        if (charAtIgnored && childNode == null) {
            result |= recursiveContains(pointer, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars,
                    ignoreWS);
        } else {
            result |= recursiveContains(childNode, text, next, ignoreCase, fragment, ignoreChars,
                    maxIgnoreChars, ignoreWS);
        }
    }
    return result;
}

From source file:com.fengduo.bee.commons.util.StringUtils.java

/**
 * ??/*from   w  w w.j a v a  2s  .  co  m*/
 * 
 * @return toCamelCase("hello_world") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld"
 * toUnderScoreCase("helloWorld") = "hello_world"
 */
public static String toCamelCase(String s) {
    if (s == null) {
        return null;
    }

    s = s.toLowerCase();

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

        if (c == SEPARATOR) {
            upperCase = true;
        } else if (upperCase) {
            sb.append(Character.toUpperCase(c));
            upperCase = false;
        } else {
            sb.append(c);
        }
    }

    return sb.toString();
}

From source file:de.vandermeer.asciithemes.a7.dropcaps.FigletRoman.java

@Override
 public String[] getDropCap(char letter) {
     return this.map.get(Character.toUpperCase(letter));
 }

From source file:edu.internet2.middleware.grouper.changeLog.provisioning.ProvisioningConsumer.java

/**
 * Convert the ChangeLogEntry to a ChangeEvent
 *
 * @param changeLogEntry/* ww w .j  a  va  2  s .co m*/
 * @return
 * @throws IllegalAccessException
 * @throws ClassNotFoundException
 */
private ChangeEvent createEventFromLogEntry(ChangeLogEntry changeLogEntry, String consumerName)
        throws IllegalAccessException, ClassNotFoundException {
    ChangeEvent event = new ChangeEvent();
    event.setSequenceNumber(changeLogEntry.getSequenceNumber());
    //if this is a group type add action and category

    // copy all values from the ChangeLogEntry to the POJO ChangeEvent
    for (ChangeLogTypeBuiltin logEntryType : ChangeLogTypeBuiltin.values()) {
        if (changeLogEntry.equalsCategoryAndAction(logEntryType)) {
            String typeStr = logEntryType.toString();
            if (LOG.isDebugEnabled())
                LOG.debug("Event is " + logEntryType.toString());
            try {
                event.setEventType(ChangeEvent.ChangeEventType.valueOf(typeStr).name());
                //Class labels = (Class)ChangeLogLabels.class.getField(typeStr).get(null);
                Class labels = Class
                        .forName("edu.internet2.middleware.grouper.changeLog.ChangeLogLabels$" + typeStr);
                for (Field f : labels.getFields()) {
                    String value = this.getLabelValue(changeLogEntry, (ChangeLogLabel) f.get(null));
                    String setterName = "set" + Character.toUpperCase(f.getName().charAt(0))
                            + f.getName().substring(1);
                    try {
                        Method setter = event.getClass().getMethod(setterName, String.class);
                        setter.invoke(event, value);
                    } catch (Exception e) {
                        LOG.info("Field " + f.getName() + " not supported by class "
                                + event.getClass().getSimpleName());
                    }
                }
            } catch (IllegalArgumentException e) {
                LOG.info("Unsupported event " + typeStr + ", " + event.getSequenceNumber());
            }

        }
    }

    event = addSubjectAttributesIfNecessary(consumerName, event);

    return event;
}

From source file:ke.go.moh.oec.mpi.match.NameMatch.java

/**
 * Clean the string before finding its soundex (or metaphone) value.
 * This is necessary because the soundex library methods used make
 * the erroneous assumption that if the java Character.isLetter()
 * method returns true then the character will be in the range
 * A-Z or a-z. This is true for the basic 7-bit ASCII codes, but it may not
 * be for the extended 8-bit ASCII codes. If the character is an accented
 * letter in the extended 8-bit ASCII range, then isLetter() will return
 * true but the character will not be in the range A-Z or a-z.
 * <p>/*from   w ww . j a v a2  s .c  o  m*/
 * To compensate for this problem in the library methods called, this
 * method strips from the string any characters for which isLetter()
 * returns true, but the character is not in the range A-Z or a-z.
 * 
 * @param str String for which the soundex value will be computed.
 * @return String with accented characters (if any) removed.
 */
private String clean(String str) {
    if (str.length() > 0) {
        int len = str.length();
        char[] chars = new char[len];
        int count = 0;
        for (int i = 0; i < len; i++) {
            char c = Character.toUpperCase(str.charAt(i));
            if (!Character.isLetter(c) || (c >= 'A' && c <= 'Z')) {
                chars[count++] = str.charAt(i);
            }
        }
        if (count != len) {
            str = new String(chars, 0, count);
        }
    }
    return str;
}

From source file:com.edgenius.wiki.render.handler.PageIndexHandler.java

public void renderStart(AbstractPage page) {
    if (page != null && page.getSpace() != null) {
        String spaceUname = page.getSpace().getUnixName();
        List<Page> pages = pageService.getPageTree(spaceUname);
        indexMap = new TreeMap<String, LinkModel>(new Comparator<String>() {
            public int compare(String o1, String o2) {
                Character c1 = Character.toUpperCase(o1.charAt(0));
                Character c2 = Character.toUpperCase(o2.charAt(0));
                if (c1.equals(c2)) {
                    return o1.compareToIgnoreCase(o2);
                } else {
                    return c1.compareTo(c2);
                }/*from w ww .ja va2  s. c o  m*/

            }
        });
        indexer = new TreeMap<Character, Integer>(new Comparator<Character>() {
            public int compare(Character o1, Character o2) {
                return o1.compareTo(o2);
            }
        });
        Character indexKey = null;
        int indexAnchor = 1;
        for (Page pg : pages) {
            String title = pg.getTitle();
            if (StringUtils.isBlank(title)) {
                log.error("Blank title page found in {}", spaceUname);
                continue;
            }
            LinkModel link = new LinkModel();
            link.setLink(title);
            link.setType(LinkModel.LINK_TO_VIEW_FLAG);
            link.setSpaceUname(spaceUname);
            link.setView(title);
            indexMap.put(title, link);

            Character first = Character.toUpperCase(title.charAt(0));
            if (!first.equals(indexKey)) {
                indexKey = first;
                indexer.put(indexKey, indexAnchor++);
            }
        }

    }
}

From source file:org.focusns.common.event.support.EventInterceptor.java

private Event getEvent(Method method, Event.Point point) {
    ///*  ww w. j  a  va 2 s  .co m*/
    String eventKey = eventKeyCache.get(method);
    if (eventKey == null) {
        StringBuilder eventKeyBuilder = new StringBuilder();
        String methodName = method.getName();
        for (int i = 0; i < methodName.length(); i++) {
            char c = methodName.charAt(i);
            if (Character.isUpperCase(c)) {
                eventKeyBuilder.append("_");
            }
            eventKeyBuilder.append(Character.toUpperCase(c));
        }
        //
        eventKey = eventKeyBuilder.append("|").append(point.name()).toString();
    }
    //
    return eventMapping.get(eventKey);
}

From source file:ca.sqlpower.persistance.CatNap.java

/**
 * Converts underscore strings into their equivalent strings having
 * camelCaps instead of underscore.  For example,
 * <tt>richard_stallman_cant_read_this_because_he_is_dyslexic</tt> becomes
 * <tt>richardStallmanCantReadThisBecauseHeIsDyslexic</tt>.
 *
 * @param underScore The string to convert.  Must not be null.
 * @return The converted string.//from  w w  w.j a v a  2 s .  com
 */
public static String underscoreToCamelCaps(String underScore) {
    StringBuffer result = new StringBuffer(underScore.length() * 2);
    char[] chars = underScore.toLowerCase().toCharArray();
    for (int i = 0; i < underScore.length(); i++) {
        if ('_' == chars[i]) {
            i++;
            if (i >= chars.length)
                break;
            result.append(Character.toUpperCase(chars[i]));
        } else {
            result.append(chars[i]);
        }
    }
    return result.toString();
}

From source file:br.gov.frameworkdemoiselle.ldap.internal.ClazzUtils.java

/**
 * Feeling a Class or return null for a String Representation of Search
 * Filters (RFC 4515)//from w  w  w.j  a  v  a2s  .  co  m
 * 
 * @param searchFilter
 * @return Class
 */
public static Class<?> getClassForSearchFilter(String searchFilter, List<String> packageNames) {
    if (searchFilter == null || packageNames == null || packageNames.size() == 0)
        return null;
    String patternStr = "objectClass=(.*?)(\\)|$)";
    Matcher matcher = Pattern.compile(patternStr).matcher(searchFilter);
    boolean matchFound = matcher.find();
    if (matchFound && matcher.groupCount() > 1)
        for (String packageName : packageNames)
            try {
                return Class.forName(packageName + "." + Character.toUpperCase(matcher.group(1).charAt(0))
                        + matcher.group(1).substring(1));
            } catch (Exception e) {
            }
    return null;
}

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

/**
 * Prueft ob es sich um einen gltigen Vorname handelt. Gibt "true" fuer
 * gltig und "false" fuer nicht gltig zurueck. Ein Vorname 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 www .  j a va 2s  . c  o  m*/
 * @author Marcel Rosenberger, Annika Weis, Marco Glaser
 * @return Ob es sich um einen gltigen Vornamen handelt.
 */
private boolean validateFirstName() {
    boolean validFirstName;

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

    return validFirstName;
}