List of usage examples for java.lang Character isLowerCase
public static boolean isLowerCase(int codePoint)
From source file:org.bd2kccc.bd2kcccpubmed.Crawler.java
int getCase(String word) { if (word.isEmpty()) return 0; boolean uppercase = true; boolean lowercase = true; boolean titlecase = true; boolean mixedcase = true; char[] letters = word.toCharArray(); if (Character.isLetter(letters[0])) { if (Character.isLowerCase(letters[0])) { //titlecase = false; //let's not require every word to be titlecase }//from w w w. j a v a 2 s.co m } else { uppercase = false; lowercase = false; titlecase = false; } for (int i = 1; i < letters.length; i++) { char letter = letters[i]; if (!Character.isLetter(letter)) { uppercase = false; lowercase = false; titlecase = false; break; } if (Character.isLowerCase(letter)) uppercase = false; else { lowercase = false; titlecase = false; } } if (uppercase && word.length() > 1) return UPPERCASE; if (lowercase) return LOWERCASE; if (titlecase) return TITLECASE; if (mixedcase) return MIXEDCASE; return 0; }
From source file:ca.uhn.fhir.model.primitive.IdDt.java
private String determineLocalPrefix(String theValue) { if (theValue == null || theValue.isEmpty()) { return null; }//from w w w . j a v a 2 s. c o m if (theValue.startsWith("#")) { return "#"; } int lastPrefix = -1; for (int i = 0; i < theValue.length(); i++) { char nextChar = theValue.charAt(i); if (nextChar == ':') { lastPrefix = i; } else if (!Character.isLetter(nextChar) || !Character.isLowerCase(nextChar)) { break; } } if (lastPrefix != -1) { String candidate = theValue.substring(0, lastPrefix + 1); if (candidate.startsWith("cid:") || candidate.startsWith("urn:")) { return candidate; } else { return null; } } else { return null; } }
From source file:com.couchbase.lite.Manager.java
/** * Returns YES if the given name is a valid database name. * (Only the characters in "abcdefghijklmnopqrstuvwxyz0123456789_$()+-/" are allowed.) *//*from www . j a va2 s . com*/ @InterfaceAudience.Public public static boolean isValidDatabaseName(String databaseName) { if (databaseName.length() > 0 && databaseName.length() < 240 && containsOnlyLegalCharacters(databaseName) && Character.isLowerCase(databaseName.charAt(0))) { return true; } return databaseName.equals(Replication.REPLICATOR_DATABASE_NAME); }
From source file:org.lightjason.agentspeak.common.CCommon.java
/** * checks if an action is usable/* w ww .j a va 2 s.com*/ * * @param p_action action object * @return boolean usable flag */ private static boolean actionusable(final IAction p_action) { if ((p_action.name() == null) || (p_action.name().isEmpty()) || (p_action.name().get(0).trim().isEmpty())) { LOGGER.warning(CCommon.languagestring(CCommon.class, "actionnameempty")); return false; } if (!Character.isLetter(p_action.name().get(0).charAt(0))) { LOGGER.warning(CCommon.languagestring(CCommon.class, "actionletter", p_action)); return false; } if (!Character.isLowerCase(p_action.name().get(0).charAt(0))) { LOGGER.warning(CCommon.languagestring(CCommon.class, "actionlowercase", p_action)); return false; } if (p_action.minimalArgumentNumber() < 0) { LOGGER.warning(CCommon.languagestring(CCommon.class, "actionargumentsnumber", p_action)); return false; } return true; }
From source file:org.owasp.jbrofuzz.core.net.MACAddrFuzzer.java
/** * <p>Construct a MAC address fuzzer, starting at value of * <b>macStart</b> and ending at value * <b>macEnd</b>. //ww w. j a v a 2 s. c o m * * * @param macStart specifying e.g. "FF:FF:FF:FF:FF:00" * will iterate from that value, inclusive. * * @param macEnd specifying e.g. "FF:FF:FF:FF:FF:FF" * will iterate to that value, inclusive. * * @throws NoSuchFuzzerException if the format of macStart * is not correct, the check is performed using * {@link #isValidMACAddress(String)}. * * @author subere@uncon.org * @version 2.5 * @since 2.5 * */ public MACAddrFuzzer(final String macStart, final String macEnd) throws NoSuchFuzzerException { final char charSeparator1 = MACAddrFuzzer.getFirstSeparator(macStart); final char charSeparator2 = MACAddrFuzzer.getFirstSeparator(macEnd); // Set the char separator off the first MAC address this.separator = MACAddrFuzzer.getSeparatorEnum(charSeparator1); if (!MACAddrFuzzer.isValidMACAddress(macStart, charSeparator1)) { throw new NoSuchFuzzerException(ERROR_MSG); } if (!MACAddrFuzzer.isValidMACAddress(macEnd, charSeparator2)) { throw new NoSuchFuzzerException(ERROR_MSG); } this.currentValue = MACAddrFuzzer.parseMAC(macStart, charSeparator1); this.maxValue = MACAddrFuzzer.parseMAC(macEnd, charSeparator2); if (Character.isLowerCase(macStart.charAt(0))) { this.hexCharArray = HEX_DIGITS.toLowerCase(Locale.ENGLISH).toCharArray(); } else { this.hexCharArray = HEX_DIGITS.toCharArray(); } }
From source file:org.intermine.metadata.StringUtil.java
/** * Returns a string with the same initial letter case as the template string * * @param n the String to convert/* w w w .j a v a2 s. c o m*/ * @param template the String to base the conversion on * @return the new String, capitalised like template */ public static String toSameInitialCase(String n, String template) { if (n == null) { throw new NullPointerException("String to convert cannot be null"); } if (template == null) { return n; } StringBuffer sb = new StringBuffer(); if (Character.isUpperCase(template.charAt(0))) { sb.append(Character.toUpperCase(n.charAt(0))); } if (Character.isLowerCase(template.charAt(0))) { sb.append(Character.toLowerCase(n.charAt(0))); } if (n.length() > 1) { sb.append(n.substring(1, n.length())); } return sb.toString(); }
From source file:org.ebayopensource.turmeric.eclipse.services.ui.wizards.pages.ServiceFromExistingWSDLWizardPage.java
/** * {@inheritDoc}//from ww w. j a va2s. co m */ @Override public boolean dialogChanged(boolean validateWsdl) { final boolean result = super.dialogChanged(validateWsdl); if (result == false && isPageComplete() == false) return result; 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( StringUtil.formatString(SOAMessages.ERR_WRONG_NAMESPACEPART, getDomainClassifier(), this.wsdl.getTargetNamespace()), super.domainClassifierList, super.adminNameText, super.resourceVersionText, super.getResourceNameText()); 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.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) && versionFromWSDL.equals(getResourceVersion()) == false) { String errorMsg = StringUtil.formatString(SOAMessages.DIFFERENT_SERVICE_VERSION_WITH_WSDL, getResourceVersion(), versionFromWSDL); updateStatus(super.resourceVersionText, errorMsg); 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.google.dart.engine.services.refactoring.NamingConventions.java
/** * Validate the given identifier, which should be lower camel case. *///from w w w . j a v a 2s .co m private static RefactoringStatus validateLowerCamelCase(String identifier, String elementName) { // null if (identifier == null) { String message = MessageFormat.format("{0} name must not be null.", elementName); return RefactoringStatus.createErrorStatus(message); } // is not identifier RefactoringStatus status = validateIdentifier(identifier, elementName); if (!status.isOK()) { return status; } // is private, OK if (identifier.charAt(0) == '_') { return new RefactoringStatus(); } // does not start with lower case if (!Character.isLowerCase(identifier.charAt(0))) { String message = MessageFormat.format("{0} name should start with a lowercase letter.", elementName); return RefactoringStatus.createWarningStatus(message); } // OK return new RefactoringStatus(); }
From source file:com.microsoft.windowsazure.management.mediaservices.AccountOperationsImpl.java
/** * The Create Media Services Account operation creates a new media services * account in Windows Azure. (see/*from w w w . j a v a 2s . com*/ * http://msdn.microsoft.com/en-us/library/windowsazure/dn194267.aspx for * more information) * * @param parameters Required. Parameters supplied to the Create Media * Services 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 The Create Media Services Account operation response. */ @Override public MediaServicesAccountCreateResponse create(MediaServicesAccountCreateParameters parameters) throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException { // Validate if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getAccountName() == null) { throw new NullPointerException("parameters.AccountName"); } if (parameters.getAccountName().length() < 3) { throw new IllegalArgumentException("parameters.AccountName"); } if (parameters.getAccountName().length() > 24) { throw new IllegalArgumentException("parameters.AccountName"); } if (parameters.getBlobStorageEndpointUri() == null) { throw new NullPointerException("parameters.BlobStorageEndpointUri"); } if (parameters.getRegion() == null) { throw new NullPointerException("parameters.Region"); } if (parameters.getRegion().length() < 3) { throw new IllegalArgumentException("parameters.Region"); } if (parameters.getRegion().length() > 256) { throw new IllegalArgumentException("parameters.Region"); } if (parameters.getStorageAccountKey() == null) { throw new NullPointerException("parameters.StorageAccountKey"); } if (parameters.getStorageAccountKey().length() < 14) { throw new IllegalArgumentException("parameters.StorageAccountKey"); } if (parameters.getStorageAccountKey().length() > 256) { throw new IllegalArgumentException("parameters.StorageAccountKey"); } if (parameters.getStorageAccountName() == null) { throw new NullPointerException("parameters.StorageAccountName"); } if (parameters.getStorageAccountName().length() < 3) { throw new IllegalArgumentException("parameters.StorageAccountName"); } if (parameters.getStorageAccountName().length() > 24) { throw new IllegalArgumentException("parameters.StorageAccountName"); } for (char storageAccountNameChar : parameters.getStorageAccountName().toCharArray()) { if (Character.isLowerCase(storageAccountNameChar) == false && Character.isDigit(storageAccountNameChar) == false) { throw new IllegalArgumentException("parameters.StorageAccountName"); } } // 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("parameters", parameters); CloudTracing.enter(invocationId, this, "createAsync", 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/mediaservices/Accounts"; 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/xml"); httpRequest.setHeader("x-ms-version", "2011-10-01"); // Serialize Request String requestContent = null; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document requestDoc = documentBuilder.newDocument(); Element accountCreationRequestElement = requestDoc.createElementNS( "http://schemas.datacontract.org/2004/07/Microsoft.Cloud.Media.Management.ResourceProvider.Models", "AccountCreationRequest"); requestDoc.appendChild(accountCreationRequestElement); Element accountNameElement = requestDoc.createElementNS( "http://schemas.datacontract.org/2004/07/Microsoft.Cloud.Media.Management.ResourceProvider.Models", "AccountName"); accountNameElement.appendChild(requestDoc.createTextNode(parameters.getAccountName())); accountCreationRequestElement.appendChild(accountNameElement); Element blobStorageEndpointUriElement = requestDoc.createElementNS( "http://schemas.datacontract.org/2004/07/Microsoft.Cloud.Media.Management.ResourceProvider.Models", "BlobStorageEndpointUri"); blobStorageEndpointUriElement .appendChild(requestDoc.createTextNode(parameters.getBlobStorageEndpointUri().toString())); accountCreationRequestElement.appendChild(blobStorageEndpointUriElement); Element regionElement = requestDoc.createElementNS( "http://schemas.datacontract.org/2004/07/Microsoft.Cloud.Media.Management.ResourceProvider.Models", "Region"); regionElement.appendChild(requestDoc.createTextNode(parameters.getRegion())); accountCreationRequestElement.appendChild(regionElement); Element storageAccountKeyElement = requestDoc.createElementNS( "http://schemas.datacontract.org/2004/07/Microsoft.Cloud.Media.Management.ResourceProvider.Models", "StorageAccountKey"); storageAccountKeyElement.appendChild(requestDoc.createTextNode(parameters.getStorageAccountKey())); accountCreationRequestElement.appendChild(storageAccountKeyElement); Element storageAccountNameElement = requestDoc.createElementNS( "http://schemas.datacontract.org/2004/07/Microsoft.Cloud.Media.Management.ResourceProvider.Models", "StorageAccountName"); storageAccountNameElement.appendChild(requestDoc.createTextNode(parameters.getStorageAccountName())); accountCreationRequestElement.appendChild(storageAccountNameElement); 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_CREATED) { ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result MediaServicesAccountCreateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_CREATED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new MediaServicesAccountCreateResponse(); 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) { MediaServicesCreatedAccount accountInstance = new MediaServicesCreatedAccount(); result.setAccount(accountInstance); JsonNode accountIdValue = responseDoc.get("AccountId"); if (accountIdValue != null && accountIdValue instanceof NullNode == false) { String accountIdInstance; accountIdInstance = accountIdValue.getTextValue(); accountInstance.setAccountId(accountIdInstance); } JsonNode accountNameValue = responseDoc.get("AccountName"); if (accountNameValue != null && accountNameValue instanceof NullNode == false) { String accountNameInstance; accountNameInstance = accountNameValue.getTextValue(); accountInstance.setAccountName(accountNameInstance); } JsonNode subscriptionValue = responseDoc.get("Subscription"); if (subscriptionValue != null && subscriptionValue instanceof NullNode == false) { String subscriptionInstance; subscriptionInstance = subscriptionValue.getTextValue(); accountInstance.setSubscriptionId(subscriptionInstance); } } } 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.eclipse.wb.internal.core.model.variable.NamesManager.java
/** * @return the default base variable name for given component class. *///from w ww. j a va 2 s .c o m public static String getDefaultName(String qualifiedClassName) { String name = CodeUtils.getShortClass(qualifiedClassName); // check if class name has only upper case characters { boolean onlyUpper = true; for (int i = 0; i < name.length(); i++) { onlyUpper &= Character.isUpperCase(name.charAt(i)); } if (onlyUpper) { return name.toLowerCase(); } } // check if class name starts from lower case character if (Character.isLowerCase(name.charAt(0))) { return name + '_'; } // remove all upper case characters from beginning except last one (most right from beginning) { int index = 0; { int maxIndex = name.length() - 1; while (index < maxIndex && Character.isUpperCase(name.charAt(index + 1))) { index++; } } name = name.substring(index); } // return StringUtils.uncapitalize(name); }