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.viadee.acceptancetests.roo.addon.AcceptanceTestsOperations.java

private String methodNameFromStory(String story) {
    String[] words = story.split(" ");
    StringBuilder methodName = new StringBuilder();
    methodName.append(Character.toLowerCase(words[0].charAt(0)));
    for (String word : words) {
        methodName.append(Character.toUpperCase(word.charAt(0)));
        methodName.append(word.substring(1));
    }//  w  ww.  ja v  a  2s.  com
    methodName.deleteCharAt(1);
    return methodName.toString();
}

From source file:com.orion.bot.Orion.java

/**
 * Object constructor//from www  . j a  va2s  .c o  m
 * 
 * @author Daniele Pantaleone
 * @param  path The Orion configuration file path
 **/
public Orion(String path) {

    try {

        // Loading the main XML configuration file
        this.config = new XmlConfiguration(path);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////// LOGGER SETUP /////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Logger.getRootLogger().setLevel(Level.OFF);
        Logger logger = Logger.getLogger("Orion");

        FileAppender fa = new FileAppender();

        fa.setLayout(new PatternLayout("%-20d{yyyy-MM-dd hh:mm:ss} %-6p %m%n"));
        fa.setFile(this.config.getString("logfile", "basepath") + this.config.getString("logfile", "filename"));
        fa.setAppend(this.config.getBoolean("logfile", "append"));
        fa.setName("FILE");
        fa.activateOptions();

        logger.addAppender(fa);

        if (this.config.getBoolean("logfile", "console")) {

            ConsoleAppender ca = new ConsoleAppender();
            ca.setLayout(new PatternLayout("%-20d{yyyy-MM-dd hh:mm:ss} %-6p %m%n"));
            ca.setWriter(new OutputStreamWriter(System.out));
            ca.setName("CONSOLE");
            ca.activateOptions();

            logger.addAppender(ca);

        }

        // Setting the log level for both the log appenders
        logger.setLevel(Level.toLevel(this.config.getString("logfile", "level")));

        // Creating the main Log object
        this.log = new Log4JLogger(logger);

        // We got a fully initialized logger utility now: printing some info messages
        this.log.info(
                "Starting " + BOTNAME + " " + VERSION + " [" + CODENAME + "] [ " + AUTHOR + " ] - " + WEBSITE);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////// LOADING PREFERENCES ///////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.timeformat = this.config.getString("orion", "timeformat", "EEE, d MMM yyyy HH:mm:ss");
        this.timezone = DateTimeZone.forID(this.config.getString("orion", "timezone", "CET"));
        this.locale = new Locale(this.config.getString("orion", "locale", "EN"),
                this.config.getString("orion", "locale", "EN"));
        this.startuptime = new DateTime(this.timezone);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////// PRE INITIALIZED OBJECTS ////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.eventBus = new EventBus("events");
        this.schedule = new LinkedHashMap<String, Timer>();
        this.game = new Game();

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////// STORAGE SETUP /////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.storage = new MySqlDataSourceManager(this.config.getString("storage", "username"),
                this.config.getString("storage", "password"), this.config.getString("storage", "connection"),
                this.log);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////// BUFFERS SETUP ////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.commandqueue = new ArrayBlockingQueue<Command>(this.config.getInt("orion", "commandqueue", 100));
        this.regcommands = new MultiKeyHashMap<String, String, RegisteredCommand>();

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////// CONSOLE SETUP ////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.console = (Console) Class
                .forName("com.orion.console." + this.config.getString("orion", "game") + "Console")
                .getConstructor(String.class, int.class, String.class, Orion.class)
                .newInstance(this.config.getString("server", "rconaddress"),
                        this.config.getInt("server", "rconport"),
                        this.config.getString("server", "rconpassword"), this);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////// CONTROLLERS SETUP /////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.groups = new GroupC(this);
        this.clients = new ClientC(this);
        this.aliases = new AliasC(this);
        this.callvotes = new CallvoteC(this);
        this.ipaliases = new IpAliasC(this);
        this.penalties = new PenaltyC(this);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////// PARSER SETUP/////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.parser = (Parser) Class
                .forName("com.orion.parser." + this.config.getString("orion", "game") + "Parser")
                .getConstructor(Orion.class).newInstance(this);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////// LOADING PLUGINS //////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.plugins = new LinkedHashMap<String, Plugin>();
        Map<String, String> pluginsList = this.config.getMap("plugins");

        for (Map.Entry<String, String> entry : pluginsList.entrySet()) {

            try {

                this.log.debug("Loading plugin [ " + Character.toUpperCase(entry.getKey().charAt(0))
                        + entry.getKey().substring(1).toLowerCase() + " ]");
                Plugin plugin = Plugin.getPlugin(entry.getKey(),
                        new XmlConfiguration(entry.getValue(), this.log), this);
                this.plugins.put(entry.getKey(), plugin);

            } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException
                    | IllegalAccessException | IllegalArgumentException | InvocationTargetException
                    | ParserException e) {

                // Logging the Exception and keep processing other plugins. This will not stop Orion execution
                this.log.error("Unable to load plugin [ " + Character.toUpperCase(entry.getKey().charAt(0))
                        + entry.getKey().substring(1).toLowerCase() + " ]", e);

            }

        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////// PLUGINS SETUP //////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        for (Map.Entry<String, Plugin> entry : this.plugins.entrySet()) {
            Plugin plugin = entry.getValue();
            plugin.onLoadConfig();
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////// PLUGINS STARTUP /////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        for (Map.Entry<String, Plugin> entry : this.plugins.entrySet()) {

            Plugin plugin = entry.getValue();

            // Check for the plugin to be enabled. onLoadConfig may have disabled
            // such plugin in case the plugin config file is non well formed
            if (plugin.isEnabled())
                plugin.onStartup();

        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////// GAME SERVER SYNC ////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        List<List<String>> status = this.console.getStatus();

        if (status == null) {
            this.log.warn("Unable to synchronize current server status: RCON response is NULL");
            return;
        }

        for (List<String> line : status) {

            // Dumping current user to build an infostring for the onClientConnect parser method
            Map<String, String> userinfo = this.console.dumpuser(Integer.parseInt(line.get(0)));

            // Not a valid client
            if (userinfo == null)
                continue;

            String infostring = new String();

            for (Map.Entry<String, String> entry : userinfo.entrySet()) {
                // Appending <key|value> using infostring format
                infostring += "\\" + entry.getKey() + "\\" + entry.getValue();
            }

            // Generating an EVT_CLIENT_CONNECT event for the connected client
            this.parser.parseLine("0:00 ClientUserinfo: " + line.get(0) + " " + infostring);

        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////// THREADS SETUP /////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.reader = new Thread(new Reader(this.config.getString("server", "logfile"),
                this.config.getInt("server", "logdelay"), this));
        this.commandproc = new Thread(new CommandProcessor(this));
        this.reader.setName("READER");
        this.commandproc.setName("COMMAND");

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////// THREADS STARTUP ////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.commandproc.start();
        this.reader.start();

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////// NOTICE BOT RUNNING ///////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        this.console.say(
                BOTNAME + " " + VERSION + " [" + CODENAME + "] - " + WEBSITE + " >> " + Color.GREEN + "ONLINE");

    } catch (Exception e) {

        // Stopping Threads if they are alive
        if ((this.commandproc != null) && (this.commandproc.isAlive()))
            this.commandproc.interrupt();
        if ((this.reader != null) && (this.reader.isAlive()))
            this.reader.interrupt();

        // Logging the Exception. Orion is not going to work if an Exception is catched at startup time
        this.log.fatal("Unable to start " + BOTNAME + " " + VERSION + " [" + CODENAME + "] [ " + AUTHOR
                + " ] - " + WEBSITE, e);

    }

}

