Example usage for java.lang Character isUpperCase

List of usage examples for java.lang Character isUpperCase

Introduction

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

Prototype

public static boolean isUpperCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is an uppercase character.

Usage

From source file:net.prasenjit.auth.validation.StrongPasswordValidator.java

/** {@inheritDoc} */
@Override//from  www.j  a  v  a  2  s  . c o m
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (!StringUtils.hasText(value))
        return true;
    int upperCount = 0;
    int specialCount = 0;
    int lowerCount = 0;
    int numericCount = 0;
    for (int i = 0; i < value.length(); i++) {
        char current = value.charAt(i);
        if (Character.isDigit(current))
            numericCount = 1;
        if (Character.isUpperCase(current))
            upperCount = 1;
        if (Character.isLowerCase(current))
            lowerCount = 1;
        if (!Character.isLetterOrDigit(current))
            specialCount = 1;
    }
    return upperCount + lowerCount + numericCount + specialCount >= 2;
}

From source file:com.google.dart.engine.services.refactoring.NamingConventions.java

/**
 * @return the {@link RefactoringStatus} with {@link RefactoringStatusSeverity#OK} if the name is
 *         valid, {@link RefactoringStatusSeverity#WARNING} if the name is discouraged, or
 *         {@link RefactoringStatusSeverity#ERROR} if the name is illegal.
 *//*from   ww  w  .j a  v a 2  s .c  o  m*/
public static RefactoringStatus validateConstantName(String name) {
    // null
    if (name == null) {
        return RefactoringStatus.createErrorStatus("Constant name must not be null.");
    }
    // is not identifier
    RefactoringStatus status = validateIdentifier(name, "Constant");
    if (!status.isOK()) {
        return status;
    }
    // is private, OK
    int startIndex = 0;
    if (name.charAt(0) == '_') {
        startIndex++;
    }
    // does not start with lower case
    for (int i = startIndex; i < name.length(); i++) {
        char c = name.charAt(i);
        if (!Character.isUpperCase(c) && !Character.isDigit(c) && c != '_') {
            return RefactoringStatus
                    .createWarningStatus("Constant name should be all uppercase with underscores.");
        }
    }
    // OK
    return new RefactoringStatus();
}

From source file:org.springframework.social.google.api.impl.ApiEnumDeserializer.java

@Override
public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {

    String camelCase = jp.getText();

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < camelCase.length(); i++) {
        char c = camelCase.charAt(i);
        if (Character.isUpperCase(c)) {
            sb.append('_').append(c);
        } else {/*  ww  w  .j a v  a  2s  .  c  o  m*/
            sb.append(Character.toUpperCase(c));
        }
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    T value = (T) Enum.valueOf((Class) type, sb.toString());

    return value;
}

From source file:com.velonuboso.made.core.interfaces.Archetype.java

/**
 * gets the name of the archetype.//www  . jav  a 2 s .  c o m
 *
 * @return the name of the archetype
 */
public String getArchetypeName() {
    if (processedName == null) {
        StringBuilder stb = new StringBuilder();

        char[] arr = this.getClass().getSimpleName().toCharArray();
        for (int i = 0; i < arr.length; i++) {
            char aux = arr[i];
            if (Character.isUpperCase(aux)) {
                if (i == 0) {
                    stb.append(aux);
                } else {
                    stb.append(" ");
                    stb.append(Character.toLowerCase(aux));
                }
            } else {
                stb.append(aux);
            }
        }
        processedName = stb.toString();
    }
    return processedName;
}

From source file:org.elasticsearch.spark.sql.Utils.java

static String camelCaseToDotNotation(String string) {
    StringBuilder sb = new StringBuilder();

    char last = 0;
    for (int i = 0; i < string.length(); i++) {
        char c = string.charAt(i);
        if (Character.isUpperCase(c) && Character.isLowerCase(last)) {
            sb.append(".");
        }// w  w w  . jav  a  2 s.  c  o  m
        last = c;
        sb.append(Character.toLowerCase(c));
    }

    return sb.toString();
}

From source file:com.zuoxiaolong.niubi.job.persistent.hibernate.HibernateNamingStrategy.java

private static String addUnderscores(String name) {
    StringBuilder buf = new StringBuilder(name.replace('.', '_'));
    for (int i = 1; i < buf.length() - 1; i++) {
        if (Character.isLowerCase(buf.charAt(i - 1)) && Character.isUpperCase(buf.charAt(i))
                && Character.isLowerCase(buf.charAt(i + 1))) {
            buf.insert(i++, '_');
        }/*  w  w  w.  j  av a2s.  c om*/
    }
    return buf.toString().toLowerCase(Locale.ROOT);
}

From source file:org.apdplat.superword.rule.RootRule.java

public static List<Word> findByRoot(Collection<Word> words, Word root) {
    return words.parallelStream().filter(word -> {
        //??/*ww  w.j a va  2s  .  c  om*/
        String w = word.getWord();
        if (Character.isUpperCase(w.charAt(0))) {
            return false;
        }
        //???
        String[] rs = root.getWord().toLowerCase().split(",");
        //???????
        for (String s : rs) {
            if (w.contains(s)) {
                return true;
            }
        }
        return false;
    }).sorted().collect(Collectors.toList());
}

From source file:io.lavagna.model.util.ShortNameGenerator.java

private static String takeFirstFourUpperCaseChars(String s) {
    StringBuilder sb = new StringBuilder();
    for (char c : s.toCharArray()) {
        if (Character.isUpperCase(c)) {
            sb.append(c);//  ww  w . jav a2s. c o m
        }
    }
    return sb.substring(0, Math.min(sb.length(), 4));
}

From source file:info.novatec.testit.livingdoc.util.NameUtils.java

public static String humanize(String s) {

    StringBuilder literal = new StringBuilder();
    char[] chars = s.toCharArray();
    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];
        if (Character.isUpperCase(c) && i > 0) {
            literal.append(' ');
            literal.append(Character.toLowerCase(c));
        } else {//from   w  ww.ja  v a 2s  .c  om
            literal.append(c);
        }
    }
    return literal.toString();
}

From source file:org.gradle.model.internal.manage.schema.extract.MethodType.java

private static boolean isNthCharUpperCase(String methodName, int position) {
    return Character.isUpperCase(methodName.charAt(position - 1));
}