Example usage for java.lang Character toLowerCase

List of usage examples for java.lang Character toLowerCase

Introduction

In this page you can find the example usage for java.lang Character toLowerCase.

Prototype

public static int toLowerCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to lowercase using case mapping information from the UnicodeData file.

Usage

From source file:com.actionbarsherlock.internal.view.MenuItemImpl.java

@Override
public MenuItem setAlphabeticShortcut(char alphaChar) {
    mAlphabeticalShortcut = Character.toLowerCase(alphaChar);
    return this;
}

From source file:ch.mlutz.plugins.t4e.tapestry.editor.TagContentAssistProcessor.java

protected ICompletionProposal[] computeOgnlCompletionProposals(int offset, String ognlPrefix,
        IDocument document, IFile documentFile) {
    List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
    int ognlPrefixLength = ognlPrefix.length();

    TapestryIndex tapestryIndex = Activator.getDefault().getTapestryIndex();
    ICompilationUnit compilationUnit = tapestryIndex.getRelatedCompilationUnit(documentFile);

    if (compilationUnit != null) {
        Map<ICompletionProposal, Integer> proposalScoreMap = new HashMap<ICompletionProposal, Integer>();

        // TODO: improve this suffix computation as in computeAttributeCompletionProposals
        String suffix = "\"";
        int additionalCursorOffset = 1;
        try {/*from w  ww  . j a v  a  2  s  .c  o  m*/
            if (offset < document.getLength() - 1 && document.get(offset, 1).equals("\"")) {
                suffix = "";
            }
        } catch (BadLocationException e) {
            log.warn("Could not compute suffix of completion proposals: ", e);
        }

        try {
            IType[] types = compilationUnit.getTypes();

            for (IType type : types) {
                if (type.isClass() && Flags.isPublic(type.getFlags())) {
                    IMethod[] methods = type.getMethods();
                    for (IMethod method : methods) {
                        String completionProposalString = method.getElementName() + "()";

                        String ognlProposalString = completionProposalString.replaceAll("^get(.+)\\(\\)?$",
                                "$1");

                        if (!ognlProposalString.equals(completionProposalString)) {
                            // ognlProposalString is different from
                            // original proposal => make sure first
                            // character is lower case
                            ognlProposalString = Character.toLowerCase(ognlProposalString.charAt(0))
                                    + ognlProposalString.substring(1);
                            completionProposalString = ognlProposalString;
                        }

                        if (completionProposalString.startsWith(ognlPrefix)) {
                            String displayName = completionProposalString;
                            String translatedSignature = translateSignatureToType(method.getReturnType());
                            if (translatedSignature != null) {
                                displayName += " - " + translatedSignature;
                            }

                            ICompletionProposal completionProposal = new CompletionProposal(
                                    completionProposalString + suffix, offset - ognlPrefixLength,
                                    ognlPrefixLength,
                                    completionProposalString.length() + additionalCursorOffset,
                                    Activator.getImage("icons/t4e.png"), displayName,
                                    getContextInformation("", ""), completionProposalString);

                            // compute score for this proposal
                            int proposalScore = getProposalScoreForMethod(method, ParameterType.STRING);

                            proposalScoreMap.put(completionProposal, proposalScore);

                            result.add(completionProposal);
                        }
                    }
                }
            }
        } catch (JavaModelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Collections.sort(result, new ScoreComparator<Integer>(proposalScoreMap));
    }

    return result.toArray(new ICompletionProposal[result.size()]);
}

From source file:de.tudarmstadt.ukp.clarin.webanno.conllu.ConllUReader.java

public void convert(JCas aJCas, BufferedReader aReader) throws IOException {
    if (readPos) {
        try {//from w  w  w .ja v  a2 s .  com
            posMappingProvider.configure(aJCas.getCas());
        } catch (AnalysisEngineProcessException e) {
            throw new IOException(e);
        }
    }

    JCasBuilder doc = new JCasBuilder(aJCas);

    List<String[]> words;
    while ((words = readSentence(aReader)) != null) {
        if (words.isEmpty()) {
            // Ignore empty sentences. This can happen when there are multiple end-of-sentence
            // markers following each other.
            continue;
        }

        int sentenceBegin = doc.getPosition();
        int sentenceEnd = sentenceBegin;

        int surfaceBegin = -1;
        int surfaceEnd = -1;
        String surfaceString = null;

        // Tokens, Lemma, POS
        Int2ObjectMap<Token> tokens = new Int2ObjectOpenHashMap<>();
        for (String[] word : words) {
            if (word[ID].contains("-")) {
                String[] fragments = word[ID].split("-");
                surfaceBegin = Integer.valueOf(fragments[0]);
                surfaceEnd = Integer.valueOf(fragments[1]);
                surfaceString = word[FORM];
                continue;
            }

            // Read token
            int tokenIdx = Integer.valueOf(word[ID]);
            Token token = doc.add(word[FORM], Token.class);
            tokens.put(tokenIdx, token);
            if (!StringUtils.contains(word[MISC], "SpaceAfter=No")) {
                doc.add(" ");
            }

            // Read lemma
            if (!UNUSED.equals(word[LEMMA]) && readLemma) {
                Lemma lemma = new Lemma(aJCas, token.getBegin(), token.getEnd());
                lemma.setValue(word[LEMMA]);
                lemma.addToIndexes();
                token.setLemma(lemma);
            }

            // Read part-of-speech tag
            if (!UNUSED.equals(word[POSTAG]) && readPos) {
                Type posTag = posMappingProvider.getTagType(word[POSTAG]);
                POS pos = (POS) aJCas.getCas().createAnnotation(posTag, token.getBegin(), token.getEnd());
                pos.setPosValue(word[POSTAG]);
                pos.addToIndexes();
                token.setPos(pos);
            }

            // Read morphological features
            if (!UNUSED.equals(word[FEATS]) && readMorph) {
                MorphologicalFeatures morphtag = new MorphologicalFeatures(aJCas, token.getBegin(),
                        token.getEnd());
                morphtag.setValue(word[FEATS]);
                morphtag.addToIndexes();
                token.setMorph(morphtag);

                // Try parsing out individual feature values. Since the DKPro Core
                // MorphologicalFeatures type is based on the definition from the UD project,
                // we can do this rather straightforwardly.
                Type morphType = morphtag.getType();
                String[] items = word[FEATS].split("\\|");
                for (String item : items) {
                    String[] keyValue = item.split("=");
                    StringBuilder key = new StringBuilder(keyValue[0]);
                    key.setCharAt(0, Character.toLowerCase(key.charAt(0)));
                    String value = keyValue[1];

                    Feature feat = morphType.getFeatureByBaseName(key.toString());
                    if (feat != null) {
                        morphtag.setStringValue(feat, value);
                    }
                }
            }

            // Read surface form
            if (tokenIdx == surfaceEnd) {
                int begin = tokens.get(surfaceBegin).getBegin();
                int end = tokens.get(surfaceEnd).getEnd();
                SurfaceForm surfaceForm = new SurfaceForm(aJCas, begin, end);
                surfaceForm.setValue(surfaceString);
                surfaceForm.addToIndexes();
                surfaceBegin = -1;
                surfaceEnd = -1;
                surfaceString = null;
            }

            sentenceEnd = token.getEnd();
        }

        // Dependencies
        if (readDependency) {
            for (String[] word : words) {
                if (!UNUSED.equals(word[DEPREL])) {
                    int depId = Integer.valueOf(word[ID]);
                    int govId = Integer.valueOf(word[HEAD]);

                    // Model the root as a loop onto itself
                    makeDependency(aJCas, govId, depId, word[DEPREL], DependencyFlavor.BASIC, tokens, word);
                }

                if (!UNUSED.equals(word[DEPS])) {
                    // list items separated by vertical bar
                    String[] items = word[DEPS].split("\\|");
                    for (String item : items) {
                        String[] sItem = item.split(":");

                        int depId = Integer.valueOf(word[ID]);
                        int govId = Integer.valueOf(sItem[0]);

                        makeDependency(aJCas, govId, depId, sItem[1], DependencyFlavor.ENHANCED, tokens, word);
                    }
                }
            }
        }

        // Sentence
        Sentence sentence = new Sentence(aJCas, sentenceBegin, sentenceEnd);
        sentence.addToIndexes();

        // Once sentence per line.
        doc.add("\n");
    }

    doc.close();
}

From source file:org.codehaus.groovy.grails.web.pages.Parse.java

private static boolean match(CharSequence pat, CharSequence text, int start) {
    int ix = start, ixz = text.length(), ixy = start + pat.length();
    if (ixz > ixy)
        ixz = ixy;/*  w  ww . j  av a2 s.co  m*/
    if (pat.length() > ixz - start)
        return false;
    for (; ix < ixz; ix++) {
        if (Character.toLowerCase(text.charAt(ix)) != Character.toLowerCase(pat.charAt(ix - start))) {
            return false;
        }
    }
    return true;
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.conll.ConllUReader.java

public void convert(JCas aJCas, BufferedReader aReader) throws IOException {
    if (readPos) {
        try {//from   w  w w .j  a  va 2s .  co m
            posMappingProvider.configure(aJCas.getCas());
        } catch (AnalysisEngineProcessException e) {
            throw new IOException(e);
        }
    }

    JCasBuilder doc = new JCasBuilder(aJCas);

    List<String[]> words;
    while ((words = readSentence(aReader)) != null) {
        if (words.isEmpty()) {
            // Ignore empty sentences. This can happen when there are multiple end-of-sentence
            // markers following each other.
            continue;
        }

        int sentenceBegin = doc.getPosition();
        int sentenceEnd = sentenceBegin;

        int surfaceBegin = -1;
        int surfaceEnd = -1;
        String surfaceString = null;

        // Tokens, Lemma, POS
        Int2ObjectMap<Token> tokens = new Int2ObjectOpenHashMap<>();
        Iterator<String[]> wordIterator = words.iterator();
        while (wordIterator.hasNext()) {
            String[] word = wordIterator.next();
            if (word[ID].contains("-")) {
                String[] fragments = word[ID].split("-");
                surfaceBegin = Integer.valueOf(fragments[0]);
                surfaceEnd = Integer.valueOf(fragments[1]);
                surfaceString = word[FORM];
                continue;
            }

            // Read token
            int tokenIdx = Integer.valueOf(word[ID]);
            Token token = doc.add(word[FORM], Token.class);
            tokens.put(tokenIdx, token);
            if (!StringUtils.contains(word[MISC], "SpaceAfter=No") && wordIterator.hasNext()) {
                doc.add(" ");
            }

            // Read lemma
            if (!UNUSED.equals(word[LEMMA]) && readLemma) {
                Lemma lemma = new Lemma(aJCas, token.getBegin(), token.getEnd());
                lemma.setValue(word[LEMMA]);
                lemma.addToIndexes();
                token.setLemma(lemma);
            }

            // Read part-of-speech tag
            POS pos = null;
            String tag = useCPosAsPos ? word[CPOSTAG] : word[POSTAG];
            if (!UNUSED.equals(tag) && readPos) {
                Type posTag = posMappingProvider.getTagType(tag);
                pos = (POS) aJCas.getCas().createAnnotation(posTag, token.getBegin(), token.getEnd());
                pos.setPosValue(tag.intern());
            }

            // Read coarse part-of-speech tag
            if (!UNUSED.equals(word[CPOSTAG]) && readCPos && pos != null) {
                pos.setCoarseValue(word[CPOSTAG].intern());
            }

            if (pos != null) {
                pos.addToIndexes();
                token.setPos(pos);
            }

            // Read morphological features
            if (!UNUSED.equals(word[FEATS]) && readMorph) {
                MorphologicalFeatures morphtag = new MorphologicalFeatures(aJCas, token.getBegin(),
                        token.getEnd());
                morphtag.setValue(word[FEATS]);
                morphtag.addToIndexes();
                token.setMorph(morphtag);

                // Try parsing out individual feature values. Since the DKPro Core
                // MorphologicalFeatures type is based on the definition from the UD project,
                // we can do this rather straightforwardly.
                Type morphType = morphtag.getType();
                String[] items = word[FEATS].split("\\|");
                for (String item : items) {
                    String[] keyValue = item.split("=");
                    StringBuilder key = new StringBuilder(keyValue[0]);
                    key.setCharAt(0, Character.toLowerCase(key.charAt(0)));
                    String value = keyValue[1];

                    Feature feat = morphType.getFeatureByBaseName(key.toString());
                    if (feat != null) {
                        morphtag.setStringValue(feat, value);
                    }
                }
            }

            // Read surface form
            if (tokenIdx == surfaceEnd) {
                int begin = tokens.get(surfaceBegin).getBegin();
                int end = tokens.get(surfaceEnd).getEnd();
                SurfaceForm surfaceForm = new SurfaceForm(aJCas, begin, end);
                surfaceForm.setValue(surfaceString);
                surfaceForm.addToIndexes();
                surfaceBegin = -1;
                surfaceEnd = -1;
                surfaceString = null;
            }

            sentenceEnd = token.getEnd();
        }

        // Dependencies
        if (readDependency) {
            for (String[] word : words) {
                if (!UNUSED.equals(word[DEPREL])) {
                    int depId = Integer.valueOf(word[ID]);
                    int govId = Integer.valueOf(word[HEAD]);

                    // Model the root as a loop onto itself
                    makeDependency(aJCas, govId, depId, word[DEPREL], DependencyFlavor.BASIC, tokens, word);
                }

                if (!UNUSED.equals(word[DEPS])) {
                    // list items separated by vertical bar
                    String[] items = word[DEPS].split("\\|");
                    for (String item : items) {
                        String[] sItem = item.split(":");

                        int depId = Integer.valueOf(word[ID]);
                        int govId = Integer.valueOf(sItem[0]);

                        makeDependency(aJCas, govId, depId, sItem[1], DependencyFlavor.ENHANCED, tokens, word);
                    }
                }
            }
        }

        // Sentence
        Sentence sentence = new Sentence(aJCas, sentenceBegin, sentenceEnd);
        sentence.addToIndexes();

        // Once sentence per line.
        doc.add("\n");
    }

    doc.close();
}

From source file:org.finra.herd.core.AbstractCoreTest.java

/**
 * Method to convert an input string to mixed case.  This method will make every other character a capitalized character followed by a lower case character.
 *
 * @param input String input that will be converted to a mixed case string.
 *
 * @return mixed case version of the input string
 *///ww  w  . j  a va2s  . c  o  m
protected static String convertStringToMixedCase(final String input) {
    // Create a string builder to hold the new mixed case string.
    StringBuilder output = new StringBuilder();

    // For each character in the input string.
    for (int i = 0; i < input.length(); i++) {
        char ch = input.charAt(i);

        // Use modulo 2 to upper case every other letter and lower case the following letter
        if (i % 2 == 0) {
            output.append(Character.toUpperCase(ch));
        } else {
            output.append(Character.toLowerCase(ch));
        }
    }

    // Return the new mixed case string
    return output.toString();
}

From source file:org.getobjects.foundation.UString.java

/**
 * Checks whether the given String has a http://, https://, ftp:// or
 * mailto:// prefix. This method is not exact since and performs no further
 * validation. Its mostly to decide whether a prefix must be added to a
 * generic String.//from   w  w  w .  j av  a2 s . c o  m
 * 
 * @param _s - an arbitrary string, eg mailto:info@skyrix.de
 * @return the protocol if the String looks like an URL, null otherwise
 */
public static String getURLProtocol(String _s) {
    int len;
    if (_s == null || (len = _s.length()) < 7)
        return null;

    switch (Character.toLowerCase(_s.charAt(0))) {
    case 'h':
        if (len > 7) {
            _s = _s.toLowerCase();
            if (_s.startsWith("http://"))
                return "http";
            if (_s.startsWith("https://"))
                return "https";
        }
        break;
    case 'f':
        if (len > 6) {
            _s = _s.toLowerCase();
            if (_s.startsWith("ftp://"))
                return "ftp";
        }
        break;
    case 'm':
        if (len > 8) {
            _s = _s.toLowerCase();
            if (_s.startsWith("mailto:"))
                return "mailto";
        }
        break;
    }
    return null;
}

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));
    }// ww w  . j a  v  a 2  s .c o  m
    methodName.deleteCharAt(1);
    return methodName.toString();
}