From source file:acp.sdk.SecureUtil.java

/**
 * byte???//w ww. j a v  a2s  . c o  m
 * 
 * @param b
 *            ?byte
 * @return ??
 */
public static String Hex2Str(byte[] b) {
    StringBuffer d = new StringBuffer(b.length * 2);
    for (int i = 0; i < b.length; i++) {
        char hi = Character.forDigit((b[i] >> 4) & 0x0F, 16);
        char lo = Character.forDigit(b[i] & 0x0F, 16);
        d.append(Character.toUpperCase(hi));
        d.append(Character.toUpperCase(lo));
    }
    return d.toString();
}

From source file:com.box.restclientv2.httpclientsupport.HttpClientURLEncodedUtils.java

/**
 * Emcode/escape a portion of a URL, to use with the query part ensure {@code plusAsBlank} is true.
 * //  w  w w .j  a  v a2s .  c  om
 * @param content
 *            the portion to decode
 * @param charset
 *            the charset to use
 * @param blankAsPlus
 *            if {@code true}, then convert space to '+' (e.g. for www-url-form-encoded content), otherwise leave as is.
 * @return
 */
private static String urlencode(final String content, final Charset charset, final BitSet safechars,
        final boolean blankAsPlus) {
    if (content == null) {
        return null;
    }
    StringBuilder buf = new StringBuilder();
    ByteBuffer bb = charset.encode(content);
    while (bb.hasRemaining()) {
        int b = bb.get() & 0xff;
        if (safechars.get(b)) {
            buf.append((char) b);
        } else if (blankAsPlus && b == ' ') {
            buf.append('+');
        } else {
            buf.append("%");
            char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX));
            char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX));
            buf.append(hex1);
            buf.append(hex2);
        }
    }
    return buf.toString();
}

