List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:org.cesecore.util.TimeUnitFormat.java
/** * Instantiates a new TimeUnitFormat and initializes it with the given units. * @param units List of units (suffixes, i.e. 'ms', 'mo', 'y', 'd', 'h', 'm', and 's'). *///from ww w . j ava2s.c om public TimeUnitFormat(final List<String> units, final Map<String, Long> factors) { this.units = units; this.factors = factors; this.defaultValues = new LinkedHashMap<String, Long>(units.size()); final StringBuilder builder = new StringBuilder(PATTERN_PREFIX); int index = 0; for (String unit : units) { this.defaultValues.put(unit.toLowerCase(), 0L); if (index++ > 0) { builder.append(OR); } for (char c : unit.toCharArray()) { builder.append(OPENING_BRAKET).append(Character.toLowerCase(c)).append(CLOSING_BRAKET); } } builder.append(PATTERN_SUFFIX); pattern = Pattern.compile(builder.toString(), Pattern.CASE_INSENSITIVE); }
From source file:org.apache.velocity.runtime.parser.node.SetPropertyExecutor.java
/** * @param clazz/* ww w . j av a2s . c o m*/ * @param property * @param arg */ protected void discover(final Class clazz, final String property, final Object arg) { Object[] params = new Object[] { arg }; try { StrBuilder sb = new StrBuilder("set"); sb.append(property); setMethod(introspector.getMethod(clazz, sb.toString(), params)); if (!isAlive()) { /* * now the convenience, flip the 1st character */ char c = sb.charAt(3); if (Character.isLowerCase(c)) { sb.setCharAt(3, Character.toUpperCase(c)); } else { sb.setCharAt(3, Character.toLowerCase(c)); } setMethod(introspector.getMethod(clazz, sb.toString(), params)); } } /** * pass through application level runtime exceptions */ catch (RuntimeException e) { throw e; } catch (Exception e) { String msg = "Exception while looking for property setter for '" + property; Logger.error(this, msg, e); throw new VelocityException(msg, e); } }
From source file:com.android.dialer.lookup.openstreetmap.OpenStreetMapForwardLookup.java
@Override public ContactInfo[] lookup(Context context, String filter, Location lastLocation) { // The OSM API doesn't support case-insentive searches, but does // support regular expressions. String regex = ""; for (int i = 0; i < filter.length(); i++) { char c = filter.charAt(i); regex += "[" + Character.toUpperCase(c) + Character.toLowerCase(c) + "]"; }// w w w . j a va2s . c o m String request = String.format(Locale.ENGLISH, LOOKUP_QUERY, regex, RADIUS, lastLocation.getLatitude(), lastLocation.getLongitude()); try { String httpResponse = httpPostRequest(request); JSONObject results = new JSONObject(httpResponse); return getEntries(results); } catch (IOException e) { Log.e(TAG, "Failed to execute query", e); } catch (JSONException e) { Log.e(TAG, "JSON error", e); } return null; }
From source file:net.yacy.cora.document.encoding.UTF8.java
private boolean equals(final String o0, final String o1, final int l) { char c0, c1;//from w ww. j av a 2 s . co m for (int i = 0; i < l; i++) { if (this.insensitive) { c0 = Character.toLowerCase(o0.charAt(i)); c1 = Character.toLowerCase(o1.charAt(i)); } else { c0 = o0.charAt(i); c1 = o1.charAt(i); } if (c0 == c1) continue; return false; } return true; }
From source file:com.opendoorlogistics.core.utils.strings.Strings.java
public static String toFirstLetterInWordCapitalised(String s) { int n = s.length(); StringBuilder builder = new StringBuilder(); boolean lastIsSpace = true; for (int i = 0; i < n; i++) { char c = s.charAt(i); if (lastIsSpace) { builder.append(Character.toUpperCase(c)); } else {/*from w w w . ja va 2 s . c o m*/ builder.append(Character.toLowerCase(c)); } lastIsSpace = Character.isWhitespace(c); } return builder.toString(); }
From source file:com.mawujun.utils.string.StringUtils.java
/** * ?/*from w w w. j a va 2 s . c o m*/ * @author mawujun email:160649888@163.com qq:16064988 * @param param * @return */ public static String camelToUnderline(String param) { if (param == null || "".equals(param.trim())) { return ""; } int len = param.length(); StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { char c = param.charAt(i); if (Character.isUpperCase(c)) { sb.append(UNDERLINE); sb.append(Character.toLowerCase(c)); } else { sb.append(c); } } return sb.toString(); }
From source file:bboss.org.apache.velocity.runtime.parser.node.SetPropertyExecutor.java
/** * @param clazz// w w w . jav a 2 s . co m * @param property * @param arg */ protected void discover(final Class clazz, final String property, final Object arg) { Object[] params = new Object[] { arg }; try { StrBuilder sb = new StrBuilder("set"); sb.append(property); setMethod(introspector.getMethod(clazz, sb.toString(), params)); if (!isAlive()) { /* * now the convenience, flip the 1st character */ char c = sb.charAt(3); if (Character.isLowerCase(c)) { sb.setCharAt(3, Character.toUpperCase(c)); } else { sb.setCharAt(3, Character.toLowerCase(c)); } setMethod(introspector.getMethod(clazz, sb.toString(), params)); } } /** * pass through application level runtime exceptions */ catch (RuntimeException e) { throw e; } catch (Exception e) { String msg = "Exception while looking for property setter for '" + property; log.error(msg, e); throw new VelocityException(msg, e); } }
From source file:com.github.braully.web.DescriptorHtmlEntity.java
public static String decapitalize(String string) { if (string == null || string.length() == 0) { return string; }//w w w . ja va 2s . c o m char c[] = string.toCharArray(); c[0] = Character.toLowerCase(c[0]); return new String(c); }
From source file:au.org.ala.delta.intkey.directives.StandardIntkeyDirective.java
@Override public IntkeyDirectiveInvocation doProcess(IntkeyContext context, String data) throws Exception { StringBuilder stringRepresentationBuilder = new StringBuilder(); stringRepresentationBuilder.append(StringUtils.join(getControlWords(), " ").toUpperCase()); List<String> tokens = ParsingUtils.tokenizeDirectiveCall(data); Queue<String> tokenQueue = new ArrayDeque<String>(tokens); IntkeyDirectiveInvocation invoc = buildCommandObject(); if (_intkeyFlagsList != null && tokenQueue.size() > 0) { boolean matchingFlags = true; while (matchingFlags) { boolean tokenMatched = false; String token = tokenQueue.peek(); if (token != null) { for (IntkeyDirectiveFlag flag : _intkeyFlagsList) { if (flag.takesStringValue()) { // Flag can have a string value supplied with it in // format "/X=string", where X is the character // symbol. Note that // it is acceptable to supply such a flag without a // following equals sign and string value. if (token.matches("^/[" + Character.toLowerCase(flag.getSymbol()) + Character.toUpperCase(flag.getSymbol()) + "](=.+)?")) { // If string value is not supplied, it defaults // to empty string String flagStringValue = ""; String[] tokenPieces = token.split("="); // There should only be 0 or 1 equals sign. If // more than none is supplied, no match. if (tokenPieces.length < 3) { if (tokenPieces.length == 2) { flagStringValue = tokenPieces[1]; }/* w w w . jav a2 s . c om*/ BeanUtils.setProperty(invoc, flag.getName(), flagStringValue); tokenQueue.remove(); tokenMatched = true; stringRepresentationBuilder.append(" "); stringRepresentationBuilder.append(token); break; } } } else { if (token.equalsIgnoreCase("/" + flag.getSymbol())) { BeanUtils.setProperty(invoc, flag.getName(), true); tokenQueue.remove(); tokenMatched = true; stringRepresentationBuilder.append(" "); stringRepresentationBuilder.append(token); break; } } } matchingFlags = tokenMatched; } else { matchingFlags = false; } } } // The arguments list needs to be generated each time a call to the // directive is processed. This is // because most arguments need to have provided with an initial value // which is used when prompting the user. // This initial value needs to be read out of the IntkeyContext at the // time of parsing. // E.g. the integer argument for the SET TOLERANCE directive will have // an initial value equal to the // the value of the tolerance setting before the call to the directive. List<IntkeyDirectiveArgument<?>> intkeyArgsList = generateArgumentsList(context); if (intkeyArgsList != null) { for (IntkeyDirectiveArgument<?> arg : intkeyArgsList) { Object parsedArgumentValue = arg.parseInput(tokenQueue, context, StringUtils.join(_controlWords, " "), stringRepresentationBuilder); if (parsedArgumentValue != null) { BeanUtils.setProperty(invoc, arg.getName(), parsedArgumentValue); } else { // No argument value supplied, user cancelled out of the // prompt dialog. return null; } } } invoc.setStringRepresentation(stringRepresentationBuilder.toString()); return invoc; }
From source file:org.amplafi.flow.FlowUtils.java
public String toLowerCase(String flowName) { StringBuilder sb = new StringBuilder(); if (isNotBlank(flowName)) { for (int i = 0; i < flowName.length(); i++) { if (Character.isUpperCase(flowName.charAt(i))) { if (i > 0) { sb.append('-'); }/*from w w w .j a va 2 s . com*/ sb.append(Character.toLowerCase(flowName.charAt(i))); } else { sb.append(flowName.charAt(i)); } } } return sb.toString(); }