Example usage for java.lang Character isLowerCase

List of usage examples for java.lang Character isLowerCase

Introduction

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

Prototype

public static boolean isLowerCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is a lowercase character.

Usage

From source file:org.apdplat.superword.tools.TextAnalyzer.java

/**
 * ?/*from   w ww .  ja va2 s  .  co  m*/
 * @param sentence
 * @return
 */
public static List<String> seg(String sentence) {
    List<String> data = new ArrayList<>();
    //??
    String[] words = sentence.trim().split("[^a-zA-Z0-9]");
    StringBuilder log = new StringBuilder();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("??:" + sentence);
    }
    for (String word : words) {
        if (StringUtils.isBlank(word) || word.length() < 2) {
            continue;
        }
        List<String> list = new ArrayList<>();
        //??
        if (word.length() < 6
                //PostgreSQL
                || (Character.isUpperCase(word.charAt(word.length() - 1))
                        && Character.isUpperCase(word.charAt(0)))
                //P2P,Neo4j
                || PATTERN.matcher(word).find() || StringUtils.isAllUpperCase(word)) {
            word = word.toLowerCase();
        }
        //???
        int last = 0;
        for (int i = 1; i < word.length(); i++) {
            if (Character.isUpperCase(word.charAt(i)) && Character.isLowerCase(word.charAt(i - 1))) {
                list.add(word.substring(last, i));
                last = i;
            }
        }
        if (last < word.length()) {
            list.add(word.substring(last, word.length()));
        }
        list.stream().map(w -> w.toLowerCase()).forEach(w -> {
            if (w.length() < 2) {
                return;
            }
            w = irregularity(w);
            if (StringUtils.isNotBlank(w)) {
                data.add(w);
                if (LOGGER.isDebugEnabled()) {
                    log.append(w).append(" ");
                }
            }
        });
    }
    LOGGER.debug("?" + log);
    return data;
}

From source file:importer.filters.PlayFilter.java

/**
 * Is the token an ordinary word, i.e. not a name?
 * @param token the token/*  w  ww.jav  a2 s.c o  m*/
 * @return true if it's a word
 */
boolean isWord(String token) {
    return Character.isLowerCase(token.charAt(0));
}

From source file:edu.txstate.dmlab.clusteringwiki.util.StaticInitializerBeanFactoryPostProcessor.java

/**
 * return the standard setter name for field fieldName
 * @param fieldName/* ww w .  j  av a2  s . c om*/
 * @return
 */
private String setterName(String fieldName) {
    String nameToUse = null;
    if (fieldName.length() == 1) {
        if (Character.isLowerCase(fieldName.charAt(0))) {
            nameToUse = fieldName.toUpperCase();
        } else {
            nameToUse = fieldName;
        }
    } else {
        if (Character.isLowerCase(fieldName.charAt(0)) && Character.isLowerCase(fieldName.charAt(1))) {
            nameToUse = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
        } else {
            nameToUse = fieldName;
        }
    }
    return "set" + nameToUse;
}

From source file:com.google.publicalerts.cap.CapUtil.java

static String underscoreCase(String s) {
    if (s.isEmpty()) {
        return s;
    }/*from   w w w  .j  av a  2 s .co  m*/
    StringBuilder sb = new StringBuilder();
    char[] chars = s.toCharArray();
    sb.append(chars[0]);
    for (int i = 1; i < chars.length; i++) {
        char ch = chars[i];
        if (Character.isUpperCase(ch) && Character.isLowerCase(chars[i - 1])) {
            sb.append('_');
        }
        sb.append(ch);
    }
    return sb.toString();
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.aclanthology.AclAnthologyReader.java

private String replaceHyphens(String text) {
    String lines[] = text.split("\\r?\\n");
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < lines.length - 1; i++) {

        // hyphen heuristic
        if (lines[i].endsWith("-") && lines[i + 1].length() > 0 && Character.isLowerCase(lines[i + 1].charAt(0))
                && !(lines[i + 1].split(" ")[0].contains("-"))) {
            // combine wordA[-\n]wordB into one word
            String[] lineA = lines[i].split(" ");
            String[] lineB = lines[i + 1].split(" ");
            String wordA = lineA[lineA.length - 1];
            wordA = wordA.substring(0, wordA.length() - 1); // remove hyphen
            String wordB = lineB[0];

            // take current line without hyphen, but with complete word
            sb.append(lines[i].substring(0, lines[i].length() - 1) + wordB + "\n");

            // delete 2nd word part from following line
            StringBuilder sbTmp = new StringBuilder();
            for (int j = 1; j < lineB.length; j++) {
                if (sbTmp.length() == 0) {
                    sbTmp.append(lineB[j]);
                } else {
                    sbTmp.append(" " + lineB[j]);
                }/*w  w  w  .ja v a2s  .com*/
            }
            lines[i + 1] = sbTmp.toString();
        } else {
            sb.append(lines[i] + "\n");
        }
    }
    return sb.toString();
}

From source file:org.nuxeo.ecm.core.storage.sql.jdbc.JDBCBackend.java