From source file:com.netspective.sparx.util.xml.XmlSource.java

/**
 * Given a text string, return a string that would be suitable for that string to be used
 * as a Java constant (public static final XXX). The rule is to basically take every letter
 * or digit and return it in uppercase and every non-letter or non-digit as an underscore.
 * This trims all non-letter/digit characters from the beginning of the string.
 *///from   w  ww.ja v  a 2  s. c  om
public static String xmlTextToJavaConstantTrimmed(String xml) {
    if (xml == null || xml.length() == 0)
        return xml;

    boolean stringStarted = false;
    StringBuffer constant = new StringBuffer();
    for (int i = 0; i < xml.length(); i++) {
        char ch = xml.charAt(i);
        if (Character.isJavaIdentifierPart(ch)) {
            stringStarted = true;
            constant.append(Character.toUpperCase(ch));
        } else if (stringStarted)
            constant.append('_');
    }
    return constant.toString();
}

From source file:com.webbfontaine.valuewebb.model.util.Utils.java

public static String toWords(CharSequence str) {
    StringBuilder res = new StringBuilder(str.length());
    for (int i = 0; i < str.length(); i++) {
        Character ch = str.charAt(i);
        if (Character.isUpperCase(ch)) {
            res.append(' ').append(ch);
        } else {//from   www . ja  va  2s.  c  o  m
            res.append(ch);
        }
    }
    char c = Character.toUpperCase(res.charAt(0));
    res.replace(0, 1, new String(new char[] { c }));
    return res.toString();
}

From source file:jp.primecloud.auto.tool.management.db.SQLExecuter.java

private String parseColumnName(String columnName) {
    String name = columnName.toLowerCase(Locale.ENGLISH);
    String[] array = name.split("_");
    if (array.length == 1) {
        return array[0];
    }//www. ja v  a  2 s.c  om

    StringBuilder sb = new StringBuilder();
    if (array[0].length() == 1) {
        sb.append(Character.toUpperCase(array[0].charAt(0)));
    } else {
        sb.append(array[0]);
    }

    for (int i = 1; i < array.length; i++) {
        sb.append(Character.toUpperCase(array[i].charAt(0))).append(array[i].substring(1));
    }

    return sb.toString();
}

From source file:org.opendatakit.common.utils.WebUtils.java

/**
 * Useful static method for constructing a UPPER_CASE persistence layer name
 * from a camelCase name. This inserts an underscore before a leading capital
 * letter and toUpper()s the resulting string. The transformation maps
 * multiple camelCase names to the same UPPER_CASE name so it is not
 * reversible.//from  w w  w .j  ava 2 s .  c o m
 * <ul>
 * <li>thisURL => THIS_URL</li>
 * <li>thisUrl => THIS_URL</li>
 * <li>myFirstObject => MY_FIRST_OBJECT</li>
 * </ul>
 *
 * @param name
 * @return
 */
