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.change_vision.astah.extension.plugin.csharpreverse.reverser.DoxygenXmlParser.java

/**
 * ???????????????????<br/>/*  www  .j  a va  2s  .  c  o m*/
 * 
 * ()  _(?)<br/>
 * :  _1<br/>
 * .  _8
 * 
 * @param str
 *            
 * @return ???
 */
private static String convertString(String str) {
    StringBuffer sb = new StringBuffer();
    for (Character ch : str.toCharArray()) {
        if (ch.equals(':')) {
            sb.append("_1");
        } else if (ch.equals('.')) {
            sb.append("_8");
        } else if (Character.isUpperCase(ch)) {
            sb.append("_" + Character.toLowerCase(ch));
        } else {
            sb.append(ch);
        }
    }
    return sb.toString();
}

From source file:net.metanotion.json.StreamingParser.java

private String lexExp(final Reader in) throws IOException {
    in.mark(MAX_BUFFER);/*from  ww w.ja va  2s .  co m*/
    int c = in.read();
    if (Character.toLowerCase(c) == 'e') {
        c = in.read();
        if (c == '+') {
            return "e+" + lexDigits(in);
        } else if (c == '-') {
            return "e-" + lexDigits(in);
        } else if (Character.isDigit(c)) {
            return (new String(Character.toChars(c))) + lexDigits(in);
        } else if (c == -1) {
            throw new ParserException("Unexpected end of stream");
        } else {
            throw new ParserException(
                    "Expected exponent, instead found: '" + (new String(Character.toChars(c))) + QUOTE);
        }
    } else {
        in.reset();
        return "";
    }
}

From source file:org.hippoecm.frontend.plugins.standards.perspective.Perspective.java

protected String toImageName(final String camelCaseString, final IconSize size, final String extension) {
    StringBuilder name = new StringBuilder(camelCaseString.length());
    name.append(Character.toLowerCase(camelCaseString.charAt(0)));
    for (int i = 1; i < camelCaseString.length(); i++) {
        char c = camelCaseString.charAt(i);
        if (Character.isUpperCase(c)) {
            name.append('-').append(Character.toLowerCase(c));
        } else {/* w  ww. java2 s .c o m*/
            name.append(c);
        }
    }
    if (size != null) {
        name.append('-').append(size.getSize());
    }
    name.append('.').append(extension);

    return name.toString();
}

From source file:org.apache.nutch.analysis.lang.NGramProfile.java

/**
 * Analyze a piece of text/*from  w ww.  j av a2 s  .  com*/
 * 
 * @param text the text to be analyzed
 */
public void analyze(StringBuilder text) {

    if (ngrams != null) {
        ngrams.clear();
        sorted = null;
        ngramcounts = null;
    }

    word.clear().append(SEPARATOR);
    for (int i = 0; i < text.length(); i++) {
        char c = Character.toLowerCase(text.charAt(i));

        if (Character.isLetter(c)) {
            add(word.append(c));
        } else {
            //found word boundary
            if (word.length() > 1) {
                //we have a word!
                add(word.append(SEPARATOR));
                word.clear().append(SEPARATOR);
            }
        }
    }

    if (word.length() > 1) {
        //we have a word!
        add(word.append(SEPARATOR));
    }
    normalize();
}

From source file:com.acmutv.ontoqa.core.CoreController.java

/**
 * Returns the normalized version of {@code question}.
 * @param question the question to normalize.
 * @return the normalized version of {@code question}; empty, if question is null or empty.
 *//*from  www .  j av  a2  s  .co  m*/
public static String normalizeQuestion(final String question) {
    if (question == null || question.isEmpty())
        return "";
    String cleaned = question.replaceAll("((?:\\s)+)", " ").replaceAll("((?:\\s)*\\?)", "");
    return Character.toLowerCase(cleaned.charAt(0)) + cleaned.substring(1);
}

From source file:org.eclipse.rdf4j.repository.manager.RepositoryManager.java