From source file:org.apache.struts2.config.ClasspathConfigurationProvider.java

/**
 * Create a default action mapping for a class instance.
 *
 * The namespace annotation is honored, if found, otherwise
 * the Java package is converted into the namespace
 * by changing the dots (".") to slashes ("/").
 *
 * @param cls Action or POJO instance to process
 * @param pkgs List of packages that were scanned for Actions
 *//*  w w w.  jav a  2  s.c  om*/
protected void processActionClass(Class cls, String[] pkgs) {
    String name = cls.getName();
    String actionPackage = cls.getPackage().getName();
    String actionNamespace = null;
    String actionName = null;
    for (String pkg : pkgs) {
        if (name.startsWith(pkg)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("ClasspathConfigurationProvider: Processing class " + name);
            }
            name = name.substring(pkg.length() + 1);

            actionNamespace = "";
            actionName = name;
            int pos = name.lastIndexOf('.');
            if (pos > -1) {
                actionNamespace = "/" + name.substring(0, pos).replace('.', '/');
                actionName = name.substring(pos + 1);
            }
            break;
        }
    }

    PackageConfig pkgConfig = loadPackageConfig(actionNamespace, actionPackage, cls);

    // In case the package changed due to namespace annotation processing
    if (!actionPackage.equals(pkgConfig.getName())) {
        actionPackage = pkgConfig.getName();
    }

    Annotation annotation = cls.getAnnotation(ParentPackage.class);
    if (annotation != null) {
        String parent = ((ParentPackage) annotation).value();
        PackageConfig parentPkg = configuration.getPackageConfig(parent);
        if (parentPkg == null) {
            throw new ConfigurationException(
                    "ClasspathConfigurationProvider: Unable to locate parent package " + parent, annotation);
        }
        pkgConfig.addParent(parentPkg);

        if (!TextUtils.stringSet(pkgConfig.getNamespace()) && TextUtils.stringSet(parentPkg.getNamespace())) {
            pkgConfig.setNamespace(parentPkg.getNamespace());
        }
    }

    // Truncate Action suffix if found
    if (actionName.endsWith(ACTION)) {
        actionName = actionName.substring(0, actionName.length() - ACTION.length());
    }

    // Force initial letter of action to lowercase, if desired
    if ((forceLowerCase) && (actionName.length() > 1)) {
        int lowerPos = actionName.lastIndexOf('/') + 1;
        StringBuilder sb = new StringBuilder();
        sb.append(actionName.substring(0, lowerPos));
        sb.append(Character.toLowerCase(actionName.charAt(lowerPos)));
        sb.append(actionName.substring(lowerPos + 1));
        actionName = sb.toString();
    }

    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setClassName(cls.getName());
    actionConfig.setPackageName(actionPackage);

    actionConfig.setResults(new ResultMap<String, ResultConfig>(cls, actionName, pkgConfig));
    pkgConfig.addActionConfig(actionName, actionConfig);
}

From source file:org.faster.opm.PropertyHelper.java

/**
 * get?getId -> idgetName -> name/*  ww w  .  ja  v  a 2 s  .  c om*/
 *
 * @param name
 *            ??
 * @return ????
 */
public static final String convertGetterMethodName(String name) {
    return new StringBuilder(name.length() - 3).append(Character.toLowerCase(name.charAt(3)))
            .append(name.substring(4)).toString();
}