public static final String unCamelCase(String name) {
    StringBuilder b = new StringBuilder();
    boolean lastCap = true;
    for (int i = 0; i < name.length(); ++i) {
        char ch = name.charAt(i);
        if (Character.isUpperCase(ch)) {
            if (!lastCap) {
                b.append('_');
            }
            lastCap = true;
            b.append(ch);
        } else if (Character.isLetterOrDigit(ch)) {
            lastCap = false;
            b.append(Character.toUpperCase(ch));
        } else {
            throw new IllegalArgumentException("Argument is not a valid camelCase name: " + name);
        }
    }
    return b.toString();
}

From source file:com.moviejukebox.plugin.trailer.AppleTrailersPlugin.java

private static String getTrailerTitle(String url) {
    int start = url.lastIndexOf('/');
    int end = url.indexOf(".mov", start);

    if ((start == -1) || (end == -1)) {
        return Movie.UNKNOWN;
    }// www .  ja v  a  2s .  c om

    StringBuilder title = new StringBuilder();

    for (int i = start + 1; i < end; i++) {
        if ((url.charAt(i) == '-') || (url.charAt(i) == '_')) {
            title.append(' ');
        } else {
            if (i == start + 1) {
                title.append(Character.toUpperCase(url.charAt(i)));
            } else {
                title.append(url.charAt(i));
            }
        }
    }

    return title.toString();
}

From source file:com.joliciel.talismane.tokeniser.filters.TokenRegexFilterImpl.java

