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:com.nanyou.framework.jdbc.sql.beans.ClassInfo.java

private static String dropCase(String name) {
    if (name.startsWith("is")) {
        name = name.substring(2);/*from  w w w.j  av a 2s. c  o m*/
    } else if (name.startsWith("get") || name.startsWith("set")) {
        name = name.substring(3);
    } else {
        throw new ProbeException(
                "Error parsing property name '" + name + "'.  Didn't start with 'is', 'get' or 'set'.");
    }

    if (name.length() == 1 || (name.length() > 1 && !Character.isUpperCase(name.charAt(1)))) {
        name = name.substring(0, 1).toLowerCase(Locale.US) + name.substring(1);
    }

    return name;
}

From source file:de.fau.cs.osr.utils.StringUtils.java

/**
 * Converts a name that's given in camel-case into upper-case, inserting
 * underscores before upper-case letters.
 * //from  ww w .  j av  a2s.  co m
 * @param camelCase
 *            Name in camel-case notation.
 * @return Name in upper-case notation.
 */
public static String camelcaseToUppercase(String camelCase) {
    int n = camelCase.length();
    StringBuilder upperCase = new StringBuilder(n * 4 / 3);
    for (int i = 0; i < n; ++i) {
        char ch = camelCase.charAt(i);
        if (Character.isUpperCase(ch)) {
            upperCase.append('_');
            upperCase.append(ch);
        } else {
            upperCase.append(Character.toUpperCase(ch));
        }
    }

    return upperCase.toString();
}

From source file:org.eredlab.g4.ccl.net.ftp.parser.UnixFTPEntryParser.java

/**
 * Parses a line of a unix (standard) FTP server file listing and converts
 * it into a usable format in the form of an <code> FTPFile </code>
 * instance.  If the file listing line doesn't describe a file,
 * <code> null </code> is returned, otherwise a <code> FTPFile </code>
 * instance representing the files in the directory is returned.
 * <p>/*from www.jav  a 2  s .  co m*/
 * @param entry A line of text from the file listing
 * @return An FTPFile instance corresponding to the supplied entry
 */
public FTPFile parseFTPEntry(String entry) {
    FTPFile file = new FTPFile();
    file.setRawListing(entry);
    int type;
    boolean isDevice = false;

    if (matches(entry)) {
        String typeStr = group(1);
        String hardLinkCount = group(15);
        String usr = group(16);
        String grp = group(17);
        String filesize = group(18);
        String datestr = group(19) + " " + group(20);
        String name = group(21);
        String endtoken = group(22);

        try {
            file.setTimestamp(super.parseTimestamp(datestr));
        } catch (ParseException e) {
            return null; // this is a parsing failure too.
        }

        // bcdlfmpSs-
        switch (typeStr.charAt(0)) {
        case 'd':
            type = FTPFile.DIRECTORY_TYPE;
            break;
        case 'l':
            type = FTPFile.SYMBOLIC_LINK_TYPE;
            break;
        case 'b':
        case 'c':
            isDevice = true;
            // break; - fall through
        case 'f':
        case '-':
            type = FTPFile.FILE_TYPE;
            break;
        default:
            type = FTPFile.UNKNOWN_TYPE;
        }

        file.setType(type);

        int g = 4;
        for (int access = 0; access < 3; access++, g += 4) {
            // Use != '-' to avoid having to check for suid and sticky bits
            file.setPermission(access, FTPFile.READ_PERMISSION, (!group(g).equals("-")));
            file.setPermission(access, FTPFile.WRITE_PERMISSION, (!group(g + 1).equals("-")));

            String execPerm = group(g + 2);
            if (!execPerm.equals("-") && !Character.isUpperCase(execPerm.charAt(0))) {
                file.setPermission(access, FTPFile.EXECUTE_PERMISSION, true);
            } else {
                file.setPermission(access, FTPFile.EXECUTE_PERMISSION, false);
            }
        }

        if (!isDevice) {
            try {
                file.setHardLinkCount(Integer.parseInt(hardLinkCount));
            } catch (NumberFormatException e) {
                // intentionally do nothing
            }
        }

        file.setUser(usr);
        file.setGroup(grp);

        try {
            file.setSize(Long.parseLong(filesize));
        } catch (NumberFormatException e) {
            // intentionally do nothing
        }

        if (null == endtoken) {
            file.setName(name);
        } else {
            // oddball cases like symbolic links, file names
            // with spaces in them.
            name += endtoken;
            if (type == FTPFile.SYMBOLIC_LINK_TYPE) {

                int end = name.indexOf(" -> ");
                // Give up if no link indicator is present
                if (end == -1) {
                    file.setName(name);
                } else {
                    file.setName(name.substring(0, end));
                    file.setLink(name.substring(end + 4));
                }

            } else {
                file.setName(name);
            }
        }
        return file;
    }
    return null;
}

From source file:com.dulion.astatium.mesh.shredder.ContextManager.java

private void updateNameTrie(ContextChild child) {
    String name = child.getName().getLocalPart();

    putNameTrie(name, child.getName());//from   w  w w .  j  av a 2 s .c o  m

    int last = name.length() - 2;
    for (int i = 1; i <= last; i++) {
        if (Character.isUpperCase(name.charAt(i))) {
            putNameTrie(name.substring(i), child.getName());
        }
    }
}

From source file:org.ebayopensource.turmeric.eclipse.typelibrary.ui.wizards.pages.NewTypeLibraryWizardPage.java

/**
 * {@inheritDoc}//from w  w  w.  j a va  2  s  .co m
 */
