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.sd.token.StandardTokenizerOptions.java

public boolean isLowerCase(int codePoint) {
    boolean result = Character.isLowerCase(codePoint);

    if (!result && symbolLowersCodePoints != null) {
        result = symbolLowersCodePoints.contains(codePoint);
    }/*from  ww  w  .  ja va  2s. co m*/

    return result;
}

From source file:org.codehaus.groovy.grails.commons.GrailsClassUtils.java

/**
 * Converts a property name into its natural language equivalent eg ('firstName' becomes 'First Name')
 * @param name The property name to convert
 * @return The converted property name//w  w w. j a  va 2s .  c  o m
 *
 * @deprecated Use {@link grails.util.GrailsNameUtils#getNaturalName(String)} instead.
 */
@Deprecated
public static String getNaturalName(String name) {
    List<String> words = new ArrayList<String>();
    int i = 0;
    char[] chars = name.toCharArray();
    for (int j = 0; j < chars.length; j++) {
        char c = chars[j];
        String w;
        if (i >= words.size()) {
            w = "";
            words.add(i, w);
        } else {
            w = words.get(i);
        }

        if (Character.isLowerCase(c) || Character.isDigit(c)) {
            if (Character.isLowerCase(c) && w.length() == 0) {
                c = Character.toUpperCase(c);
            } else if (w.length() > 1 && Character.isUpperCase(w.charAt(w.length() - 1))) {
                w = "";
                words.add(++i, w);
            }

            words.set(i, w + c);
        } else if (Character.isUpperCase(c)) {
            if ((i == 0 && w.length() == 0) || Character.isUpperCase(w.charAt(w.length() - 1))) {
                words.set(i, w + c);
            } else {
                words.add(++i, String.valueOf(c));
            }
        }
    }

    StringBuilder buf = new StringBuilder();
    for (Iterator<String> j = words.iterator(); j.hasNext();) {
        buf.append(j.next());
        if (j.hasNext()) {
            buf.append(' ');
        }
    }
    return buf.toString();
}

From source file:org.sigmah.client.util.ClientUtils.java