Pattern getPattern() {
    if (pattern == null) {
        // we may need to replace WordLists by the list contents
        String myRegex = this.regex;

        if (LOG.isTraceEnabled()) {
            LOG.trace("Regex: " + myRegex);
        }//from  w ww. j a  va  2s.co  m

        if (this.autoWordBoundaries) {
            Boolean startsWithLetter = null;
            for (int i = 0; i < myRegex.length() && startsWithLetter == null; i++) {
                char c = myRegex.charAt(i);
                if (c == '\\') {
                    i++;
                    c = myRegex.charAt(i);
                    if (c == 'd' || c == 'w') {
                        startsWithLetter = true;
                    } else if (c == 's' || c == 'W' || c == 'b' || c == 'B') {
                        startsWithLetter = false;
                    } else if (c == 'p') {
                        i += 2; // skip the open curly brackets
                        int closeCurlyBrackets = myRegex.indexOf('}', i);
                        int openParentheses = myRegex.indexOf('(', i);
                        int endIndex = closeCurlyBrackets;
                        if (openParentheses > 0 && openParentheses < closeCurlyBrackets)
                            endIndex = openParentheses;
                        if (endIndex > 0) {
                            String specialClass = myRegex.substring(i, endIndex);
                            if (specialClass.equals("WordList")) {
                                startsWithLetter = true;
                            }
                        }
                    }
                    break;
                } else if (c == '[' || c == '(') {
                    // do nothing
                } else if (Character.isLetter(c) || Character.isDigit(c)) {
                    startsWithLetter = true;
                } else {
                    startsWithLetter = false;
                }
            }

            Boolean endsWithLetter = null;
            for (int i = myRegex.length() - 1; i >= 0 && endsWithLetter == null; i--) {
                char c = myRegex.charAt(i);
                char prevC = ' ';
                if (i >= 1)
                    prevC = myRegex.charAt(i - 1);
                if (prevC == '\\') {
                    if (c == 'd' || c == 'w') {
                        endsWithLetter = true;
                    } else if (c == 's' || c == 'W' || c == 'b' || c == 'B') {
                        endsWithLetter = false;
                    } else if (c == 'p') {
                        i += 2; // skip the open curly brackets
                        int closeCurlyBrackets = myRegex.indexOf('}', i);
                        int openParentheses = myRegex.indexOf('(', i);
                        int endIndex = closeCurlyBrackets;
                        if (openParentheses < closeCurlyBrackets)
                            endIndex = openParentheses;
                        if (endIndex > 0) {
                            String specialClass = myRegex.substring(i, endIndex);
                            if (specialClass.equals("WordList") || specialClass.equals("Alpha")
                                    || specialClass.equals("Lower") || specialClass.equals("Upper")
                                    || specialClass.equals("ASCII") || specialClass.equals("Digit")) {
                                startsWithLetter = true;
                            }
                        }
                    }
                    break;
                } else if (c == ']' || c == ')' || c == '+') {
                    // do nothing
                } else if (c == '}') {
                    int startIndex = myRegex.lastIndexOf('{') + 1;
                    int closeCurlyBrackets = myRegex.indexOf('}', startIndex);
                    int openParentheses = myRegex.indexOf('(', startIndex);
                    int endIndex = closeCurlyBrackets;
                    if (openParentheses > 0 && openParentheses < closeCurlyBrackets)
                        endIndex = openParentheses;
                    if (endIndex > 0) {
                        String specialClass = myRegex.substring(startIndex, endIndex);
                        if (specialClass.equals("WordList") || specialClass.equals("Alpha")
                                || specialClass.equals("Lower") || specialClass.equals("Upper")
                                || specialClass.equals("ASCII") || specialClass.equals("Digit")) {
                            endsWithLetter = true;
                        }
                    }
                    break;
                } else if (Character.isLetter(c) || Character.isDigit(c)) {
                    endsWithLetter = true;
                } else {
                    endsWithLetter = false;
                }
            }

            if (startsWithLetter != null && startsWithLetter) {
                myRegex = "\\b" + myRegex;
            }
            if (endsWithLetter != null && endsWithLetter) {
                myRegex = myRegex + "\\b";
            }
            if (LOG.isTraceEnabled()) {
                LOG.trace("After autoWordBoundaries: " + myRegex);
            }
        }

        if (!this.caseSensitive || !this.diacriticSensitive) {
            StringBuilder regexBuilder = new StringBuilder();
            for (int i = 0; i < myRegex.length(); i++) {
                char c = myRegex.charAt(i);
                if (c == '\\') {
                    // escape - skip next
                    regexBuilder.append(c);
                    i++;
                    c = myRegex.charAt(i);
                    regexBuilder.append(c);
                } else if (c == '[') {
                    // character group, don't change it
                    regexBuilder.append(c);
                    while (c != ']' && i < myRegex.length()) {
                        i++;
                        c = myRegex.charAt(i);
                        regexBuilder.append(c);
                    }
                } else if (c == '{') {
                    // command, don't change it
                    regexBuilder.append(c);
                    while (c != '}' && i < myRegex.length()) {
                        i++;
                        c = myRegex.charAt(i);
                        regexBuilder.append(c);
                    }
                } else if (Character.isLetter(c)) {
                    Set<String> chars = new TreeSet<String>();
                    chars.add("" + c);
                    char noAccent = diacriticPattern.matcher(Normalizer.normalize("" + c, Form.NFD))
                            .replaceAll("").charAt(0);

                    if (!this.caseSensitive) {
                        chars.add("" + Character.toUpperCase(c));
                        chars.add("" + Character.toLowerCase(c));
                        chars.add("" + Character.toUpperCase(noAccent));
                    }
                    if (!this.diacriticSensitive) {
                        chars.add("" + noAccent);
                        if (!this.caseSensitive) {
                            chars.add("" + Character.toLowerCase(noAccent));
                        }
                    }
                    if (chars.size() == 1) {
                        regexBuilder.append(c);
                    } else {
                        regexBuilder.append('[');
                        for (String oneChar : chars) {
                            regexBuilder.append(oneChar);
                        }
                        regexBuilder.append(']');
                    }
                } else {
                    regexBuilder.append(c);
                }
            }
            myRegex = regexBuilder.toString();
            if (LOG.isTraceEnabled()) {
                LOG.trace("After caseSensitive: " + myRegex);
            }
        }

        Matcher matcher = wordListPattern.matcher(myRegex);
        StringBuilder regexBuilder = new StringBuilder();

        int lastIndex = 0;
        while (matcher.find()) {
            String[] params = matcher.group(1).split(",");
            int start = matcher.start();
            int end = matcher.end();
            regexBuilder.append(myRegex.substring(lastIndex, start));

            String wordListName = params[0];
            boolean uppercaseOptional = false;
            boolean diacriticsOptional = false;
            boolean lowercaseOptional = false;
            boolean firstParam = true;
            for (String param : params) {
                if (firstParam) {
                    /* word list name */ } else if (param.equals("diacriticsOptional"))
                    diacriticsOptional = true;
                else if (param.equals("uppercaseOptional"))
                    uppercaseOptional = true;
                else if (param.equals("lowercaseOptional"))
                    lowercaseOptional = true;
                else
                    throw new TalismaneException(
                            "Unknown parameter in word list " + matcher.group(1) + ": " + param);
                firstParam = false;
            }

            ExternalWordList wordList = externalResourceFinder.getExternalWordList(wordListName);
            if (wordList == null)
                throw new TalismaneException("Unknown word list: " + wordListName);

            StringBuilder sb = new StringBuilder();

            boolean firstWord = true;
            for (String word : wordList.getWordList()) {
                if (!firstWord)
                    sb.append("|");
                word = Normalizer.normalize(word, Form.NFC);
                if (uppercaseOptional || diacriticsOptional) {
                    String wordNoDiacritics = Normalizer.normalize(word, Form.NFD)
                            .replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
                    String wordLowercase = word.toLowerCase(Locale.ENGLISH);
                    String wordLowercaseNoDiacritics = Normalizer.normalize(wordLowercase, Form.NFD)
                            .replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
                    String wordUppercase = wordNoDiacritics.toUpperCase(Locale.ENGLISH);

                    boolean needsGrouping = false;
                    if (uppercaseOptional && !word.equals(wordLowercase))
                        needsGrouping = true;
                    if (diacriticsOptional && !word.equals(wordNoDiacritics))
                        needsGrouping = true;
                    if (lowercaseOptional && !word.equals(wordUppercase))
                        needsGrouping = true;
                    if (needsGrouping) {
                        for (int i = 0; i < word.length(); i++) {
                            char c = word.charAt(i);

                            boolean grouped = false;
                            if (uppercaseOptional && c != wordLowercase.charAt(i))
                                grouped = true;
                            if (diacriticsOptional && c != wordNoDiacritics.charAt(i))
                                grouped = true;
                            if (lowercaseOptional && c != wordUppercase.charAt(i))
                                grouped = true;

                            if (!grouped)
                                sb.append(c);
                            else {
                                sb.append("[");
                                String group = "" + c;
                                if (uppercaseOptional && group.indexOf(wordLowercase.charAt(i)) < 0)
                                    group += (wordLowercase.charAt(i));
                                if (lowercaseOptional && group.indexOf(wordUppercase.charAt(i)) < 0)
                                    group += (wordUppercase.charAt(i));
                                if (diacriticsOptional && group.indexOf(wordNoDiacritics.charAt(i)) < 0)
                                    group += (wordNoDiacritics.charAt(i));
                                if (uppercaseOptional && diacriticsOptional
                                        && group.indexOf(wordLowercaseNoDiacritics.charAt(i)) < 0)
                                    group += (wordLowercaseNoDiacritics.charAt(i));

                                sb.append(group);
                                sb.append("]");
                            } // does this letter need grouping?
                        } // next letter
                    } else {
                        sb.append(word);
                    } // any options activated?
                } else {
                    sb.append(word);
                }
                firstWord = false;
            } // next word in list

            regexBuilder.append(sb.toString());
            lastIndex = end;
        } // next match
        regexBuilder.append(myRegex.substring(lastIndex));
        myRegex = regexBuilder.toString();
        this.pattern = Pattern.compile(myRegex, Pattern.UNICODE_CHARACTER_CLASS);
    }
    return pattern;
}