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:com.judoscript.jamaica.JavaClassCreator.java

public static String toJVMClassName(String clsName) {
    if (clsName == null)
        return "java/lang/Object";
    if (Character.isLowerCase(clsName.charAt(0))) {
        if (clsName.equals("int"))
            return "I";
        if (clsName.equals("long"))
            return "L";
        if (clsName.equals("double"))
            return "D";
        if (clsName.equals("float"))
            return "F";
        if (clsName.equals("byte"))
            return "B";
        if (clsName.equals("boolean"))
            return "Z";
        if (clsName.equals("char"))
            return "C";
        if (clsName.equals("short"))
            return "S";
    }/*from  www .ja  v  a  2s. co  m*/
    return clsName.replace('.', '/');
}

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

public boolean isHBMCamelCasePropertyAccessor(String propertyName) {
    if (propertyName.length() < 3) {
        return false;
    }//from  w  ww  . ja  va  2 s . c o m

    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:org.fornax.cartridges.sculptor.smartclient.server.ScServlet.java

private String mapObjToOutput(Object obj, int maxDepth, Stack<Object> serStack, boolean useGwtArray,
        boolean translateValue) {
    if (serStack.size() == 0) {
        log.log(Level.FINER, "Serializing START {0}", obj);
    }/*from  ww w .  j a  va2s .  c om*/

    // Avoid recursion
    if (serStack.size() == maxDepth && !(obj instanceof Date || obj instanceof Number || obj instanceof Boolean
            || obj instanceof CharSequence || obj instanceof Enum)) {
        String objId = getIdFromObj(obj);
        return objId == null ? Q + Q : objId;
    }
    if (serStack.contains(obj)) {
        return getIdFromObj(obj);
        // return Q+"ref: "+obj.getClass().getName()+"@"+obj.hashCode()+Q;
    }
    serStack.push(obj);

    String startArray = useGwtArray ? "$wnd.Array.create([" : "[";
    String endArray = useGwtArray ? "])" : "]";

    StringBuilder recordData = new StringBuilder();
    if (obj == null) {
        recordData.append("null");
    } else if (obj instanceof Map) {
        recordData.append("{");
        Map objMap = (Map) obj;
        String delim = "";
        for (Object objKey : objMap.keySet()) {
            recordData.append(delim).append(objKey).append(":")
                    .append(mapObjToOutput(objMap.get(objKey), maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append("}");
    } else if (obj instanceof Collection) {
        recordData.append(startArray);
        Collection objSet = (Collection) obj;
        String delim = "";
        for (Object objVal : objSet) {
            recordData.append(delim).append(mapObjToOutput(objVal, maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append(endArray);
    } else if (obj instanceof List) {
        recordData.append(startArray);
        List objList = (List) obj;
        String delim = "";
        for (Object objVal : objList) {
            recordData.append(delim).append(mapObjToOutput(objVal, maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append(endArray);
    } else if (obj instanceof Object[]) {
        recordData.append(startArray);
        Object[] objArr = (Object[]) obj;
        String delim = "";
        for (Object objVal : objArr) {
            recordData.append(delim).append(mapObjToOutput(objVal, maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append(endArray);
    } else if (obj instanceof Date) {
        Date objDate = (Date) obj;
        // recordData.append(Q+dateTimeFormat.format(objDate)+Q);
        recordData.append("new Date(" + objDate.getTime() + ")");
    } else if (obj instanceof Boolean) {
        recordData.append(obj);
    } else if (obj instanceof Number) {
        recordData.append(obj);
    } else if (obj instanceof CharSequence) {
        String strObj = obj.toString();
        if (strObj.startsWith(Main.JAVASCRIPT_PREFIX) && useGwtArray) {
            recordData.append(" ").append(strObj.substring(Main.JAVASCRIPT_PREFIX.length()));
        } else if (strObj.startsWith("function") && useGwtArray) {
            recordData.append(" ").append(strObj);
        } else {
            strObj = translateValue ? translate(strObj) : strObj;
            String escapeString = strObj.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"")
                    .replaceAll("\\r", "\\\\r").replaceAll("\\n", "\\\\n");
            recordData.append(Q + escapeString + Q);
        }
    } else if (obj instanceof Enum) {
        String val = ((Enum) obj).name();
        if (useGwtArray) {
            try {
                Method getValMethod = obj.getClass().getMethod("getValue", (Class[]) null);
                val = (String) getValMethod.invoke(obj, (Object[]) null);
            } catch (Exception e) {
                // no method getValue
            }
        }
        recordData.append(Q + val + Q);
    } else {
        String className = obj.getClass().getName();
        ServiceDescription serviceForClass = findServiceByClassName(className);
        log.log(Level.FINER, "Serializing class {0}", className);
        if (serStack.size() > 2 && serviceForClass != null) {
            recordData.append(getIdFromObj(obj));
        } else {
            // Use reflection
            recordData.append("{");
            String delim = "";
            String jsonPostfix = null;
            Method[] methods = obj.getClass().getMethods();
            for (Method m : methods) {
                boolean translateThisValue = false;
                String mName;
                if (m.getName().startsWith(GET_TRANSLATE)) {
                    translateThisValue = true;
                    mName = m.getName().substring(GET_TRANSLATE_LENGTH);
                } else if (m.getName().startsWith("is")) {
                    mName = m.getName().substring(2);
                } else {
                    mName = m.getName().substring(3);
                }

                if (mName.length() > 1 && Character.isLowerCase(mName.charAt(1))) {
                    mName = mName.substring(0, 1).toLowerCase() + mName.substring(1);
                }

                if (m.getName().startsWith("getJsonPostfix") && m.getParameterTypes().length == 0
                        && String.class.equals(m.getReturnType())) {
                    try {
                        jsonPostfix = (String) m.invoke(obj, new Object[] {});
                    } catch (Throwable e) {
                        log.log(Level.FINE, "Mapping error", e);
                    }
                } else if (!m.getDeclaringClass().getName().startsWith("org.hibernate")
                        && m.getDeclaringClass() != Object.class && m.getDeclaringClass() != Class.class
                        && (m.getName().startsWith("get") || m.getName().startsWith("is"))
                        && m.getParameterTypes().length == 0 && m.getReturnType() != null
                        && !isHiddenField(m.getDeclaringClass().getName(), mName)) {
                    log.log(Level.FINEST, "Reflection invoking name={0} declaringClass={1} on {2}[{3}]",
                            new Object[] { m.getName(), m.getDeclaringClass(), obj, obj.getClass() });
                    try {
                        Object result = m.invoke(obj, new Object[] {});
                        if (result != null) {
                            mName = mName.startsWith("xxx") ? mName.substring(3) : mName;
                            String resultClassName = AopUtils.getTargetClass(result).getName();
                            String idVal = getIdFromObj(result);
                            String valStr;
                            if (findServiceByClassName(resultClassName) != null && idVal != null) {
                                recordData.append(delim).append(mName).append(":").append(idVal);
                                String refField = ds2Ref.get(resultClassName);
                                if (refField != null) {
                                    Object realVal = getValFromObj(refField, result);
                                    valStr = realVal == null ? Q + Q : Q + realVal + Q;
                                } else {
                                    valStr = Q + "UNKNOWN" + Q;
                                }
                                mName = mName + "_VAL";
                                delim = ", ";
                            } else {
                                valStr = mapObjToOutput(result, maxDepth, serStack, useGwtArray,
                                        translateThisValue);
                            }
                            recordData.append(delim).append(mName).append(":").append(valStr);
                            delim = ", ";
                        }
                    } catch (Throwable e) {
                        log.log(Level.FINE, "Mapping error", e);
                    }
                }
            }

            if (jsonPostfix != null) {
                recordData.append(delim).append(jsonPostfix).append("}");
            } else {
                recordData.append("}");
            }
        }
    }
    serStack.pop();
    return recordData.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;
            }/*from 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:com.microsoft.windowsazure.management.storage.StorageAccountOperationsImpl.java

/**
* The Update Storage Account operation updates the label and the
* description, and enables or disables the geo-replication status for a
* storage account in Azure.  (see//  w  w  w.ja  v a2s  .c om
* http://msdn.microsoft.com/en-us/library/windowsazure/hh264516.aspx for
* more information)
*
* @param accountName Required. Name of the storage account to update.
* @param parameters Required. Parameters supplied to the Update Storage
* Account operation.
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public OperationResponse update(String accountName, StorageAccountUpdateParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (accountName == null) {
        throw new NullPointerException("accountName");
    }
    if (accountName.length() < 3) {
        throw new IllegalArgumentException("accountName");
    }
    if (accountName.length() > 24) {
        throw new IllegalArgumentException("accountName");
    }
    for (char accountNameChar : accountName.toCharArray()) {
        if (Character.isLowerCase(accountNameChar) == false && Character.isDigit(accountNameChar) == false) {
            throw new IllegalArgumentException("accountName");
        }
    }
    // TODO: Validate accountName is a valid DNS name.
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getDescription() != null && parameters.getDescription().length() > 1024) {
        throw new IllegalArgumentException("parameters.Description");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("accountName", accountName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "updateAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/storageservices/";
    url = url + URLEncoder.encode(accountName, "UTF-8");
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpPut httpRequest = new HttpPut(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/xml");
    httpRequest.setHeader("x-ms-version", "2014-10-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    Element updateStorageServiceInputElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "UpdateStorageServiceInput");
    requestDoc.appendChild(updateStorageServiceInputElement);

    if (parameters.getDescription() != null) {
        Element descriptionElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "Description");
        descriptionElement.appendChild(requestDoc.createTextNode(parameters.getDescription()));
        updateStorageServiceInputElement.appendChild(descriptionElement);
    } else {
        Element emptyElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "Description");
        Attr nilAttribute = requestDoc.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "nil");
        nilAttribute.setValue("true");
        emptyElement.setAttributeNode(nilAttribute);
        updateStorageServiceInputElement.appendChild(emptyElement);
    }

    if (parameters.getLabel() != null) {
        Element labelElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Label");
        labelElement.appendChild(requestDoc.createTextNode(Base64.encode(parameters.getLabel().getBytes())));
        updateStorageServiceInputElement.appendChild(labelElement);
    }

    if (parameters.getExtendedProperties() != null) {
        if (parameters.getExtendedProperties() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getExtendedProperties()).isInitialized()) {
            Element extendedPropertiesDictionaryElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "ExtendedProperties");
            for (Map.Entry<String, String> entry : parameters.getExtendedProperties().entrySet()) {
                String extendedPropertiesKey = entry.getKey();
                String extendedPropertiesValue = entry.getValue();
                Element extendedPropertiesElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/windowsazure", "ExtendedProperty");
                extendedPropertiesDictionaryElement.appendChild(extendedPropertiesElement);

                Element extendedPropertiesKeyElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/windowsazure", "Name");
                extendedPropertiesKeyElement.appendChild(requestDoc.createTextNode(extendedPropertiesKey));
                extendedPropertiesElement.appendChild(extendedPropertiesKeyElement);

                Element extendedPropertiesValueElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/windowsazure", "Value");
                extendedPropertiesValueElement.appendChild(requestDoc.createTextNode(extendedPropertiesValue));
                extendedPropertiesElement.appendChild(extendedPropertiesValueElement);
            }
            updateStorageServiceInputElement.appendChild(extendedPropertiesDictionaryElement);
        }
    }

    if (parameters.getAccountType() != null) {
        Element accountTypeElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "AccountType");
        accountTypeElement.appendChild(requestDoc.createTextNode(parameters.getAccountType()));
        updateStorageServiceInputElement.appendChild(accountTypeElement);
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        OperationResponse result = null;
        // Deserialize Response
        result = new OperationResponse();
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:com.microsoft.azure.management.storage.StorageAccountOperationsImpl.java

/**
* Lists the access keys for the specified storage account.
*
* @param resourceGroupName Required. The name of the resource group.
* @param accountName Required. The name of the storage account.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.//from   w ww .j  av a2s  .c om
* @throws ServiceException Thrown if an unexpected response is found.
* @return The ListKeys operation response.
*/
@Override
public StorageAccountListKeysResponse listKeys(String resourceGroupName, String accountName)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (accountName == null) {
        throw new NullPointerException("accountName");
    }
    if (accountName.length() < 3) {
        throw new IllegalArgumentException("accountName");
    }
    if (accountName.length() > 24) {
        throw new IllegalArgumentException("accountName");
    }
    for (char accountNameChar : accountName.toCharArray()) {
        if (Character.isLowerCase(accountNameChar) == false && Character.isDigit(accountNameChar) == false) {
            throw new IllegalArgumentException("accountName");
        }
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("resourceGroupName", resourceGroupName);
        tracingParameters.put("accountName", accountName);
        CloudTracing.enter(invocationId, this, "listKeysAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/subscriptions/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/resourceGroups/";
    url = url + URLEncoder.encode(resourceGroupName, "UTF-8");
    url = url + "/providers/Microsoft.Storage/storageAccounts/";
    url = url + URLEncoder.encode(accountName, "UTF-8");
    url = url + "/listKeys";
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-06-15");
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpPost httpRequest = new HttpPost(url);

    // Set Headers
    httpRequest.setHeader("x-ms-client-request-id", UUID.randomUUID().toString());

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        StorageAccountListKeysResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new StorageAccountListKeysResponse();
            ObjectMapper objectMapper = new ObjectMapper();
            JsonNode responseDoc = null;
            String responseDocContent = IOUtils.toString(responseContent);
            if (responseDocContent == null == false && responseDocContent.length() > 0) {
                responseDoc = objectMapper.readTree(responseDocContent);
            }

            if (responseDoc != null && responseDoc instanceof NullNode == false) {
                StorageAccountKeys storageAccountKeysInstance = new StorageAccountKeys();
                result.setStorageAccountKeys(storageAccountKeysInstance);

                JsonNode key1Value = responseDoc.get("key1");
                if (key1Value != null && key1Value instanceof NullNode == false) {
                    String key1Instance;
                    key1Instance = key1Value.getTextValue();
                    storageAccountKeysInstance.setKey1(key1Instance);
                }

                JsonNode key2Value = responseDoc.get("key2");
                if (key2Value != null && key2Value instanceof NullNode == false) {
                    String key2Instance;
                    key2Instance = key2Value.getTextValue();
                    storageAccountKeysInstance.setKey2(key2Instance);
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:org.apache.click.util.ClickUtils.java

/**
 * Return a field label string from the given field name. For example:
 * <pre class="codeHtml">//from  w  w  w.  ja v  a 2  s . c o  m
 * <span class="blue">faxNumber</span> &nbsp; -&gt; &nbsp; <span class="red">Fax Number</span> </pre>
 * <p/>
 * <b>Note</b> toLabel will return an empty String ("") if a <tt>null</tt>
 * String name is specified.
 *
 * @param name the field name
 * @return a field label string from the given field name
 */
public static String toLabel(String name) {
    if (name == null) {
        return "";
    }

    HtmlStringBuffer buffer = new HtmlStringBuffer();

    for (int i = 0, size = name.length(); i < size; i++) {
        char aChar = name.charAt(i);

        if (i == 0) {
            buffer.append(Character.toUpperCase(aChar));

        } else {
            buffer.append(aChar);

            if (i < name.length() - 1) {
                char nextChar = name.charAt(i + 1);
                if (Character.isLowerCase(aChar)
                        && (Character.isUpperCase(nextChar) || Character.isDigit(nextChar))) {

                    // Add space before digits or uppercase letters
                    buffer.append(" ");

                } else if (Character.isDigit(aChar) && (!Character.isDigit(nextChar))) {

                    // Add space after digits
                    buffer.append(" ");
                }
            }
        }
    }

    return buffer.toString();
}

From source file:com.osparking.attendant.AttListForm.java

private boolean isEnglish(char firstCh) {
    if (Character.isLowerCase(firstCh) || Character.isUpperCase(firstCh)) {
        return true;
    } else {//from   www . ja  va2 s  .c o  m
        return false;
    }
}

From source file:com.microsoft.azure.management.storage.StorageAccountOperationsImpl.java

/**
* Regenerates the access keys for the specified storage account.
*
* @param resourceGroupName Required. The name of the resource group within
* the user's subscription.//  www . j a  v a 2  s  . c o  m
* @param accountName Required. The name of the storage account within the
* specified resource group. Storage account names must be between 3 and 24
* characters in length and use numbers and lower-case letters only.
* @param regenerateKey Required. Specifies name of the key which should be
* regenerated. key1 or key2 for the default keys
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return The RegenerateKey operation response.
*/
@Override
public StorageAccountRegenerateKeyResponse regenerateKey(String resourceGroupName, String accountName,
        String regenerateKey) throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (accountName == null) {
        throw new NullPointerException("accountName");
    }
    if (accountName.length() < 3) {
        throw new IllegalArgumentException("accountName");
    }
    if (accountName.length() > 24) {
        throw new IllegalArgumentException("accountName");
    }
    for (char accountNameChar : accountName.toCharArray()) {
        if (Character.isLowerCase(accountNameChar) == false && Character.isDigit(accountNameChar) == false) {
            throw new IllegalArgumentException("accountName");
        }
    }
    if (regenerateKey == null) {
        throw new NullPointerException("regenerateKey");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("resourceGroupName", resourceGroupName);
        tracingParameters.put("accountName", accountName);
        tracingParameters.put("regenerateKey", regenerateKey);
        CloudTracing.enter(invocationId, this, "regenerateKeyAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/subscriptions/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/resourceGroups/";
    url = url + URLEncoder.encode(resourceGroupName, "UTF-8");
    url = url + "/providers/Microsoft.Storage/storageAccounts/";
    url = url + URLEncoder.encode(accountName, "UTF-8");
    url = url + "/regenerateKey";
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-06-15");
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpPost httpRequest = new HttpPost(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json");
    httpRequest.setHeader("x-ms-client-request-id", UUID.randomUUID().toString());

    // Serialize Request
    String requestContent = null;
    JsonNode requestDoc = null;

    ObjectMapper objectMapper = new ObjectMapper();
    ObjectNode storageAccountRegenerateKeyParametersValue = objectMapper.createObjectNode();
    requestDoc = storageAccountRegenerateKeyParametersValue;

    ((ObjectNode) storageAccountRegenerateKeyParametersValue).put("keyName", regenerateKey);

    StringWriter stringWriter = new StringWriter();
    objectMapper.writeValue(stringWriter, requestDoc);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/json");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        StorageAccountRegenerateKeyResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new StorageAccountRegenerateKeyResponse();
            JsonNode responseDoc = null;
            String responseDocContent = IOUtils.toString(responseContent);
            if (responseDocContent == null == false && responseDocContent.length() > 0) {
                responseDoc = objectMapper.readTree(responseDocContent);
            }

            if (responseDoc != null && responseDoc instanceof NullNode == false) {
                StorageAccountKeys storageAccountKeysInstance = new StorageAccountKeys();
                result.setStorageAccountKeys(storageAccountKeysInstance);

                JsonNode key1Value = responseDoc.get("key1");
                if (key1Value != null && key1Value instanceof NullNode == false) {
                    String key1Instance;
                    key1Instance = key1Value.getTextValue();
                    storageAccountKeysInstance.setKey1(key1Instance);
                }

                JsonNode key2Value = responseDoc.get("key2");
                if (key2Value != null && key2Value instanceof NullNode == false) {
                    String key2Instance;
                    key2Instance = key2Value.getTextValue();
                    storageAccountKeysInstance.setKey2(key2Instance);
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

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

/**
 * @param str/*  w ww  .ja va2 s  . c om*/
 * @return
 */
public static boolean isAllCaps(final String str) {
    for (int i = 0; i < str.length(); i++) {
        char ch = str.charAt(i);
        if (Character.isLetter(ch) && Character.isLowerCase(ch)) {
            return false;
        }
    }
    return true;
}