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:org.apache.openjpa.jdbc.meta.ReverseMappingTool.java

/**
 * Return true if the given string is all uppercase letters.
 *//*  w ww .  j ava2  s.  co  m*/
private static boolean allUpperCase(String str) {
    for (int i = 0; i < str.length(); i++) {
        if (Character.isLetter(str.charAt(i)) && !Character.isUpperCase(str.charAt(i)))
            return false;
    }
    return true;
}

From source file:org.getobjects.appserver.core.WOApplication.java

/**
 * Loads the configuration for the application. This is called very early in
 * the configuration process because settings like WOCachingEnabled affect
 * subsequent initialization.// w ww .ja va2  s.  c  om
 * <p>
 * Properties will be loaded in order from:
 * <ul>
 *   <li>Defaults.properties in the Go package
 *   <li>Defaults.properties in your application package
 *   <li>ApplicationName.properties in the current directory (user.dir)
 * </ul>
 */
protected void loadProperties() {
    InputStream in;

    final Properties sysProps = System.getProperties();
    this.properties = new Properties();

    /* First load the internal properties of WOApplication */
    in = WOApplication.class.getResourceAsStream("Defaults.properties");
    if (!this.loadProperties(in))
        log.error("failed to load Defaults.properties of WOApplication");

    /* Try to load the Defaults.properties resource which is located
     * right beside the WOApplication subclass.
     */
    in = this.getClass().getResourceAsStream("Defaults.properties");
    if (!this.loadProperties(in))
        log.error("failed to load Defaults.properties of application");

    /* Load configuration from the current directory. We might want
     * to change the lookup strategy ...
     */
    File f = this.userDomainPropertiesFile();
    if (f != null && f.exists()) {
        try {
            in = new FileInputStream(f);
            if (!this.loadProperties(in))
                log.error("failed to load user domain properties: " + f);
            else
                log.info("did load user domain properties: " + f);
        } catch (FileNotFoundException e) {
            log.error("did not find user domains file: " + f);
        }
    }

    for (Object key : sysProps.keySet()) {
        /* we add all keys starting with uppercase, weird, eh?! ;-)
         * this passes through WOxyz stuff and avoids the standard Java props
         */
        if (!(key instanceof String))
            continue;
        if (Character.isUpperCase(((String) key).charAt(0)))
            this.properties.put(key, sysProps.get(key));
    }

    /* Finally, add volatile properties set by the adapter */
    if (this.volatileProperties != null) {
        for (Object key : this.volatileProperties.keySet()) {
            if (!(key instanceof String))
                continue;
            this.properties.put(key, this.volatileProperties.get(key));
        }
    }
}

From source file:org.apache.openjpa.util.ProxyManagerImpl.java

/**
 * Return whether the target string stars with the given token.
 *///from  ww w .  j  a  v  a2s. c  o m
private static boolean startsWith(String str, String token) {
    return str.startsWith(token)
            && (str.length() == token.length() || Character.isUpperCase(str.charAt(token.length())));
}

From source file:org.anurag.file.quest.FileQuestHD.java

/**
 * this function finds the device information and sets in drawer menu....
 *//*from  w ww. ja  v  a2s. c o  m*/
private void init_with_device_id() {
    TextView devId = (TextView) findViewById(R.id.dev_id);
    String dev = Build.MODEL;
    String man = Build.MANUFACTURER;
    if (dev.length() == 0 || dev == null)
        dev = getString(R.string.unknown);
    else {
        if (!dev.contains(man))
            dev = man + " " + dev;
        char a = dev.charAt(0);
        if (!Character.isUpperCase(a)) {
            dev = Character.toUpperCase(a) + dev.substring(1);
        }
    }
    devId.setText(dev);
}

From source file:com.liferay.portal.tools.service.builder.ServiceBuilder.java

public boolean isHBMCamelCasePropertyAccessor(String propertyName) {
    if (propertyName.length() < 3) {
        return false;
    }//  w w  w  . j a v a 2s  . c om

    char[] chars = propertyName.toCharArray();

    char c0 = chars[0];
    char c1 = chars[1];
    char c2 = chars[2];

    if (Character.isLowerCase(c0) && Character.isUpperCase(c1) && Character.isLowerCase(c2)) {

        return true;
    }

    return false;
}

From source file:de.innovationgate.wga.model.WGADesignConfigurationModel.java

