List of usage examples for java.lang Character isLowerCase
public static boolean isLowerCase(int codePoint)
From source file:co.id.app.sys.util.StringUtils.java
/** * Return a field label string from the given field name. For example: * <pre class="codeHtml">/*from w w w . j a va2 s . c o m*/ * <span class="blue">faxNumber</span> -> <span class="red">Fax Number</span> </pre> * * @param name the field name * @return a field label string from the given field name */ public static String toLabel(String name) { if (name == null) { throw new IllegalArgumentException("Null name parameter"); } 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))) { buffer.append(" "); } } } } return buffer.toString(); }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static int countLowercaseChain(final CharSequence sequence) { if (isBlankOrNull(sequence)) { return 0; } else if (length(sequence) == 1) { return hasLowercase(sequence) ? 1 : 0; }/*from w ww . j a v a 2s . com*/ int max = 0; int count = 0; for (int i = 0; i < sequence.length(); i++) { if (Character.isLowerCase(sequence.charAt(i))) { count++; } else { if (count > max) { max = count; } count = 0; } } if (count > max) { max = count; } return max; }
From source file:com.microsoft.azure.management.storage.StorageAccountOperationsImpl.java
/** * Deletes a storage account in Microsoft Azure. * * @param resourceGroupName Required. The name of the resource group within * the user's subscription.//from w w w .ja 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. * @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 delete(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, "deleteAsync", 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"); 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 CustomHttpDelete httpRequest = new CustomHttpDelete(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 && statusCode != HttpStatus.SC_NO_CONTENT) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, 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:org.rdkit.knime.wizards.RDKitNodesWizardsPage.java
/** * Generates a friendly and easily readable name based on the passed in name. * Replaces for instance underscores with spaces, corrects lower and upper * cases when necessary.// ww w . j a v a2s . co m * * @param name A name of something. Can be null. * * @return A friendly name. Is empty when null was passed in. */ public static String generateFriendlyName(final String name) { String workName = ""; if (name != null) { workName = name.trim(); // Don't touch, if length is <= 2 (usually a variable like x, y, z) if (workName.length() > 2) { workName = workName.replaceAll("_", " "); workName = workName.replaceAll("\\s", " "); final StringBuilder sbFriendlyName = new StringBuilder(); int iCountUpperCase = 0; boolean bWasSpace = false; char[] chars = workName.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); for (char c : chars) { final boolean bIsUpperCase = Character.isUpperCase(c); final boolean bIsLowerCase = Character.isLowerCase(c); if (bIsUpperCase && iCountUpperCase == 0) { sbFriendlyName.append(" "); } if (bIsLowerCase && iCountUpperCase > 1) { sbFriendlyName.insert(sbFriendlyName.length() - 1, " "); } if (bWasSpace) { c = Character.toUpperCase(c); } sbFriendlyName.append(c); if (bIsUpperCase) { iCountUpperCase++; } else { iCountUpperCase = 0; } bWasSpace = (c == ' '); } workName = sbFriendlyName.toString().trim(); // If more than one whitespace was added in the middle, reduce // multiple to single space workName = workName.trim().replaceAll("\\s+", " "); } } return workName; }
From source file:org.seasar.dbflute.task.DfSql2EntityTask.java
protected boolean needsConvertToJavaName(String columnName) { if (columnName == null || columnName.trim().length() == 0) { String msg = "The columnName is invalid: " + columnName; throw new IllegalArgumentException(msg); }/*from w w w . j a v a 2s. c o m*/ if (columnName.contains("_")) { return true; // contains (supported) connector! } // here 'BIRHDATE' or 'birthdate' or 'Birthdate' // or 'memberStatus' or 'MemberStatus' final char[] columnCharArray = columnName.toCharArray(); boolean existsUpper = false; boolean existsLower = false; for (char ch : columnCharArray) { if (Character.isDigit(ch)) { continue; } if (Character.isUpperCase(ch)) { existsUpper = true; continue; } if (Character.isLowerCase(ch)) { existsLower = true; continue; } } final boolean camelCase = existsUpper && existsLower; // if it's camelCase, no needs to convert // (all characters that are upper or lower case needs to convert) return !camelCase; }
From source file:org.andromda.cartridges.gui.GuiUtils.java
/** * Returns <code>true</code> if the argument name will not cause any troubles with the Jakarta commons-beanutils * library, which basically means it does not start with an lowercase characters followed by an uppercase character. * This means there's a bug in that specific library that causes an incompatibility with the Java Beans * specification as implemented in the JDK. * /*from w w w.ja v a2 s . c o m*/ * @param name the name to test, may be <code>null</code> * @return <code>true</code> if the name is safe to use with the Jakarta libraries, <code>false</code> otherwise */ public static boolean isSafeName(final String name) { boolean safe = true; if ((name != null) && (name.length() > 1)) { safe = !(Character.isLowerCase(name.charAt(0)) && Character.isUpperCase(name.charAt(1))); } return safe; }
From source file:es.ehu.si.ixa.pipe.convert.Convert.java
/** * Do not print a sentence if is less than 90% lowercase. * /* w ww . j a va 2 s . c om*/ * @param sentences * the list of sentences * @return the list of sentences that contain more than 90% lowercase * characters * @throws IOException */ private String brownCleanUpperCase(File inFile) throws IOException { InputStream inputStream = CmdLineUtil.openInFile(inFile); StringBuilder precleantext = new StringBuilder(); BufferedReader breader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); String line; while ((line = breader.readLine()) != null) { double lowercaseCounter = 0; StringBuilder sb = new StringBuilder(); String[] lineArray = line.split(" "); for (String word : lineArray) { if (lineArray.length > 0) { sb.append(word); } } char[] lineCharArray = sb.toString().toCharArray(); for (char lineArr : lineCharArray) { if (Character.isLowerCase(lineArr)) { lowercaseCounter++; } } double percent = lowercaseCounter / (double) lineCharArray.length; if (percent >= 0.90) { precleantext.append(line).append("\n"); } } breader.close(); return precleantext.toString(); }
From source file:com.microsoft.azure.management.storage.StorageAccountOperationsImpl.java
/** * Returns the properties for the specified storage account including but * not limited to name, account type, location, and account status. The * ListKeys operation should be used to retrieve storage keys. * * @param resourceGroupName Required. The name of the resource group within * the user's subscription./*from w w w . j a va 2s.co 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. * @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. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The Get storage account operation response. */ @Override public StorageAccountGetPropertiesResponse getProperties(String resourceGroupName, String accountName) throws IOException, ServiceException, URISyntaxException { // 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, "getPropertiesAsync", 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"); 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 HttpGet httpRequest = new HttpGet(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 StorageAccountGetPropertiesResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountGetPropertiesResponse(); 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) { StorageAccount storageAccountInstance = new StorageAccount(); result.setStorageAccount(storageAccountInstance); JsonNode idValue = responseDoc.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); storageAccountInstance.setId(idInstance); } JsonNode nameValue = responseDoc.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); storageAccountInstance.setName(nameInstance); } JsonNode typeValue = responseDoc.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); storageAccountInstance.setType(typeInstance); } JsonNode locationValue = responseDoc.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); storageAccountInstance.setLocation(locationInstance); } JsonNode tagsSequenceElement = ((JsonNode) responseDoc.get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey = property.getKey(); String tagsValue = property.getValue().getTextValue(); storageAccountInstance.getTags().put(tagsKey, tagsValue); } } JsonNode propertiesValue = responseDoc.get("properties"); if (propertiesValue != null && propertiesValue instanceof NullNode == false) { JsonNode provisioningStateValue = propertiesValue.get("provisioningState"); if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) { ProvisioningState provisioningStateInstance; provisioningStateInstance = EnumUtility.fromString(ProvisioningState.class, provisioningStateValue.getTextValue()); storageAccountInstance.setProvisioningState(provisioningStateInstance); } JsonNode accountTypeValue = propertiesValue.get("accountType"); if (accountTypeValue != null && accountTypeValue instanceof NullNode == false) { AccountType accountTypeInstance; accountTypeInstance = StorageManagementClientImpl .parseAccountType(accountTypeValue.getTextValue()); storageAccountInstance.setAccountType(accountTypeInstance); } JsonNode primaryEndpointsValue = propertiesValue.get("primaryEndpoints"); if (primaryEndpointsValue != null && primaryEndpointsValue instanceof NullNode == false) { Endpoints primaryEndpointsInstance = new Endpoints(); storageAccountInstance.setPrimaryEndpoints(primaryEndpointsInstance); JsonNode blobValue = primaryEndpointsValue.get("blob"); if (blobValue != null && blobValue instanceof NullNode == false) { URI blobInstance; blobInstance = new URI(blobValue.getTextValue()); primaryEndpointsInstance.setBlob(blobInstance); } JsonNode queueValue = primaryEndpointsValue.get("queue"); if (queueValue != null && queueValue instanceof NullNode == false) { URI queueInstance; queueInstance = new URI(queueValue.getTextValue()); primaryEndpointsInstance.setQueue(queueInstance); } JsonNode tableValue = primaryEndpointsValue.get("table"); if (tableValue != null && tableValue instanceof NullNode == false) { URI tableInstance; tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } JsonNode fileValue = primaryEndpointsValue.get("file"); if (fileValue != null && fileValue instanceof NullNode == false) { URI fileInstance; fileInstance = new URI(fileValue.getTextValue()); primaryEndpointsInstance.setFile(fileInstance); } } JsonNode primaryLocationValue = propertiesValue.get("primaryLocation"); if (primaryLocationValue != null && primaryLocationValue instanceof NullNode == false) { String primaryLocationInstance; primaryLocationInstance = primaryLocationValue.getTextValue(); storageAccountInstance.setPrimaryLocation(primaryLocationInstance); } JsonNode statusOfPrimaryValue = propertiesValue.get("statusOfPrimary"); if (statusOfPrimaryValue != null && statusOfPrimaryValue instanceof NullNode == false) { AccountStatus statusOfPrimaryInstance; statusOfPrimaryInstance = EnumUtility.fromString(AccountStatus.class, statusOfPrimaryValue.getTextValue()); storageAccountInstance.setStatusOfPrimary(statusOfPrimaryInstance); } JsonNode lastGeoFailoverTimeValue = propertiesValue.get("lastGeoFailoverTime"); if (lastGeoFailoverTimeValue != null && lastGeoFailoverTimeValue instanceof NullNode == false) { Calendar lastGeoFailoverTimeInstance; lastGeoFailoverTimeInstance = DatatypeConverter .parseDateTime(lastGeoFailoverTimeValue.getTextValue()); storageAccountInstance.setLastGeoFailoverTime(lastGeoFailoverTimeInstance); } JsonNode secondaryLocationValue = propertiesValue.get("secondaryLocation"); if (secondaryLocationValue != null && secondaryLocationValue instanceof NullNode == false) { String secondaryLocationInstance; secondaryLocationInstance = secondaryLocationValue.getTextValue(); storageAccountInstance.setSecondaryLocation(secondaryLocationInstance); } JsonNode statusOfSecondaryValue = propertiesValue.get("statusOfSecondary"); if (statusOfSecondaryValue != null && statusOfSecondaryValue instanceof NullNode == false) { AccountStatus statusOfSecondaryInstance; statusOfSecondaryInstance = EnumUtility.fromString(AccountStatus.class, statusOfSecondaryValue.getTextValue()); storageAccountInstance.setStatusOfSecondary(statusOfSecondaryInstance); } JsonNode creationTimeValue = propertiesValue.get("creationTime"); if (creationTimeValue != null && creationTimeValue instanceof NullNode == false) { Calendar creationTimeInstance; creationTimeInstance = DatatypeConverter .parseDateTime(creationTimeValue.getTextValue()); storageAccountInstance.setCreationTime(creationTimeInstance); } JsonNode customDomainValue = propertiesValue.get("customDomain"); if (customDomainValue != null && customDomainValue instanceof NullNode == false) { CustomDomain customDomainInstance = new CustomDomain(); storageAccountInstance.setCustomDomain(customDomainInstance); JsonNode nameValue2 = customDomainValue.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); customDomainInstance.setName(nameInstance2); } JsonNode useSubDomainValue = customDomainValue.get("useSubDomain"); if (useSubDomainValue != null && useSubDomainValue instanceof NullNode == false) { boolean useSubDomainInstance; useSubDomainInstance = useSubDomainValue.getBooleanValue(); customDomainInstance.setUseSubDomain(useSubDomainInstance); } } JsonNode secondaryEndpointsValue = propertiesValue.get("secondaryEndpoints"); if (secondaryEndpointsValue != null && secondaryEndpointsValue instanceof NullNode == false) { Endpoints secondaryEndpointsInstance = new Endpoints(); storageAccountInstance.setSecondaryEndpoints(secondaryEndpointsInstance); JsonNode blobValue2 = secondaryEndpointsValue.get("blob"); if (blobValue2 != null && blobValue2 instanceof NullNode == false) { URI blobInstance2; blobInstance2 = new URI(blobValue2.getTextValue()); secondaryEndpointsInstance.setBlob(blobInstance2); } JsonNode queueValue2 = secondaryEndpointsValue.get("queue"); if (queueValue2 != null && queueValue2 instanceof NullNode == false) { URI queueInstance2; queueInstance2 = new URI(queueValue2.getTextValue()); secondaryEndpointsInstance.setQueue(queueInstance2); } JsonNode tableValue2 = secondaryEndpointsValue.get("table"); if (tableValue2 != null && tableValue2 instanceof NullNode == false) { URI tableInstance2; tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } JsonNode fileValue2 = secondaryEndpointsValue.get("file"); if (fileValue2 != null && fileValue2 instanceof NullNode == false) { URI fileInstance2; fileInstance2 = new URI(fileValue2.getTextValue()); secondaryEndpointsInstance.setFile(fileInstance2); } } } } } 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.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java
private CharSequence adjustCase(AnyKey key) { // if (mKeyboard.isShifted() && label != null && label.length() < 3 // && Character.isLowerCase(label.charAt(0))) { // label = label.toString().toUpperCase(); // }// w ww. j ava2s.c om CharSequence label = key.label; // if (mKeyboard.isShifted() && // (!TextUtils.isEmpty(label)) && // Character.isLowerCase(label.charAt(0))) { // label = label.toString().toUpperCase(); // } if (mKeyboard.isShifted()) { if (!TextUtils.isEmpty(key.shiftedKeyLabel)) label = key.shiftedKeyLabel; else if (!TextUtils.isEmpty(label) && Character.isLowerCase(label.charAt(0))) label = label.toString().toUpperCase(); } return label; }
From source file:net.yacy.cora.document.id.MultiProtocolURL.java
private static CharType charType(final char c) { if (Character.isLowerCase(c)) return CharType.low; if (Character.isDigit(c)) return CharType.number; return CharType.high; }