/**
 * <p>/* w w w .j av  a  2  s  .  c o  m*/
 * Uncapitalizes a String changing the first letter to title case as per {@link Character#toLowerCase(char)}. No other
 * letters are changed.
 * </p>
 * <p>
 * A {@code null} input String returns {@code null}.
 * </p>
 * 
 * <pre>
 * StringUtils.uncapitalize(null)  = null
 * StringUtils.uncapitalize("")    = ""
 * StringUtils.uncapitalize("Cat") = "cat"
 * StringUtils.uncapitalize("CAT") = "cAT"
 * </pre>
 * 
 * @param str
 *          the String to uncapitalize, may be null
 * @return the uncapitalized String, {@code null} if null String input
 * @see #capitalize(String)
 */
public static String uncapitalize(final String str) {

    int strLen;
    if (str == null || (strLen = str.length()) == 0) {
        return str;
    }

    char firstChar = str.charAt(0);
    if (Character.isLowerCase(firstChar)) {
        // already uncapitalized
        return str;
    }

    return new StringBuilder(strLen).append(Character.toLowerCase(firstChar)).append(str.substring(1))
            .toString();

}

From source file:org.ebayopensource.turmeric.eclipse.services.ui.wizards.pages.ConsumerFromExistingWSDLWizardPage.java

/**
 * {@inheritDoc}//w  w w  . j  a va  2 s .  c o  m
 */
@Override
protected boolean dialogChanged() {
    if (super.dialogChanged(false) == false && isPageComplete() == false) {
        return false;
    }

    if (publicServiceNameText != null && (validateName(publicServiceNameText, getPublicServiceName(),
            RegExConstants.SERVICE_NAME_EXP,
            "The service name [" + getPublicServiceName() + "] in WSDL file is not valid against the pattern \""
                    + RegExConstants.SERVICE_NAME_EXP
                    + "\". Please correct service name in WSDL and run this wizard again.") == false)) {
        return false;
    }

    // Client name is consumer project name and admin name is the service
    // interface project name. They should not be the same.
    if (this.serviceClientText != null && adminNameText != null) {
        String clientName = serviceClientText.getText();
        String adminName = adminNameText.getText();
        if (StringUtils.equalsIgnoreCase(clientName, adminName) == true) {
            updateStatus("Admin Name and Client Name should not be the same.", serviceClientText,
                    adminNameText);
            return false;
        }
    }

    if (this.serviceClientText != null) {
        if (StringUtils.isBlank(getClientName())) {
            updateStatus(this.serviceClientText, "Client name must be specified");
            return false;
        }
        if (StringUtils.equals(StringUtils.capitalize(getClientName()), getClientName()) == false) {
            updateStatus(this.serviceClientText, "Client name must be capitalized.");
            return false;
        }
        if (validateName(this.serviceClientText, getClientName(), RegExConstants.PROJECT_NAME_EXP,
                ErrorMessage.PROJECT_NAME_ERRORMSG + " The name [" + getClientName()
                        + "] is not valid against the pattern \"" + RegExConstants.PROJECT_NAME_EXP
                        + "\"") == false) {
            return false;
        }
    }

    if (envrionmentList != null) {
        if (environments.isEmpty() && this.simpleMode == false) {
            updateStatus(envrionmentList.getControl(), "At least one environment must be added");
            return false;
        }
    }

    // String version = resourceVersionText.getText();
    // if (StringUtils.isNotBlank(version) &&
    // (isV2Format == true)) {
    // // version from WSDL is X.Y, only maintenance version should be
    // changed.
    // Version newVer = new Version(version);
    // Version oldVer = new Version(versionFromWSDL);
    // if ((newVer.getMajor() != oldVer.getMajor())
    // || (newVer.getMinor() != oldVer.getMinor())) {
    // updateStatus(super.resourceVersionText,
    // "Service version from WSDL is: "+versionFromWSDL +
    // ". You can not change the major and minor version. The version must start with->"
    // + versionFromWSDL);
    // return false;
    // }
    // }

    /*
     * 1) If service version in WSDL follows V3 format, like 1.2.3, service
     * version text will not be editable. 2) If service version in WSDL
     * doesnt follow V3 format, like 1.2, 1.2,3, 1, 1.a, 1.2.a, then
     * service version text is editable. BUT even user specified a correct
     * V3 version, there will be an error marker on the service version text
     * says Specified service version [1.2.3] does not match service version
     * in WSDL [1.2]. Please modify service version in source WSDL and
     * follow format {major.minor.maintance}. It means the WSDL file used
     * in wizard must contain a correct V3 format service version.
     * Otherwise, the wizard couldnt continue.
     */

    if ((versionFromWSDL != null && resourceVersionText != null)
            && versionFromWSDL.equals(getResourceVersion()) == false) {
        String errorMsg = StringUtil.formatString(SOAMessages.DIFFERENT_SERVICE_VERSION_WITH_WSDL,
                getResourceVersion(), versionFromWSDL);
        updateStatus(super.resourceVersionText, errorMsg);
        return false;
    }

    if (domainClassifierList != null && StringUtils.isNotBlank(getDomainClassifier()) && this.wsdl != null) {
        String namespacePart = getOrganizationProvider()
                .getNamespacePartFromTargetNamespace(this.wsdl.getTargetNamespace());
        if (StringUtils.isNotBlank(namespacePart) && namespacePart.equals(getDomainClassifier()) == false) {
            // user has selected a namespace part that not match the ns-part
            // from the wsdl file
            updateStatus(super.domainClassifierList,
                    StringUtil.formatString(SOAMessages.ERR_WRONG_NAMESPACEPART, getDomainClassifier(),
                            this.wsdl.getTargetNamespace()));
            return false;
        }
    }

    if (StringUtils.isNotEmpty(getResourceName()) && Character.isLowerCase(getResourceName().charAt(0))) {
        updatePageStatus(getResourceNameText(),
                EclipseMessageUtils.createStatus(SOAMessages.SVCNAME_ERR, Status.WARNING));
        return true;
    }

    return true;
}

From source file:org.ebayopensource.turmeric.eclipse.services.ui.wizards.pages.ConsumeServiceFromExistingWSDLWizardPage.java

@Override
protected boolean dialogChanged() {

    if (super.dialogChanged() == false && isPageComplete() == false)
        return false;

    if (publicServiceNameText != null && (validateName(publicServiceNameText, getPublicServiceName(),
            RegExConstants.SERVICE_NAME_EXP,
            "The service name [" + getPublicServiceName() + "] in WSDL file is not valid against the pattern \""
                    + RegExConstants.SERVICE_NAME_EXP
                    + "\". Please correct service name in WSDL and run this wizard again.") == false)) {
        return false;
    }//from  w w w .  ja  v  a2 s  . c om

    /*
     * 1) If service version in WSDL follows V3 format, like 1.2.3, service
     * version text will not be editable. 2) If service version in WSDL
     * doesnt follow V3 format, like 1.2, 1.2,3, 1, 1.a, 1.2.a, then
     * service version text is editable. BUT even user specified a correct
     * V3 version, there will be an error marker on the service version text
     * says Specified service version [1.2.3] does not match service version
     * in WSDL [1.2]. Please modify service version in source WSDL and
     * follow format {major.minor.maintenance}. It means the WSDL file used
     * in wizard must contain a correct V3 format service version.
     * Otherwise, the wizard couldnt continue.
     */

    if ((versionFromWSDL != null && resourceVersionText != null)
            && versionFromWSDL.equals(getResourceVersion()) == false) {
        String errorMsg = StringUtil.formatString(SOAMessages.DIFFERENT_SERVICE_VERSION_WITH_WSDL,
                getResourceVersion(), versionFromWSDL);
        updateStatus(super.resourceVersionText, errorMsg);
        return false;
    }

    if (domainClassifierList != null && StringUtils.isNotBlank(getDomainClassifier()) && this.wsdl != null) {
        String namespacePart = getOrganizationProvider()
                .getNamespacePartFromTargetNamespace(this.wsdl.getTargetNamespace());
        if (StringUtils.isNotBlank(namespacePart) && namespacePart.equals(getDomainClassifier()) == false) {
            // user has selected a namespace part that not match the ns-part
            // from the wsdl file
            updateStatus(super.domainClassifierList,
                    StringUtil.formatString(SOAMessages.ERR_WRONG_NAMESPACEPART, getDomainClassifier(),
                            this.wsdl.getTargetNamespace()));
            return false;
        }
    }

    if (this.serviceClientText != null) {
        if (StringUtils.isBlank(getClientName())) {
            updateStatus(this.serviceClientText, "Client name must be specified");
            return false;
        }
        if (StringUtils.equals(StringUtils.capitalize(getClientName()), getClientName()) == false) {
            updateStatus(this.serviceClientText, "Client name must be capitalized.");
            return false;
        }
        if (validateName(this.serviceClientText, getClientName(), RegExConstants.PROJECT_NAME_EXP,
                ErrorMessage.PROJECT_NAME_ERRORMSG + " The name [" + getClientName()
                        + "] is not valid against the pattern \"" + RegExConstants.PROJECT_NAME_EXP
                        + "\"") == false) {
            return false;
        }
    }

    if (StringUtils.isNotEmpty(getResourceName()) && Character.isLowerCase(getResourceName().charAt(0))) {
        updatePageStatus(getResourceNameText(),
                EclipseMessageUtils.createStatus(SOAMessages.SVCNAME_ERR, IStatus.WARNING));
        return true;
    }

    return true;
}

From source file:com.flexive.shared.scripting.groovy.GroovyTypeBuilder.java

@SuppressWarnings({ "unchecked" })
@Override/* ww w  .ja v  a 2 s  . c  o m*/
protected Object createNode(Object name, Map attributes, Object value) {
    final String structureName = (String) name;
    final AttributeMapper am = new AttributeMapper(attributes, value, structureName);
    if (this.type == null) {
        // setGeneralACL if passed as param
        setGeneralAcl(attributes);
        // check if called for an existing type
        if (CacheAdmin.getEnvironment().typeExists(structureName)) {
            this.type = CacheAdmin.getEnvironment().getType(structureName);
            return new Node();
        }

        // AttributeMapper
        am.setStructureAttributes(acl);

        try { // root node, create type
            final FxType parentType = am.parentTypeName != null
                    ? CacheAdmin.getEnvironment().getType(am.parentTypeName)
                    : null;
            final FxTypeEdit type;
            if (parentType == null) {
                type = FxTypeEdit.createNew(structureName, am.label, am.acl, null);
            } else {
                type = FxTypeEdit.createNew(structureName,
                        am.attributes.containsKey("label") ? am.label : parentType.getLabel(),
                        am.attributes.containsKey("acl") ? am.acl : parentType.getACL(), parentType);
            }
            am.setTypeAttributes(type); // set type attributes

            final long typeId = EJBLookup.getTypeEngine().save(type);
            this.type = CacheAdmin.getEnvironment().getType(typeId);
            return new Node();
        } catch (FxApplicationException e) {
            throw e.asRuntimeException();
        }
    }

    am.setElementAttributes(acl);
    boolean hasParent = this.getCurrent() instanceof GroupAssignmentNode
            || this.getCurrent() instanceof GroupNode;
    // always reload the type
    type = CacheAdmin.getEnvironment().getType(type.getId());
    if (hasParent) {// set the parent xPath immed. for assignments and reload the type from the cache
        am.parentXPath = getXPathFromStructureName(structureName, true);
    }
    // name starts lowercase --> create property or property assignment
    if (Character.isLowerCase(structureName.charAt(0))) {
        if (am.assignment != null) { // create a new property assignment
            final FxAssignment fxAssignment = CacheAdmin.getEnvironment().getAssignment(
                    am.assignment.startsWith("/") ? type.getName() + am.assignment : am.assignment);
            try {
                return createNewPropertyAssignmentNode(fxAssignment, am);
            } catch (FxApplicationException e) {
                throw e.asRuntimeException();
            }
        } else {
            try {
                // existing property assignments
                if (CacheAdmin.getEnvironment().propertyExistsInType(type.getName(), am.structureName)
                        || structureAssignmentIsInType(structureName, hasParent, false)) {
                    final FxAssignment fxAssignment;

                    if (hasCreateUniqueOptions(attributes.keySet(), false))
                        return createNewPropertyNode(am);

                    am.isNew = false;
                    am.assignmentChanges = attributes.size() > 0;
                    final String xPath;
                    if (hasParent) {
                        if (CacheAdmin.getEnvironment()
                                .assignmentExists(getXPathFromStructureName(structureName, false)))
                            xPath = getXPathFromStructureName(structureName, false);
                        else // try an alias
                            xPath = getXPathFromAlias(am.structureName, false, true);

                    } else { // root
                        if (CacheAdmin.getEnvironment()
                                .assignmentExists(type.getName() + "/" + structureName.toUpperCase()))
                            xPath = type.getName() + "/" + structureName;
                        else // we might have a different alias
                            xPath = getXPathFromAlias(am.structureName, false, false);
                    }

                    if (xPath == null) // IF THE XPATH REMAINS NULL, WE ASSUME THAT A NEW PROPERTY HAVING THE SAME NAME MUST BE CREATED
                        return createNewPropertyNode(am);

                    // retrieve the fxAssignment and set the correct alias if applicable
                    fxAssignment = CacheAdmin.getEnvironment().getAssignment(xPath);
                    // also set the correct alias in the attributesmapper
                    if (!attributes.containsKey("alias")) {
                        am.alias = fxAssignment.getAlias();
                    }
                    return createNewPropertyAssignmentNode(fxAssignment, am);
                }
                // create a new property
                return createNewPropertyNode(am);

            } catch (FxApplicationException e) {
                throw e.asRuntimeException();
            }
        }
    } else { // name starts uppercase --> group
        if (am.assignment != null) { // create a new group assignment
            final FxAssignment fxAssignment = CacheAdmin.getEnvironment().getAssignment(
                    am.assignment.startsWith("/") ? type.getName() + am.assignment : am.assignment);
            try {
                return createNewGroupAssignmentNode(fxAssignment, am);
            } catch (FxApplicationException e) {
                throw e.asRuntimeException();
            }
        } else {
            try {
                // do not create a new group if it already exists - for calls to the builder to change or add existing assignments
                if (CacheAdmin.getEnvironment().groupExistsInType(type.getName(), am.structureName)
                        || structureAssignmentIsInType(structureName, hasParent, true)) {
                    final FxAssignment fxAssignment;

                    if (hasCreateUniqueOptions(attributes.keySet(), true))
                        return createNewGroupNode(am);

                    am.isNew = false;
                    am.assignmentChanges = attributes.size() > 0;
                    final String xPath;
                    if (hasParent) {
                        if (CacheAdmin.getEnvironment()
                                .assignmentExists(getXPathFromStructureName(structureName, false)))
                            xPath = getXPathFromStructureName(structureName, false);
                        else // try an alias
                            xPath = getXPathFromAlias(am.structureName, true, true);

                    } else { // root
                        if (CacheAdmin.getEnvironment()
                                .assignmentExists(type.getName() + "/" + structureName.toUpperCase()))
                            xPath = type.getName() + "/" + structureName;
                        else // we might have a different alias
                            xPath = getXPathFromAlias(am.structureName, true, false);
                    }

                    if (xPath == null)
                        return createNewGroupNode(am);

                    // retrieve the fxAssignment and set the correct alias if applicable
                    fxAssignment = CacheAdmin.getEnvironment().getAssignment(xPath);
                    // also set the correct alias in the attributesmapper
                    if (!attributes.containsKey("alias")) {
                        am.alias = fxAssignment.getAlias();
                    }
                    return createNewGroupAssignmentNode(fxAssignment, am);
                }
                // create a new group
                return createNewGroupNode(am);

            } catch (FxApplicationException e) {
                throw e.asRuntimeException();
            }
        }
    }
}

From source file:edu.stanford.muse.util.Util.java

/** capitalizes just the first letter and returns the given string */
public static boolean allUppercase(String str) {
    if (str == null)
        return true;
    for (char c : str.toCharArray())
        if (Character.isLowerCase(c))
            return false;
    return true;//  w w w . j a v  a  2 s.c o  m
}

From source file:CharUtils.java

/**
 * True if string is all lower case./*from   ww  w . j  a  v  a  2s.c  om*/
 * 
 * @param s
 *            String to check for being all lower case.
 * 
 * @return True if string is all lower case.
 */

public static boolean isAllLowerCase(String s) {
    boolean result = true;

    for (int i = 0; i < s.length(); i++) {
        char ch = s.charAt(i);

        if (Character.isLetter(ch)) {
            result = result && Character.isLowerCase(ch);
            if (!result)
                break;
        }
    }

    return result;
}

From source file:com.adaptc.mws.plugins.testing.transformations.TestMixinTransformation.java

/**
 * Calculate the name for a getter method to retrieve the specified property
 * @param propertyName//from  www . ja v  a  2  s.co  m
 * @return The name for the getter method for this property, if it were to exist, i.e. getConstraints
 */
public static String getGetterName(String propertyName) {
    final String suffix;
    if (propertyName.length() > 1 && Character.isLowerCase(propertyName.charAt(0))
            && Character.isUpperCase(propertyName.charAt(1))) {
        suffix = propertyName;
    } else {
        suffix = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
    }
    return "get" + suffix;
}

From source file:org.wso2.carbon.governance.generic.ui.utils.GenericUtil.java

public static String getDataElementName(String widgetName) {
    if (widgetName == null || widgetName.length() == 0) {
        return null;
    }//from w w  w.ja v a2  s. c om
    String[] nameParts = widgetName.split("_");
    String convertedName = null;
    //  making widget name camel case
    for (String namePart : nameParts) {
        int i;
        for (i = 0; i < namePart.length(); i++) {
            char c = namePart.charAt(i);
            if (!Character.isLetter(c) || Character.isLowerCase(c)) {
                break;
            }
        }
        namePart = namePart.substring(0, i).toLowerCase() + namePart.substring(i);
        if (convertedName == null) {
            convertedName = namePart;
        } else {
            convertedName += "_" + namePart;
        }
    }
    if (convertedName == null) {
        return null;
    }

    return convertedName.replaceAll(" ", "").replaceAll("-", "");
}