@Override
public void initialize(RepositoryImpl repository) throws StorageException {
    this.repository = repository;
    RepositoryDescriptor repositoryDescriptor = repository.getRepositoryDescriptor();
    pseudoDataSourceName = ConnectionHelper.getPseudoDataSourceNameForRepository(repositoryDescriptor.name);

    try {//w w  w  .java2 s .co  m
        DataSource ds = DataSourceHelper.getDataSource(pseudoDataSourceName);
        if (ds instanceof PooledDataSource) {
            isPooledDataSource = true;
            return;
        }
    } catch (NamingException cause) {
        ;
    }

    // try single-datasource non-XA mode
    try (Connection connection = ConnectionHelper.getConnection(pseudoDataSourceName)) {
        if (connection != null) {
            return;
        }
    } catch (SQLException cause) {
        throw new StorageException("Connection error", cause);
    }

    // standard XA mode
    // instantiate the XA datasource
    String className = repositoryDescriptor.xaDataSourceName;
    Class<?> klass;
    try {
        klass = Class.forName(className);
    } catch (ClassNotFoundException e) {
        throw new StorageException("Unknown class: " + className, e);
    }
    Object instance;
    try {
        instance = klass.newInstance();
    } catch (Exception e) {
        throw new StorageException("Cannot instantiate class: " + className, e);
    }
    if (!(instance instanceof XADataSource)) {
        throw new StorageException("Not a XADataSource: " + className);
    }
    xadatasource = (XADataSource) instance;

    // set JavaBean properties on the datasource
    for (Entry<String, String> entry : repositoryDescriptor.properties.entrySet()) {
        String name = entry.getKey();
        Object value = Framework.expandVars(entry.getValue());
        if (name.contains("/")) {
            // old syntax where non-String types were explicited
            name = name.substring(0, name.indexOf('/'));
        }
        // transform to proper JavaBean convention
        if (Character.isLowerCase(name.charAt(1))) {
            name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
        }
        try {
            BeanUtils.setProperty(xadatasource, name, value);
        } catch (Exception e) {
            log.error(String.format("Cannot set %s = %s", name, value));
        }
    }
}

From source file:org.jumpmind.util.FormatUtils.java

public static boolean isMixedCase(String text) {
    char[] chars = text.toCharArray();
    boolean upper = false;
    boolean lower = false;
    for (char ch : chars) {
        upper |= Character.isUpperCase(ch);
        lower |= Character.isLowerCase(ch);
    }//from  w ww  . j a v a 2  s.  co m
    return upper && lower;
}

From source file:org.eclipse.wb.internal.core.utils.StringUtilities.java

/**
 * @return the index of the first lowercase letter.
 * /*from ww  w.j a v a 2 s. com*/
 * <pre>
  * null      = -1
  * ""        = -1
  * "button"  = 0
  * "JButton" = 2
  * "ABC"     = -1
  * </pre>
 */
public static int indexOfFirstLowerCase(String str) {
    if (str == null) {
        return -1;
    }
    // check each character for lower case
    for (int i = 0; i < str.length(); i++) {
        char ch = str.charAt(i);
        if (Character.isLowerCase(ch)) {
            return i;
        }
    }
    // no lower case characters
    return -1;
}

From source file:modmanager.backend.ModificationOption.java

/**
 * Renames folders to be compatible to unix file systems
 *//*  w w  w.  j  av a2  s. c o  m*/
private void makeUnixCompatible(File path) {
    logger.log(Level.FINER, "Making modification compatible to UNIX filesystems (Mac, Linux, ...)");

    /**
     * Check if the data folder is named wrong
     */
    if (FileUtils.getFile(path, "data").exists()) {
        FileUtils.getFile(path, "data").renameTo(FileUtils.getFile(path, "Data"));

        /**
         * Go to data directory
         */
        path = FileUtils.getFile(path, "Data");

        logger.log(Level.FINEST, "unix: Renamed data to Data");
    } else if (FileUtils.getFile(directory, "Data").exists()) {
        /**
         * Go to data directory
         */
        path = FileUtils.getFile(path, "Data");
    }

    /**
     * All top folders should be renamed to uppercase letter first
     */
    for (File dir : path.listFiles()) {
        if (dir.isDirectory()) {
            if (Character.isLowerCase(dir.getName().charAt(0))) {
                /**
                 * Silently assuming that a folder has more than one letter
                 */
                String new_name = Character.toUpperCase(dir.getName().charAt(0)) + dir.getName().substring(1);

                dir.renameTo(FileUtils.getFile(dir.getParentFile(), new_name));
                logger.log(Level.FINEST, "unix: Renamed {0} to {1}",
                        new Object[] { dir.getAbsolutePath(), new_name });
            }
        }
    }
}

From source file:TestStore.java

private void dumpRecord(byte[] data, int size, PrintStream out, StringBuffer hexLine, StringBuffer charLine,
        int maxLen) {
    if (size == 0)
        return;//from  w ww .j av  a 2s  . c om

    hexLine.setLength(0);
    charLine.setLength(0);

    int count = 0;

    for (int i = 0; i < size; ++i) {
        char b = (char) (data[i] & 0xFF);

        if (b < 0x10) {
            hexLine.append('0');
        }

        hexLine.append(Integer.toHexString(b));
        hexLine.append(' ');

        if ((b >= 32 && b <= 127) || Character.isDigit(b) || Character.isLowerCase(b)
                || Character.isUpperCase(b)) {
            charLine.append((char) b);
        } else {
            charLine.append('.');
        }

        if (++count >= maxLen || i == size - 1) {
            while (count++ < maxLen) {
                hexLine.append("   ");
            }

            hexLine.append(' ');
            hexLine.append(charLine.toString());

            out.println(hexLine.toString());

            hexLine.setLength(0);
            charLine.setLength(0);
            count = 0;
        }
    }
}