@Override
protected boolean dialogChanged() {

    boolean result = super.dialogChanged();
    if (result) {
        // IStatus validationModel = null;
        try {
            if (SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry()
                    .getTypeLibrary(getResourceName()) != null) {
                updateStatus(super.getResourceNameText(),
                        "Type library with the same name already exists in the registry.");
                return false;
            }
        } catch (Exception e) {
            SOALogger.getLogger().error(e);
        }
        if (namespaceText != null) {
            try {
                new URI(namespaceText.getText());
            } catch (URISyntaxException e) {
                SOALogger.getLogger().error(e);
                updateStatus(namespaceText, "Invalid Namespace.");
                return false;
            }
        }
        if (StringUtils.isEmpty(getResourceName()) == false) {
            try {
                if (GlobalRepositorySystem.instanceOf().getActiveRepositorySystem().getTypeRegistryBridge()
                        .typeLibraryExists(getResourceName())) {
                    updateStatus(super.getResourceNameText(),
                            "A project with the same name already exists. Please choose a different name.");
                    return false;
                }
            } catch (Exception e) {
                SOALogger.getLogger().error(e);
                updateStatus(
                        "There are some problems in activating the registry. Please open the global registry view and do a manual refresh.");
                return false;
            }
        }

        if (validateNamespaceAndTypesDuplicated() == false) {
            return false;
        }

        String tlName = this.getResourceName();
        if (StringUtils.isEmpty(tlName) == false && Character.isUpperCase(tlName.charAt(0)) == false) {
            IStatus status = EclipseMessageUtils.createStatus(
                    "By convention Type Library name should start with uppercase.", IStatus.WARNING);
            updatePageStatus(getResourceNameText(), status);
            return true;
        }
    }
    return result;
}

From source file:com.tc.utils.StrUtils.java

public static boolean isUpperCase(char c) {
    return Character.isUpperCase(c);
}

From source file:com.duowan.common.spring.jdbc.BeanPropertyRowMapper.java

/**
 * Convert a name in camelCase to an underscored name in lower case.
 * Any upper case letters are converted to lower case with a preceding underscore.
 * @param name the string containing original name
 * @return the converted name//from   www  .  j a  va  2  s.co m
 */
private String underscoreName(String name) {
    StringBuilder result = new StringBuilder();
    if (name != null && name.length() > 0) {
        result.append(name.substring(0, 1).toLowerCase());
        for (int i = 1; i < name.length(); i++) {
            char c = name.charAt(i);
            if (Character.isUpperCase(c) && !Character.isDigit(c)) {
                result.append("_");
                result.append(Character.toLowerCase(c));
            } else {
                result.append(c);
            }
        }
    }
    return result.toString();
}

From source file:org.ng200.openolympus.Application.java

private void reportMissingLocalisationKey(final String code) {
    try {/*from  www  .ja v a2  s  .  c o m*/
        if (code.isEmpty() || Character.isUpperCase(code.charAt(0))) {
            return;
        }
        final File file = new File(new File(StorageSpace.STORAGE_PREFIX), "missingLocalisation.txt");
        if (!file.exists()) {
            file.getParentFile().mkdirs();
            file.createNewFile();
        }
        final Set<String> s = new TreeSet<>(Arrays.asList(FileUtils.readFileToString(file).split("\n")));
        s.add(code);
        FileUtils.writeStringToFile(file, s.stream().collect(Collectors.joining("\n")));
    } catch (final IOException e) {
        Application.logger.error("Couldn't add to missing key repo: {}", e);
    }
}

From source file:ca.sqlpower.persistance.CatNap.java

/**
 * Converts camelCaps strings into their equivalent strings having
 * underscores instead of camelCaps.  For example,
 * <tt>richardStallmanCantReadThisBecauseHeIsDyslexic</tt> becomes
 * <tt>richard_stallman_cant_read_this_because_he_is_dyslexic</tt>.
 *
 * @param camel The string to convert.  Must not be null.
 * @return The converted string./*from  w w w . j a  v  a 2s. co m*/
 */
public static String camelToUnderscore(String camel) {
    StringBuffer result = new StringBuffer(camel.length() * 2);
    for (char ch : camel.toCharArray()) {
        if (Character.isUpperCase(ch)) {
            result.append('_');
            result.append(Character.toLowerCase(ch));
        } else {
            result.append(ch);
        }
    }
    return result.toString();
}

From source file:org.jboss.loom.utils.Utils.java

/**
 *  Extracts all String getters properties to a map.
 *  @see also @Property.Utils.convert*()
 */// w  w w . j  a v a  2  s.c o m
public static Map<String, String> describeBean(IConfigFragment bean) {

    Map<String, String> ret = new LinkedHashMap();

    Method[] methods = bean.getClass().getMethods();
    for (Method method : methods) {
        boolean get = false;
        String name = method.getName();

        // Only use getters which return String.
        if (method.getParameterTypes().length != 0)
            continue;
        if (!method.getReturnType().equals(String.class))
            continue;
        if (name.startsWith("get"))
            get = true;
        if (!(get || name.startsWith("is")))
            continue;

        // Remove "get" or "is".
        name = name.substring(get ? 3 : 2);
        // Uncapitalize, unless it's getDLQJNDIName.
        if (name.length() > 1 && !Character.isUpperCase(name.charAt(2)))
            name = StringUtils.uncapitalize(name);

        try {
            ret.put(name, (String) method.invoke(bean));
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
            log.warn("Failed extracting property from " + bean.getClass().getSimpleName() + ":\n    "
                    + ex.getMessage(), ex);
        }
    }
    return ret;
}