List of usage examples for java.lang Character isLowerCase
public static boolean isLowerCase(int codePoint)
From source file:org.icgc.dcc.release.job.fathmm.core.FathmmPredictor.java
private static String mapPosition(int seqStart, int seqEnd, int hmmBegin, String align, int substitution) { if (substitution < seqStart || substitution > seqEnd) return null; int start = seqStart - 1; int end = hmmBegin - 1; for (char c : align.toCharArray()) { if (Character.isUpperCase(c) || Character.isLowerCase(c)) start++;//from www .j av a 2 s . c om if (Character.isUpperCase(c) || c == '-') end++; if (start == substitution && Character.isUpperCase(c)) return String.valueOf(end); } return null; }
From source file:org.hyperic.hq.plugin.jboss.JBossUtil.java
static Object getRemoteMBeanValue(Metric metric) throws MetricNotFoundException, MetricInvalidException, MetricUnreachableException, PluginException { MBeanServerConnection mServer = null; boolean cached = true; String url = getServerURL(metric); synchronized (serverCache) { mServer = (MBeanServerConnection) serverCache.get(url); }/* w w w.ja v a2 s. com*/ if (mServer == null) { cached = false; try { mServer = getMBeanServerConnection(metric); //jndi lookup } catch (NamingException e) { throw unreachable(metric, e); } catch (RemoteException e) { throw unreachable(metric, e); } determineJSR77Case(url, mServer); synchronized (serverCache) { serverCache.put(url, mServer); } } String attrName = metric.getAttributeName(); boolean lc; Boolean jsr77Case; synchronized (lowerCaseURLMappings) { jsr77Case = (Boolean) lowerCaseURLMappings.get(url); } if (jsr77Case != null) { lc = jsr77Case.booleanValue(); } else { lc = Character.isLowerCase(attrName.charAt(0)); } String lcAttr; //another 3.2.8 hack if (lc && ((lcAttr = (String) jsr77LowerCase.get(attrName)) != null)) { attrName = lcAttr; } try { ObjectName objName = new ObjectName(metric.getObjectName()); if (attrName.substring(1).startsWith(/*S*/"tatistic")) { return getJSR77Statistic(mServer, objName, metric, lc); } else if (attrName.equals("__INSTANCE__")) { //cheap hack for an avail metric for MBeans that dont //have anything better we can use, e.g. Hibernate. try { mServer.getObjectInstance(objName); return Boolean.TRUE; } catch (Exception e) { return Boolean.FALSE; } } else { return mServer.getAttribute(objName, attrName); } } catch (MalformedObjectNameException e) { throw invalid(metric, e); } catch (InstanceNotFoundException e) { throw notfound(metric, e); } catch (AttributeNotFoundException e) { //XXX not all MBeans have a reasonable attribute to //determine availability, so just assume if we get this far //the MBean exists and is alive. if (attrName.equals(Metric.ATTR_AVAIL)) { return new Double(Metric.AVAIL_UP); } throw notfound(metric, e); } catch (ReflectionException e) { throw error(metric, e); } catch (MBeanException e) { throw error(metric, e); } catch (RuntimeMBeanException e) { throw error(metric, e); } catch (Exception e) { //CommunicationException, NamingException, RemoteException, etc. if (cached) { //retry once, in the event the cached connection was stale synchronized (serverCache) { serverCache.remove(url); } log.debug("MBeanServerConnection cache cleared for " + url); return getRemoteMBeanValue(metric); } else { throw unreachable(metric, e); } } }
From source file:de.aschoerk.javaconv.RustDumpVisitor.java
private String toSnakeIfNecessary(String n) { if (namesMap.containsKey(n)) { n = namesMap.get(n);/*from w w w. j a v a 2s . co m*/ } String name = n; if (Character.isLowerCase(name.charAt(0))) { StringBuilder sb = new StringBuilder(); for (Character c : name.toCharArray()) { if (Character.isUpperCase(c)) { sb.append("_").append(Character.toLowerCase(c)); } else { sb.append(c); } } return sb.toString(); } return n; }
From source file:com.microsoft.windowsazure.management.storage.StorageAccountOperationsImpl.java
/** * The Begin Creating Storage Account operation creates a new storage * account in Azure. (see/*from w w w .ja va 2s. com*/ * http://msdn.microsoft.com/en-us/library/windowsazure/hh264518.aspx for * more information) * * @param parameters Required. Parameters supplied to the Begin Creating * 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 beginCreating(StorageAccountCreateParameters parameters) throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException { // Validate if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getDescription() != null && parameters.getDescription().length() > 1024) { throw new IllegalArgumentException("parameters.Description"); } if (parameters.getLabel() == null) { throw new NullPointerException("parameters.Label"); } if (parameters.getLabel().length() > 100) { throw new IllegalArgumentException("parameters.Label"); } if (parameters.getName() == null) { throw new NullPointerException("parameters.Name"); } if (parameters.getName().length() < 3) { throw new IllegalArgumentException("parameters.Name"); } if (parameters.getName().length() > 24) { throw new IllegalArgumentException("parameters.Name"); } for (char nameChar : parameters.getName().toCharArray()) { if (Character.isLowerCase(nameChar) == false && Character.isDigit(nameChar) == false) { throw new IllegalArgumentException("parameters.Name"); } } // TODO: Validate parameters.Name is a valid DNS name. // 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, "beginCreatingAsync", 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"; 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", "2014-10-01"); // Serialize Request String requestContent = null; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document requestDoc = documentBuilder.newDocument(); Element createStorageServiceInputElement = requestDoc .createElementNS("http://schemas.microsoft.com/windowsazure", "CreateStorageServiceInput"); requestDoc.appendChild(createStorageServiceInputElement); Element serviceNameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "ServiceName"); serviceNameElement.appendChild(requestDoc.createTextNode(parameters.getName())); createStorageServiceInputElement.appendChild(serviceNameElement); if (parameters.getDescription() != null) { Element descriptionElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Description"); descriptionElement.appendChild(requestDoc.createTextNode(parameters.getDescription())); createStorageServiceInputElement.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); createStorageServiceInputElement.appendChild(emptyElement); } Element labelElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Label"); labelElement.appendChild(requestDoc.createTextNode(Base64.encode(parameters.getLabel().getBytes()))); createStorageServiceInputElement.appendChild(labelElement); if (parameters.getAffinityGroup() != null) { Element affinityGroupElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "AffinityGroup"); affinityGroupElement.appendChild(requestDoc.createTextNode(parameters.getAffinityGroup())); createStorageServiceInputElement.appendChild(affinityGroupElement); } if (parameters.getLocation() != null) { Element locationElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Location"); locationElement.appendChild(requestDoc.createTextNode(parameters.getLocation())); createStorageServiceInputElement.appendChild(locationElement); } 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); } createStorageServiceInputElement.appendChild(extendedPropertiesDictionaryElement); } } if (parameters.getAccountType() != null) { Element accountTypeElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "AccountType"); accountTypeElement.appendChild(requestDoc.createTextNode(parameters.getAccountType())); createStorageServiceInputElement.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_ACCEPTED) { 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.screenslicer.core.nlp.Person.java
private static boolean isFirstName(String str, boolean strict) { if (!isValidNameChars(str)) { return false; }//from w w w . jav a 2 s . com if (Character.isLowerCase(str.charAt(0))) { return false; } return (strict && firstNamesPopular.contains(str)) || (!strict && firstNames.contains(str)); }
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>. /* www. j ava2s .co 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. * * @param separator The character <-> will be replaced with a ':' * in case of a COLON, a '-' in case of a HYPHEN, etc. NONE can * be selected for output of the format FFFFFFFFFFFF. In this * latter case, no separating character will be appended * between octets.</p> * * * @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, final Separator separator) throws NoSuchFuzzerException { final char charSeparator1 = MACAddrFuzzer.getFirstSeparator(macStart); final char charSeparator2 = MACAddrFuzzer.getFirstSeparator(macEnd); this.separator = separator; 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.hyperic.hq.plugin.tomcat.JBossUtil.java
static Object getRemoteMBeanValue(Metric metric) throws MetricNotFoundException, MetricInvalidException, MetricUnreachableException, PluginException { MBeanServerConnection mServer = null; boolean cached = true; String url = getServerURL(metric); synchronized (serverCache) { mServer = (MBeanServerConnection) serverCache.get(url); }/*from w w w . j a v a 2 s . c om*/ if (mServer == null) { cached = false; try { mServer = getMBeanServerConnection(metric); //jndi lookup } catch (NamingException e) { throw unreachable(metric, e); } catch (RemoteException e) { throw unreachable(metric, e); } // determineJSR77Case(url, mServer); synchronized (serverCache) { serverCache.put(url, mServer); } } String attrName = metric.getAttributeName(); boolean lc; Boolean jsr77Case; synchronized (lowerCaseURLMappings) { jsr77Case = (Boolean) lowerCaseURLMappings.get(url); } if (jsr77Case != null) { lc = jsr77Case.booleanValue(); } else { lc = Character.isLowerCase(attrName.charAt(0)); } String lcAttr; //another 3.2.8 hack if (lc && ((lcAttr = (String) jsr77LowerCase.get(attrName)) != null)) { attrName = lcAttr; } try { ObjectName objName = new ObjectName(metric.getObjectName()); if (attrName.substring(1).startsWith(/*S*/"tatistic")) { return getJSR77Statistic(mServer, objName, metric, lc); } else if (attrName.equals("__INSTANCE__")) { //cheap hack for an avail metric for MBeans that dont //have anything better we can use, e.g. Hibernate. try { mServer.getObjectInstance(objName); return Boolean.TRUE; } catch (Exception e) { return Boolean.FALSE; } } else { return mServer.getAttribute(objName, attrName); } } catch (MalformedObjectNameException e) { throw invalid(metric, e); } catch (InstanceNotFoundException e) { throw notfound(metric, e); } catch (AttributeNotFoundException e) { //XXX not all MBeans have a reasonable attribute to //determine availability, so just assume if we get this far //the MBean exists and is alive. if (attrName.equals(Metric.ATTR_AVAIL)) { return new Double(Metric.AVAIL_UP); } throw notfound(metric, e); } catch (ReflectionException e) { throw error(metric, e); } catch (MBeanException e) { throw error(metric, e); } catch (RuntimeMBeanException e) { throw error(metric, e); } catch (Exception e) { //CommunicationException, NamingException, RemoteException, etc. if (cached) { //retry once, in the event the cached connection was stale synchronized (serverCache) { serverCache.remove(url); } log.debug("MBeanServerConnection cache cleared for " + url); return getRemoteMBeanValue(metric); } else { throw unreachable(metric, e); } } }
From source file:com.screenslicer.core.nlp.Person.java
private static boolean isLastName(String str) { if (!isValidNameChars(str)) { return false; }//from w w w . j av a2s . c om if (Character.isLowerCase(str.charAt(0))) { return false; } return lastNames.contains(str.toUpperCase()); }
From source file:org.kuali.rice.edl.framework.workflow.EDocLitePostProcessor.java
private static String lowerCaseFirstChar(String s) { if (s.length() == 0 || Character.isLowerCase(s.charAt(0))) return s; StringBuffer sb = new StringBuffer(s.length()); sb.append(Character.toLowerCase(s.charAt(0))); if (s.length() > 1) { sb.append(s.substring(1));/*from w w w . j ava 2 s. c om*/ } return sb.toString(); }
From source file:com.revolsys.record.io.format.xml.XmlProcessor.java
@SuppressWarnings("unchecked") public <T> T parseObject(final StaxReader parser, final Class<? extends T> objectClass) throws IOException { try {//from ww w .jav a2 s. com if (objectClass == null) { Object object = null; while (parser.nextTag() == XMLStreamConstants.START_ELEMENT) { if (object != null) { throw new IllegalArgumentException( "Expecting a single child element " + parser.getLocation()); } object = process(parser); } return (T) object; } else { final T object = objectClass.newInstance(); if (object instanceof Collection) { final Collection<Object> collection = (Collection<Object>) object; while (parser.nextTag() == XMLStreamConstants.START_ELEMENT) { final Object value = process(parser); collection.add(value); } } else { while (parser.nextTag() == XMLStreamConstants.START_ELEMENT) { final String tagName = parser.getName().getLocalPart(); final Object value = process(parser); try { String propertyName; if (tagName.length() > 1 && Character.isLowerCase(tagName.charAt(1))) { propertyName = CaseConverter.toLowerFirstChar(tagName); } else { propertyName = tagName; } BeanUtils.setProperty(object, propertyName, value); } catch (final Throwable e) { e.printStackTrace(); } } } return object; } } catch (final InstantiationException e) { throw new IllegalArgumentException(e); } catch (final IllegalAccessException e) { throw new IllegalArgumentException(e); } }