/**
 * Generates an ID for a new repository based on the specified base name. The base name may for example be
 * a repository name entered by the user. The generated ID will contain a variant of this name that does
 * not occur as a repository ID in this manager yet and is suitable for use as a file name (e.g. for the
 * repository's data directory).//from  w  w w  . j a v a2s  . c o m
 * 
 * @param baseName
 *        The String on which the returned ID should be based, must not be <tt>null</tt>.
 * @return A new repository ID derived from the specified base name.
 * @throws RepositoryException
 * @throws RepositoryConfigException
 */
public String getNewRepositoryID(String baseName) throws RepositoryException, RepositoryConfigException {
    if (baseName != null) {
        // Filter exotic characters from the base name
        baseName = baseName.trim();

        int length = baseName.length();
        StringBuilder buffer = new StringBuilder(length);

        for (char c : baseName.toCharArray()) {
            if (Character.isLetter(c) || Character.isDigit(c) || c == '-' || c == '_' || c == '.') {
                // Convert to lower case since file names are case insensitive on
                // some/most platforms
                buffer.append(Character.toLowerCase(c));
            } else if (c != '"' && c != '\'') {
                buffer.append('-');
            }
        }

        baseName = buffer.toString();
    }

    // First try if we can use the base name without an appended index
    if (baseName != null && baseName.length() > 0 && !hasRepositoryConfig(baseName)) {
        return baseName;
    }

    // When the base name is null or empty, generate one
    if (baseName == null || baseName.length() == 0) {
        baseName = "repository-";
    } else if (!baseName.endsWith("-")) {
        baseName += "-";
    }

    // Keep appending numbers until we find an unused ID
    int index = 2;
    while (hasRepositoryConfig(baseName + index)) {
        index++;
    }

    return baseName + index;
}

From source file:CharArrayMap.java

private boolean equals(CharSequence text1, char[] text2) {
    int len = text1.length();
    if (len != text2.length)
        return false;
    if (ignoreCase) {
        for (int i = 0; i < len; i++) {
            if (Character.toLowerCase(text1.charAt(i)) != text2[i])
                return false;
        }/* w w  w .  j a  v  a 2s . c  o  m*/
    } else {
        for (int i = 0; i < len; i++) {
            if (text1.charAt(i) != text2[i])
                return false;
        }
    }
    return true;
}

From source file:com.legstar.jaxb.plugin.CobolJAXBAnnotator.java

/**
 * {@inheritDoc}//  w w w  . ja v  a  2 s .com
 * <p>
 * XJC has built an abstract in-memory model of the target classes. We are
 * given a chance to tweak it.
 * */
public void postProcessModel(Model model, ErrorHandler errorHandler) {
    /*
     * With ECI we need to change field names so that they match the bean
     * getter/setter convention.
     */
    if (isEciCompatible()) {
        for (Entry<NClass, CClassInfo> entry : model.beans().entrySet()) {
            CClassInfo classInfo = entry.getValue();
            List<CPropertyInfo> properties = classInfo.getProperties();
            for (CPropertyInfo property : properties) {
                String publicName = property.getName(true);
                String newPrivateName = Character.toLowerCase(publicName.charAt(0)) + publicName.substring(1);
                property.setName(false, newPrivateName);
            }
        }
    }
}

