List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:net.sf.cocmvc.ConventionalHandlerMapping.java
private String toCamelCase(String str) { if (!StringUtils.hasText(str)) return str; return Character.toLowerCase(str.charAt(0)) + (str.length() > 1 ? str.substring(1) : ""); }
From source file:org.apache.hadoop.gateway.config.impl.DefaultConfigurationInjector.java
private static String getConfigName(Method method) { String methodName = method.getName(); if (methodName != null) { StringBuilder name = new StringBuilder(methodName.length()); if (methodName.length() > 3 && methodName.startsWith("set") && Character.isUpperCase(methodName.charAt(3))) { name.append(methodName.substring(3)); name.setCharAt(0, Character.toLowerCase(name.charAt(0))); } else {/* w w w . j ava 2 s .c o m*/ name.append(name); } return name.toString(); } return null; }
From source file:it.mb.whatshare.CallGooGlInbound.java
private static String getURL(String encodedId, String deviceAssignedID) { StringBuilder builder = new StringBuilder("http://"); Random generator = new Random(); int sum = 0;/*from w ww .jav a2 s .com*/ for (int i = 0; i < 8; i++) { char rand = CHARACTERS[generator.nextInt(CHARACTERS.length)]; builder.append(rand); // no idea why they set lowercase for domain names... sum += CHAR_MAP.get(Character.toLowerCase(rand)); } builder.append("/"); builder.append(sum); builder.append("?model="); try { builder.append(URLEncoder .encode(String.format("%s %s", Utils.capitalize(Build.MANUFACTURER), Build.MODEL), "UTF-8") .replaceAll("\\+", "%20")); builder.append("&yourid="); builder.append(deviceAssignedID); builder.append("&id="); builder.append(encodedId); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return builder.toString(); }
From source file:org.disit.servicemap.api.ServiceMapApi.java
public void queryFulltext(JspWriter out, RepositoryConnection con, String textToSearch, String selection, String dist, String limit) throws Exception { Configuration conf = Configuration.getInstance(); String sparqlType = conf.get("sparqlType", "virtuoso"); String km4cVersion = conf.get("km4cVersion", "new"); String[] coords = null;/*from w w w .j a v a 2 s. c o m*/ if (selection != null && selection.contains(";")) { coords = selection.split(";"); } String queryText = "PREFIX luc: <http://www.ontotext.com/owlim/lucene#>\n" + "PREFIX km4c:<http://www.disit.org/km4city/schema#>\n" + "PREFIX km4cr:<http://www.disit.org/km4city/resource#>\n" + "PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#>\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n" + "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "PREFIX schema:<http://schema.org/>\n" + "PREFIX omgeo:<http://www.ontotext.com/owlim/geo#>\n" + "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n" + "PREFIX foaf:<http://xmlns.com/foaf/0.1/>\n" + "SELECT DISTINCT ?ser ?long ?lat ?sType ?sTypeIta ?sCategory ?sName ?txt ?x WHERE {\n" + ServiceMap.textSearchQueryFragment("?ser", "?p", textToSearch) + (km4cVersion.equals( "old") ? " OPTIONAL { ?ser km4c:hasServiceCategory ?cat.\n" + " ?cat rdfs:label ?sTypeIta. FILTER(LANG(?sTypeIta)=\"it\") }\n" : " {\n" + " ?ser a ?sType. FILTER(?sType!=km4c:RegularService && ?sType!=km4c:Service && ?sType!=km4c:DigitalLocation && ?sType!=km4c:TransverseService)\n" + " OPTIONAL { ?sType rdfs:subClassOf ?sCategory. FILTER(STRSTARTS(STR(?sCategory),\"http://www.disit.org/km4city/schema#\"))}\n" + " ?sType rdfs:label ?sTypeIta. FILTER(LANG(?sTypeIta)=\"it\")\n" + " }\n") + " OPTIONAL {{?ser schema:name ?sName } UNION { ?ser foaf:name ?sName }}\n" + " {\n" + " ?ser geo:lat ?lat .\n" + " ?ser geo:long ?long .\n" + ServiceMap.geoSearchQueryFragment("?ser", coords, dist) + " } UNION {\n" + " ?ser km4c:hasAccess ?entry.\n" + " ?entry geo:lat ?lat.\n" + " ?entry geo:long ?long.\n" + ServiceMap.geoSearchQueryFragment("?entry", coords, dist) /*+ "} UNION {" + " ?ser km4c:hasStreetNumber/km4c:hasExternalAccess ?entry." + " ?entry geo:lat ?lat." + " ?entry geo:long ?long." + ServiceMap.geoSearchQueryFragment("?entry", coords, dist)*/ + " }\n" + "} ORDER BY DESC(?sc)"; if (!"0".equals(limit)) { queryText += " LIMIT " + limit; } TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryText); long start = System.nanoTime(); TupleQueryResult result = tupleQuery.evaluate(); logQuery(queryText, "free-text-search", sparqlType, textToSearch + ";" + limit, System.nanoTime() - start); int i = 0; out.println("{ " + "\"type\": \"FeatureCollection\", " + "\"features\": [ "); while (result.hasNext()) { if (i != 0) { out.println(", "); } BindingSet bindingSet = result.next(); String serviceUri = bindingSet.getValue("ser").stringValue(); String serviceLat = ""; if (bindingSet.getValue("lat") != null) { serviceLat = bindingSet.getValue("lat").stringValue(); } String serviceLong = ""; if (bindingSet.getValue("long") != null) { serviceLong = bindingSet.getValue("long").stringValue(); } String label = ""; if (bindingSet.getValue("sTypeIta") != null) { label = bindingSet.getValue("sTypeIta").stringValue(); //label = Character.toLowerCase(label.charAt(0)) + label.substring(1); label = label.replace(" ", "_"); label = label.replace("'", ""); } // DICHIARAZIONE VARIABILI serviceType e serviceCategory per ICONA String subCategory = ""; if (bindingSet.getValue("sType") != null) { subCategory = bindingSet.getValue("sType").stringValue(); subCategory = subCategory.replace("http://www.disit.org/km4city/schema#", ""); subCategory = Character.toLowerCase(subCategory.charAt(0)) + subCategory.substring(1); subCategory = subCategory.replace(" ", "_"); } String category = ""; if (bindingSet.getValue("sCategory") != null) { category = bindingSet.getValue("sCategory").stringValue(); category = category.replace("http://www.disit.org/km4city/schema#", ""); category = Character.toLowerCase(category.charAt(0)) + category.substring(1); category = category.replace(" ", "_"); } String sName = ""; if (bindingSet.getValue("sName") != null) { sName = bindingSet.getValue("sName").stringValue(); } else { sName = subCategory.replace("_", " ").toUpperCase(); } // Controllo categoria SensorSite e BusStop per ricerca testuale. String serviceType = ""; String valueOfLinee = ""; //Da verificare se OK /*if (subCategory.equals("sensorSite")) { serviceType = "RoadSensor"; } else if (subCategory.equals("busStop")) { serviceType = "NearBusStop"; TupleQueryResult resultLinee = queryBusLines(sName, con); if(resultLinee != null){ while (resultLinee.hasNext()) { BindingSet bindingSetLinee = resultLinee.next(); String idLinee = bindingSetLinee.getValue("id").stringValue(); valueOfLinee = valueOfLinee + " - "+idLinee; } if(valueOfLinee.length()>3) valueOfLinee = valueOfLinee.substring(3); } } else if(! "".equals(category)){ serviceType = category + "_" + subCategory; }*/ serviceType = category + "_" + subCategory; if (subCategory.equals("BusStop")) { TupleQueryResult resultLinee = queryBusLines(sName, con); if (resultLinee != null) { while (resultLinee.hasNext()) { BindingSet bindingSetLinee = resultLinee.next(); String idLinee = bindingSetLinee.getValue("id").stringValue(); valueOfLinee = valueOfLinee + " - " + idLinee; } if (valueOfLinee.length() > 3) valueOfLinee = valueOfLinee.substring(3); } } String txt = ""; if (bindingSet.getValue("txt") != null) { txt = bindingSet.getValue("txt").stringValue(); } out.println("{ " + " \"geometry\": { " + " \"type\": \"Point\", " + " \"coordinates\": [ " + " " + serviceLong + ", " + " " + serviceLat + " " + " ] " + "}, " + "\"type\": \"Feature\", " + "\"properties\": { " + " \"serviceUri\": \"" + serviceUri + "\", " // *** INSERIMENTO serviceType // ********************************************** + "\"nome\": \"" + ServiceMap.escapeJSON(sName) + "\", "); if (!"".equals(category)) out.println("\"tipo\": \"servizio\", " + " \"serviceType\": \"" + escapeJSON(mapServiceType(serviceType)) + "\", "); out.println("\"type\": \"" + ServiceMap.escapeJSON(label) + "\", " + " \"linee\": \"" + escapeJSON(valueOfLinee) + "\" " + "}, " + "\"id\": " + Integer.toString(i + 1) + " " // + "\"query\": \"" + queryString + "\" " + "}"); i++; } out.println("] " + "}"); }
From source file:org.dasein.persist.riak.RiakCache.java
public String getBucket() { if (bucketName == null) { String entityName = getEntityName(); if (entityName != null) { bucketName = entityName;//from w w w .j ava 2s . c o m return bucketName; } String name = getEntityClassName(); int idx = name.lastIndexOf('.'); while (idx == 0 && name.length() > 1) { name = name.substring(1); idx = name.lastIndexOf('.'); } while (idx == (name.length() - 1) && name.length() > 1) { name = name.substring(0, name.length() - 1); idx = name.lastIndexOf('.'); } if (idx == -1 || name.length() < 2) { return name; } name = name.substring(idx + 1); StringBuilder s = new StringBuilder(); for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (Character.isUpperCase(c) && i > 0) { s.append("_"); } s.append(Character.toLowerCase(c)); } bucketName = s.toString(); } return bucketName; }
From source file:net.minder.config.impl.DefaultConfigurationInjector.java
private static String getConfigName(Method method) { String methodName = method.getName(); StringBuilder name = new StringBuilder(methodName.length()); if (methodName != null && methodName.length() > 3 && methodName.startsWith("set") && Character.isUpperCase(methodName.charAt(3))) { name.append(methodName.substring(3)); name.setCharAt(0, Character.toLowerCase(name.charAt(0))); } else {// w w w.j a va 2s . c o m name.append(name); } return name.toString(); }
From source file:StringUtils.java
public static String uncapitalize(String string) { return string.length() == 0 ? "" : Character.toLowerCase(string.charAt(0)) + string.substring(1); }
From source file:HtmlUtil.java
/** * Finds first index of a substring in the given source string with ignored * case. This seems to be the fastest way doing this, with common string * length and content (of course, with no use of Boyer-Mayer type of * algorithms). Other implementations are slower: getting char array frist, * lowercasing the source string, using String.regionMatch etc. * * @param src source string for examination * @param subS substring to find//from w ww .j a va 2 s .c o m * @param startIndex starting index from where search begins * * @return index of founded substring or -1 if substring is not found */ public static int indexOfIgnoreCase(String src, String subS, int startIndex) { String sub = subS.toLowerCase(Locale.CHINA); int sublen = sub.length(); int total = src.length() - sublen + 1; for (int i = startIndex; i < total; i++) { int j = 0; while (j < sublen) { char source = Character.toLowerCase(src.charAt(i + j)); if (sub.charAt(j) != source) { break; } j++; } if (j == sublen) { return i; } } return -1; }
From source file:org.apache.axis.encoding.ser.BeanDeserializer.java
/** * Deserializer interface called on each child element encountered in * the XML stream.//from w w w .ja va 2 s . com * @param namespace is the namespace of the child element * @param localName is the local name of the child element * @param prefix is the prefix used on the name of the child element * @param attributes are the attributes of the child element * @param context is the deserialization context. * @return is a Deserializer to use to deserialize a child (must be * a derived class of SOAPHandler) or null if no deserialization should * be performed. */ public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) throws SAXException { handleMixedContent(); BeanPropertyDescriptor propDesc = null; FieldDesc fieldDesc = null; SOAPConstants soapConstants = context.getSOAPConstants(); String encodingStyle = context.getEncodingStyle(); boolean isEncoded = Constants.isSOAP_ENC(encodingStyle); QName elemQName = new QName(namespace, localName); // The collectionIndex needs to be reset for Beans with multiple arrays if ((prevQName == null) || (!prevQName.equals(elemQName))) { collectionIndex = -1; } boolean isArray = false; QName itemQName = null; if (typeDesc != null) { // Lookup the name appropriately (assuming an unqualified // name for SOAP encoding, using the namespace otherwise) String fieldName = typeDesc.getFieldNameForElement(elemQName, isEncoded); propDesc = (BeanPropertyDescriptor) propertyMap.get(fieldName); fieldDesc = typeDesc.getFieldByName(fieldName); if (fieldDesc != null) { ElementDesc element = (ElementDesc) fieldDesc; isArray = element.isMaxOccursUnbounded(); itemQName = element.getItemQName(); } } if (propDesc == null) { // look for a field by this name. propDesc = (BeanPropertyDescriptor) propertyMap.get(localName); } // Workaround if (propDesc == null) { StringBuffer sb = new StringBuffer(); sb.append(Character.toLowerCase(localName.charAt(0))); if (localName.length() > 1) sb.append(localName.substring(1)); // look for a field by this name. propDesc = (BeanPropertyDescriptor) propertyMap.get(sb.toString()); } // try and see if this is an xsd:any namespace="##any" element before // reporting a problem if (propDesc == null || (((prevQName != null) && prevQName.equals(elemQName) && !(propDesc.isIndexed() || isArray) && getAnyPropertyDesc() != null))) { // try to put unknown elements into a SOAPElement property, if // appropriate prevQName = elemQName; propDesc = getAnyPropertyDesc(); if (propDesc != null) { try { MessageElement[] curElements = (MessageElement[]) propDesc.get(value); int length = 0; if (curElements != null) { length = curElements.length; } MessageElement[] newElements = new MessageElement[length + 1]; if (curElements != null) { System.arraycopy(curElements, 0, newElements, 0, length); } MessageElement thisEl = context.getCurElement(); newElements[length] = thisEl; propDesc.set(value, newElements); // if this is the first pass through the MessageContexts // make sure that the correct any element is set, // that is the child of the current MessageElement, however // on the first pass this child has not been set yet, so // defer it to the child SOAPHandler if (!localName.equals(thisEl.getName())) { return new SOAPHandler(newElements, length); } return new SOAPHandler(); } catch (Exception e) { throw new SAXException(e); } } } if (propDesc == null) { // No such field throw new SAXException(Messages.getMessage("badElem00", javaType.getName(), localName)); } prevQName = elemQName; // Get the child's xsi:type if available QName childXMLType = context.getTypeFromAttributes(namespace, localName, attributes); String href = attributes.getValue(soapConstants.getAttrHref()); Class fieldType = propDesc.getType(); // If no xsi:type or href, check the meta-data for the field if (childXMLType == null && fieldDesc != null && href == null) { childXMLType = fieldDesc.getXmlType(); if (itemQName != null) { // This is actually a wrapped literal array and should be // deserialized with the ArrayDeserializer childXMLType = Constants.SOAP_ARRAY; fieldType = propDesc.getActualType(); } else { childXMLType = fieldDesc.getXmlType(); } } // Get Deserializer for child, default to using DeserializerImpl Deserializer dSer = getDeserializer(childXMLType, fieldType, href, context); // It is an error if the dSer is not found - the only case where we // wouldn't have a deserializer at this point is when we're trying // to deserialize something we have no clue about (no good xsi:type, // no good metadata). if (dSer == null) { dSer = context.getDeserializerForClass(propDesc.getType()); } // Fastpath nil checks... if (context.isNil(attributes)) { if ((propDesc.isIndexed() || isArray)) { if (!((dSer != null) && (dSer instanceof ArrayDeserializer))) { collectionIndex++; dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc, collectionIndex)); addChildDeserializer(dSer); return (SOAPHandler) dSer; } } return null; } if (dSer == null) { throw new SAXException(Messages.getMessage("noDeser00", childXMLType.toString())); } if (constructorToUse != null) { if (constructorTarget == null) { constructorTarget = new ConstructorTarget(constructorToUse, this); } dSer.registerValueTarget(constructorTarget); } else if (propDesc.isWriteable()) { // If this is an indexed property, and the deserializer we found // was NOT the ArrayDeserializer, this is a non-SOAP array: // <bean> // <field>value1</field> // <field>value2</field> // ... // In this case, we want to use the collectionIndex and make sure // the deserialized value for the child element goes into the // right place in the collection. // Register value target if ((itemQName != null || propDesc.isIndexed() || isArray) && !(dSer instanceof ArrayDeserializer)) { collectionIndex++; dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc, collectionIndex)); } else { // If we're here, the element maps to a single field value, // whether that be a "basic" type or an array, so use the // normal (non-indexed) BeanPropertyTarget form. collectionIndex = -1; dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc)); } } // Let the framework know that we need this deserializer to complete // for the bean to complete. addChildDeserializer(dSer); return (SOAPHandler) dSer; }
From source file:com.github.pockethub.ui.repo.RepositoryListFragment.java
private void updateHeaders(final List<Repo> repos) { HeaderFooterListAdapter<?> rootAdapter = getListAdapter(); if (rootAdapter == null) return;// w w w. j av a2 s. c om DefaultRepositoryListAdapter adapter = (DefaultRepositoryListAdapter) rootAdapter.getWrappedAdapter(); adapter.clearHeaders(); if (repos.isEmpty()) return; // Add recent header if at least one recent repository Repo first = repos.get(0); if (recentRepos.contains(first)) adapter.registerHeader(first, getString(R.string.recently_viewed)); // Advance past all recent repositories int index; Repo current = null; for (index = 0; index < repos.size(); index++) { Repo repository = repos.get(index); if (recentRepos.contains(repository.id)) current = repository; else break; } if (index >= repos.size()) return; if (current != null) adapter.registerNoSeparator(current); // Register header for first character current = repos.get(index); char start = Character.toLowerCase(current.name.charAt(0)); adapter.registerHeader(current, Character.toString(start).toUpperCase(US)); char previousHeader = start; for (index = index + 1; index < repos.size(); index++) { current = repos.get(index); char repoStart = Character.toLowerCase(current.name.charAt(0)); if (repoStart <= start) continue; // Don't include separator for the last element of the previous // character if (previousHeader != repoStart) adapter.registerNoSeparator(repos.get(index - 1)); adapter.registerHeader(current, Character.toString(repoStart).toUpperCase(US)); previousHeader = repoStart; start = repoStart++; } // Don't include separator for last element adapter.registerNoSeparator(repos.get(repos.size() - 1)); }