@Override
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<ValidationError>();

    // validate publisher options only valid with defined values
    PublisherOption pOption = getPublisherOption(PublisherOption.OPTION_BROWSING_SECURITY);
    if (pOption != null) {
        try {//from   w  ww. j  a v a  2 s. c o m
            int browsingSecurity = Integer.parseInt(pOption.getValue());
            if (BROWSINGSECURITY_VALUES.get(browsingSecurity) == null) {
                errors.add(new ValidationError(
                        "Unknown value '" + browsingSecurity + "' for option 'BrowsingSecurity'.",
                        new String[] { "publisherOptions" }));
            }
        } catch (NumberFormatException e) {
            errors.add(new ValidationError("Cannot interpret 'BrowsingSecurity' as int.",
                    new String[] { "publisherOptions" }));
        }
    }
    if (!errors.isEmpty()) {
        return errors;
    }

    if (_csConfig instanceof de.innovationgate.wga.common.beans.csconfig.v4.CSConfig) {
        try {
            Version newV = new Version(_minimumWGAVersion);
            ((de.innovationgate.wga.common.beans.csconfig.v4.CSConfig) _csConfig).setMinimumWGAVersion(newV);
        } catch (RuntimeException e) {
            // unparsable version
            errors.add(new ValidationError("Invalid version format.", new String[] { "minimumWGAVersion" }));
        }
    }

    if (hasPluginConfig()) {
        try {
            Version newV = new Version(_pluginVersion);
            newV.setBuildVersion(_pluginBuild);
            _csConfig.getPluginConfig().getId().setVersion(newV);
        } catch (RuntimeException e) {
            // unparsable version
            errors.add(new ValidationError("Invalid version format.", new String[] { "pluginVersion" }));
        }

        try {
            Version newV = new Version(_pluginWGAVersion);
            _csConfig.getPluginConfig().setMinimumWGAVersion(newV);
            loadVersionProperties();
        } catch (RuntimeException e) {
            if (!(_csConfig instanceof de.innovationgate.wga.common.beans.csconfig.v4.CSConfig)) {
                // unparsable version
                errors.add(new ValidationError("Invalid version format.", new String[] { "pluginWGAVersion" }));
            }
        }

        try {
            Version newV = new Version(_pluginJavaVersion);
            _csConfig.getPluginConfig().setMinimumJavaVersion(newV);
        } catch (RuntimeException e) {
            // unparsable version
            errors.add(new ValidationError("Invalid version format.", new String[] { "pluginJavaVersion" }));
        }

        if (isPluginDisableInit()) {
            if (!(_csConfig
                    .getPluginConfig() instanceof de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig)) {
                errors.add(new ValidationError(
                        "Plugin initialisation functionalities can only be disabled with WGA5 compatibility or higher.",
                        new String[] { "versionCompliance", "pluginDisableInit" }));
            }
        }

        if (isPluginClearDatabaseOnUpdate()) {
            if (!(_csConfig
                    .getPluginConfig() instanceof de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig)) {
                errors.add(new ValidationError(
                        "Clear plugin database on plugin update can only be enabled with WGA5 compatibility or higher.",
                        new String[] { "versionCompliance", "pluginClearDatabaseOnUpdate" }));
            }
        }

        if (getPluginPersonalisationMode() != null
                && getPluginPersonalisationMode().getKey().equals(Constants.PERSMODE_SESSION)) {
            if (!getVersionCompliance().toWGAVersion().isAtLeast(6, 0)) {
                errors.add(new ValidationError("Session based personalisation requires WGA 6.0 or higher.",
                        new String[] { "versionCompliance", "pluginPersonalisationMode" }));
            }
        }

        if (isOverlay() && _csConfigBase != null) {
            // check if base plugin is in dependency list
            boolean baseDependencyDefined = false;
            PluginID baseID = _csConfigBase.getPluginConfig().getId();
            for (PluginID dependency : getPluginDependencies()) {
                if (dependency.getUniqueName().equals(baseID.getUniqueName())
                        && dependency.getVersion().isAtLeast(baseID.getVersion())) {
                    baseDependencyDefined = true;
                    break;
                }
            }

            if (!baseDependencyDefined) {
                errors.add(new ValidationError(
                        "Dependency to base plugin '" + baseID.getUniqueName() + " (>="
                                + baseID.getVersion().getMainVersionString() + ")' is not defined.",
                        new String[] { "pluginDependencies" }));
            }
        }
    }

    // Prevent HDB enabling with Non-WGA4-Compatibility
    PublisherOption option = _csConfig.findPublisherOption("isHDB");
    boolean hdbEnabled = (option != null && option.getValue().equals("true"));
    if (hdbEnabled) {
        if (_csConfig.getVersionCompliance().equals(CSConfig.VERSIONCOMPLIANCE_WGA3)) {
            errors.add(
                    new ValidationError("HDB interface can only be enabled with WGA4 compatibility or higher.",
                            new String[] { "versionCompliance", "usesHDB" }));
        }
    }

    // Prevent Disconnection Script with Non-WGA5-Compatibility
    if (getDisconnectionScript() != null && getDisconnectionScript().trim().length() > 0) {
        if (!(_csConfig instanceof de.innovationgate.wga.common.beans.csconfig.v3.CSConfig)) {
            errors.add(new ValidationError(
                    "Disconnection script can only be enabled with WGA5 compatibility or higher.",
                    new String[] { "versionCompliance", "disconnectionScript" }));
        }
    }

    if (isStaticClasspath()) {
        if (!(_csConfig instanceof de.innovationgate.wga.common.beans.csconfig.v3.CSConfig)) {
            errors.add(new ValidationError(
                    "Prevent reloading of java libraries can only be enabled with WGA5 compatibility or higher.",
                    new String[] { "versionCompliance", "staticClasspath" }));
        }
    }

    // Prevent Admin App enabling with Non-WGA5-Compat.
    if (isAdminApp()) {
        if (_csConfig.getVersionCompliance().equals(CSConfig.VERSIONCOMPLIANCE_WGA3)
                || _csConfig.getVersionCompliance().equals(CSConfig.VERSIONCOMPLIANCE_WGA4)
                || _csConfig.getVersionCompliance().equals(CSConfig.VERSIONCOMPLIANCE_WGA41)) {
            errors.add(new ValidationError(
                    "Admin application can only be enabled for WGA5 compatibility or higher.",
                    new String[] { "versionCompliance", "adminApp" }));
        }
    }

    // Validate role names
    Iterator<ACLRole> roles = getACLRoles().iterator();
    while (roles.hasNext()) {
        ACLRole role = (ACLRole) roles.next();
        if (!Constants.PATTERN_ROLENAMES.matcher(role.getName()).matches()) {
            errors.add(new ValidationError("Role name '" + role.getName()
                    + "' is invalid. Use only international alphanumeric characters and the symbols -, _, $, #, [ and ]",
                    new String[] { "aclRoles" }));
        }
    }

    if (_csConfig instanceof de.innovationgate.wga.common.beans.csconfig.v2.CSConfig) {
        de.innovationgate.wga.common.beans.csconfig.v2.CSConfig v2 = (de.innovationgate.wga.common.beans.csconfig.v2.CSConfig) _csConfig;
        Iterator<Shortcut> shortcuts = v2.getShortcuts().iterator();
        while (shortcuts.hasNext()) {
            Shortcut shortcut = shortcuts.next();
            if (WGUtils.isEmpty(shortcut.getShortcut())) {
                errors.add(new ValidationError("A shortcut has no name", new String[] { "shortcuts" }));
            } else if (WGUtils.isEmpty(shortcut.getReference())) {
                errors.add(new ValidationError("The shortcut '" + shortcut.getShortcut() + "' has no reference",
                        new String[] { "shortcuts" }));
            } else if (shortcut.getType() == Shortcut.TYPE_TMLSCRIPT_GLOBAL) {
                if (!Character.isUpperCase(shortcut.getShortcut().charAt(0))) {
                    errors.add(new ValidationError("The TMLScript global shortcut '" + shortcut.getShortcut()
                            + "' must start with an uppercase letter.", new String[] { "shortcuts" }));
                }
            }

        }
    }

    if (hasPluginConfig()) {
        // Validate plugin id
        PluginConfig pc = _csConfig.getPluginConfig();
        PluginID id = pc.getId();

        errors.addAll(validatePluginUniqueName(getPluginUniqueName()));

        // Validate plugin dependencies
        Iterator<PluginID> dependencies = pc.getDependencies().iterator();
        while (dependencies.hasNext()) {
            PluginID did = (PluginID) dependencies.next();
            if (did.getUniqueName() == null || did.getUniqueName().trim().equals("")) {
                errors.add(new ValidationError("Unique name of plugin dependency should not be empty.",
                        new String[] { "pluginDependencies" }));
            } else if (did.getUniqueName().contains(" ")) {
                errors.add(
                        new ValidationError("Unique name of plugin dependency should not contain white spaces.",
                                new String[] { "pluginDependencies" }));
            }
        }

        // Validate relation between minimum WGA version and WGA compatibility version
        Version minWGAVersion = _csConfig.getPluginConfig().getMinimumWGAVersion();
        String affectedVersionField = "pluginWGAVersion";
        if (_csConfig instanceof de.innovationgate.wga.common.beans.csconfig.v4.CSConfig) {
            minWGAVersion = ((de.innovationgate.wga.common.beans.csconfig.v4.CSConfig) _csConfig)
                    .getMinimumWGAVersion();
            affectedVersionField = "minimumWGAVersion";
        }
        float fMinimumWGAVersion = Float
                .valueOf(minWGAVersion.getMajorVersion() + "." + minWGAVersion.getMinorVersion());
        float compatibilityWGAVersion = Float.valueOf(_csConfig.getVersionCompliance().substring(3));
        if (fMinimumWGAVersion < compatibilityWGAVersion) {
            errors.add(new ValidationError(
                    "The minimum WGA version is lower than the version chosen in 'Version compliance'",
                    new String[] { affectedVersionField, "versionCompliance" }));
        }
        if (minWGAVersion.isAtLeast(6, 0)
                && !_csConfig.getPluginConfig().getMinimumJavaVersion().isAtLeast(1, 6)) {
            errors.add(
                    new ValidationError("Invalid Java version. OpenWGA >= 6.0 requires Java 1.6.0 or higher.",
                            new String[] { "pluginJavaVersion" }));
        } else if (minWGAVersion.isAtLeast(5, 0)
                && !_csConfig.getPluginConfig().getMinimumJavaVersion().isAtLeast(1, 5)) {
            errors.add(
                    new ValidationError("Invalid Java version. OpenWGA >= 5.0 requires Java 1.5.0 or higher.",
                            new String[] { "pluginJavaVersion" }));
        }
    }

    if (getBrowsingSecurity() == null) {
        errors.add(new ValidationError("Unknown value for 'BrowsingSecurity'.",
                new String[] { "publisherOptions" }));
    } else {
        // Prevent BrowsingSecurity other than default for WGA < 5.3.
        if (!getBrowsingSecurity().getKey().equals(BrowsingSecurity.FULL_ACCESS)) {
            if (!getVersionCompliance().toWGAVersion().isAtLeast(5, 3)) {
                errors.add(new ValidationError(
                        "Browsing security can only be enabled for WGA 5.3 compatibility or higher.",
                        new String[] { "versionCompliance", "browsingSecurity" }));
            }
        }
    }

    if (getVersionCompliance().toWGAVersion().isAtLeast(6, 0)) {
        // validate accesslevels
        if (getAnonymousAccessLevel() != null) {
            if (getAnonymousAccessLevel().getKey() == AccessLevel.LEVEL_READER_DESIGNER) {
                errors.add(new ValidationError(
                        "Access level 'Reader/Designer' has been removed in OpenWGA 6.0 and later. Please change to 'Reader'.",
                        new String[] { "anonymousAccessLevel" }));
            } else if (getAnonymousAccessLevel().getKey() == AccessLevel.LEVEL_AUTHOR_DESIGNER) {
                errors.add(new ValidationError(
                        "Access level 'Author/Designer' has been removed in OpenWGA 6.0 and later. Please change to 'Author'.",
                        new String[] { "anonymousAccessLevel" }));
            } else if (getAnonymousAccessLevel().getKey() == AccessLevel.LEVEL_EDITOR_DESIGNER) {
                errors.add(new ValidationError(
                        "Access level 'Editor/Designer' has been removed in OpenWGA 6.0 and later. Please change to 'Editor'.",
                        new String[] { "anonymousAccessLevel" }));
            }
        }
        if (getDefaultAccessLevel() != null) {
            if (getDefaultAccessLevel().getKey() == AccessLevel.LEVEL_READER_DESIGNER) {
                errors.add(new ValidationError(
                        "Access level 'Reader/Designer' has been removed in OpenWGA 6.0 and later. Please change to 'Reader'.",
                        new String[] { "defaultAccessLevel" }));
            } else if (getDefaultAccessLevel().getKey() == AccessLevel.LEVEL_AUTHOR_DESIGNER) {
                errors.add(new ValidationError(
                        "Access level 'Author/Designer' has been removed in OpenWGA 6.0 and later. Please change to 'Author'.",
                        new String[] { "defaultAccessLevel" }));
            } else if (getDefaultAccessLevel().getKey() == AccessLevel.LEVEL_EDITOR_DESIGNER) {
                errors.add(new ValidationError(
                        "Access level 'Editor/Designer' has been removed in OpenWGA 6.0 and later. Please change to 'Editor'.",
                        new String[] { "defaultAccessLevel" }));
            }
        }
        if (getRemoteActions() != null) {
            for (RemoteAction remoteAction : getRemoteActions()) {
                if (remoteAction.getCallerLevel() == AccessLevel.LEVEL_READER_DESIGNER) {
                    errors.add(new ValidationError(
                            "Remote action specifies invalid access level 'Reader/Designer'. Please change to 'Reader'.",
                            new String[] { "remoteActions" }));
                    break;
                } else if (remoteAction.getCallerLevel() == AccessLevel.LEVEL_AUTHOR_DESIGNER) {
                    errors.add(new ValidationError(
                            "Remote action specifies invalid access level 'Author/Designer'. Please change to 'Author'.",
                            new String[] { "remoteActions" }));
                    break;
                } else if (remoteAction.getCallerLevel() == AccessLevel.LEVEL_EDITOR_DESIGNER) {
                    errors.add(new ValidationError(
                            "Remote action specifies invalid access level 'Editor/Designer'. Please change to 'Editor'.",
                            new String[] { "remoteActions" }));
                    break;
                }
            }
        }
    }

    return errors;
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java