From source file:com.astamuse.asta4d.util.annotation.AnnotatedPropertyUtil.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private static AnnotatedPropertyInfoMap retrievePropertiesMap(Class cls) {
    String cacheKey = cls.getName();
    AnnotatedPropertyInfoMap map = propertiesMapCache.get(cacheKey);
    if (map == null) {
        List<AnnotatedPropertyInfo> infoList = new LinkedList<>();
        Set<String> beanPropertyNameSet = new HashSet<>();

        Method[] mtds = cls.getMethods();
        for (Method method : mtds) {
            List<Annotation> annoList = ConvertableAnnotationRetriever
                    .retrieveAnnotationHierarchyList(AnnotatedProperty.class, method.getAnnotations());

            if (CollectionUtils.isEmpty(annoList)) {
                continue;
            }//  w ww.  j  a  v  a  2 s .c  o  m

            AnnotatedPropertyInfo info = new AnnotatedPropertyInfo();
            info.setAnnotations(annoList);

            boolean isGet = false;
            boolean isSet = false;
            String propertySuffixe = method.getName();
            if (propertySuffixe.startsWith("set")) {
                propertySuffixe = propertySuffixe.substring(3);
                isSet = true;
            } else if (propertySuffixe.startsWith("get")) {
                propertySuffixe = propertySuffixe.substring(3);
                isGet = true;
            } else if (propertySuffixe.startsWith("is")) {
                propertySuffixe = propertySuffixe.substring(2);
                isSet = true;
            } else {
                String msg = String.format("Method [%s]:[%s] can not be treated as a getter or setter method.",
                        cls.getName(), method.toGenericString());
                throw new RuntimeException(msg);
            }

            char[] cs = propertySuffixe.toCharArray();
            cs[0] = Character.toLowerCase(cs[0]);
            info.setBeanPropertyName(new String(cs));

            AnnotatedProperty ap = (AnnotatedProperty) annoList.get(0);// must by
            String name = ap.name();
            if (StringUtils.isEmpty(name)) {
                name = info.getBeanPropertyName();
            }

            info.setName(name);

            if (isGet) {
                info.setGetter(method);
                info.setType(method.getReturnType());
                String setterName = "set" + propertySuffixe;
                Method setter = null;
                try {
                    setter = cls.getMethod(setterName, method.getReturnType());
                } catch (NoSuchMethodException | SecurityException e) {
                    String msg = "Could not find setter method:[{}({})] in class[{}] for annotated getter:[{}]";
                    logger.warn(msg, new Object[] { setterName, method.getReturnType().getName(), cls.getName(),
                            method.getName() });
                }
                info.setSetter(setter);
            }

            if (isSet) {
                info.setSetter(method);
                info.setType(method.getParameterTypes()[0]);
                String getterName = "get" + propertySuffixe;
                Method getter = null;
                try {
                    getter = cls.getMethod(getterName);
                } catch (NoSuchMethodException | SecurityException e) {
                    String msg = "Could not find getter method:[{}:{}] in class[{}] for annotated setter:[{}]";
                    logger.warn(msg, new Object[] { getterName, method.getReturnType().getName(), cls.getName(),
                            method.getName() });
                }
                info.setGetter(getter);
            }

            infoList.add(info);
            beanPropertyNameSet.add(info.getBeanPropertyName());
        }

        List<Field> list = new ArrayList<>(ClassUtil.retrieveAllFieldsIncludeAllSuperClasses(cls));
        Iterator<Field> it = list.iterator();

        while (it.hasNext()) {
            Field f = it.next();
            List<Annotation> annoList = ConvertableAnnotationRetriever
                    .retrieveAnnotationHierarchyList(AnnotatedProperty.class, f.getAnnotations());
            if (CollectionUtils.isNotEmpty(annoList)) {
                AnnotatedProperty ap = (AnnotatedProperty) annoList.get(0);// must by

                String beanPropertyName = f.getName();
                if (beanPropertyNameSet.contains(beanPropertyName)) {
                    continue;
                }

                String name = ap.name();
                if (StringUtils.isEmpty(name)) {
                    name = f.getName();
                }

                AnnotatedPropertyInfo info = new AnnotatedPropertyInfo();
                info.setAnnotations(annoList);
                info.setBeanPropertyName(beanPropertyName);
                info.setName(name);
                info.setField(f);
                info.setGetter(null);
                info.setSetter(null);
                info.setType(f.getType());
                infoList.add(info);
            }
        }

        map = new AnnotatedPropertyInfoMap(infoList);
        if (Configuration.getConfiguration().isCacheEnable()) {
            propertiesMapCache.put(cacheKey, map);
        }
    }
    return map;
}

From source file:com.quinsoft.zeidon.standardoe.WriteOisToJsonStream.java

private String camelCaseName(String name) {
    if (!options.isCamelCase())
        return name;

    char[] nameChars = name.toCharArray();
    for (int i = 0; i < nameChars.length; i++) {
        if (!Character.isUpperCase(nameChars[i]))
            break;

        nameChars[i] = Character.toLowerCase(nameChars[i]);
    }// ww w  .j a v  a  2s . c  o  m

    return String.valueOf(nameChars);
}