/**
 * Split apart the name keying on upper case
 * @param nameToFix the name of the field
 * @return the split apart name//from   www .j  ava2 s .co m
 */
protected String fixName(final String nameToFix) {
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < nameToFix.length(); i++) {
        if (i == 0) {
            s.append(Character.toUpperCase(nameToFix.charAt(i)));
        } else {
            char c = nameToFix.charAt(i);
            if (Character.isUpperCase(c)) {
                s.append(' ');
            }
            s.append(c);
        }
    }
    return s.toString();
}

From source file:coreferenceresolver.process.FeatureExtractor.java

public static Boolean isProperName(NounPhrase np) {
    //if the first letter of word is lettercase -> false, else continure checking
    if (Character.isUpperCase(np.getNpNode().getLeaves().get(0).toString().charAt(0))) {
        //if the NP is single word
        if (np.getNpNode().numChildren() == 1) {
            //if the NP is in the Dictionary -> false, else -> True
            if (sDict.contains(";" + np.getNpNode().getLeaves().get(0).toString().toLowerCase() + ";")) {
                return false;
            } else {
                return true;
            }/*  w  w  w  .j a v a  2 s. co m*/
        } //if the NP is compound word
        else {
            // because "of" and "and" don't need to upper in Proper name, so check.
            for (int i = 0; i < np.getNpNode().getLeaves().size(); i++) {
                if ((np.getNpNode().getLeaves().get(i).toString().equals("of"))
                        || (np.getNpNode().getLeaves().get(i).toString().equals("and"))
                        || (DETERMINERS.contains(np.getNpNode().getLeaves().get(i).toString().toLowerCase()))) {
                } else {
                    if (Character.isLowerCase(np.getNpNode().getLeaves().get(i).toString().charAt(0))) {
                        return false;
                    } else {
                    }
                }
            }
            return true;
        }
    } else {
        return false;
    }
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Takes a string and separates the 'names' inside by the capitial letters.
 * @param nameToFix the name to fix/*from   ww w .ja  va 2 s . com*/
 * @return the new name with spaces in it
 */
public static String makeNamePretty(final String nameToFix) {
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < nameToFix.length(); i++) {
        if (i == 0) {
            s.append(Character.toUpperCase(nameToFix.charAt(i)));
        } else {
            char c = nameToFix.charAt(i);
            if (Character.isUpperCase(c)) {
                s.append(' ');
            }
            s.append(c);
        }
    }
    return s.toString();
}