List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:org.amplafi.flow.web.BaseFlowComponent.java
/** * add "-" before each letter that is uppercase and convert uppercase to lowercase. * for example, convert "FooBar" to "foo-bar" * @param baseName//from w ww . j a va 2s . co m * @param sb converted baseName added. */ private void tweak(String baseName, StringBuilder sb) { boolean separate = false; for (int i = 0; i < baseName.length(); i++) { char ch = baseName.charAt(i); if (Character.isUpperCase(ch)) { if (separate) { sb.append('-'); } sb.append(Character.toLowerCase(ch)); } else { sb.append(ch); } separate = true; } }
From source file:org.getobjects.foundation.kvc.KVCWrapper.java
public PropertyDescriptor[] getPropertyDescriptors(Class _class) throws Exception { /**/*from ww w. jav a 2 s . c o m*/ * Our idea of KVC differs from what the Bean API proposes. Instead of * having get<name> and set<name> methods, we expect <name> and * set<name> methods. * * HH: changed to allow for getXYZ style accessors. */ Map<String, Method> settersMap = new HashMap<String, Method>(); Map<String, Method> gettersMap = new HashMap<String, Method>(); Method methods[] = getPublicDeclaredMethods(_class); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method == null) continue; String name = method.getName(); int nameLen = name.length(); int paraCount = method.getParameterTypes().length; if (name.startsWith("set")) { if (method.getReturnType() != Void.TYPE) continue; if (paraCount != 1) continue; if (nameLen == 3) continue; char[] chars = name.substring(3).toCharArray(); chars[0] = Character.toLowerCase(chars[0]); String decapsedName = new String(chars); if (logger.isDebugEnabled()) { logger.debug("Recording setter method [" + method + "] for name \"" + decapsedName + "\""); } settersMap.put(decapsedName, method); } else { /* register as a getter */ if (method.getReturnType() == Void.TYPE) continue; if (paraCount > 0) continue; if (name.startsWith("get")) { char[] chars = name.substring(3).toCharArray(); chars[0] = Character.toLowerCase(chars[0]); name = new String(chars); } if (logger.isDebugEnabled()) { logger.debug("Recording getter method [" + method + "] for name \"" + name + "\""); } gettersMap.put(name, method); } } Set<PropertyDescriptor> pds = new HashSet<PropertyDescriptor>(); /* merge all names from getters and setters */ Set<String> names = new HashSet<String>(gettersMap.keySet()); names.addAll(settersMap.keySet()); for (String name : names) { Method getter = gettersMap.get(name); Method setter = settersMap.get(name); if (getter == null && setter == null) continue; /* this is JavaBeans stuff */ PropertyDescriptor descriptor = new PropertyDescriptor(name, getter, setter); pds.add(descriptor); } return pds.toArray(new PropertyDescriptor[0]); }
From source file:com.videobox.web.util.dwr.AutoAnnotationDiscoveryContainer.java
private String lowerFirst(String name) { return Character.toLowerCase(name.charAt(0)) + name.substring(1); }
From source file:org.cosmo.common.record.Defn.java
public void lazyFieldInit() { String declaredFieldName = getDeclaringFieldName(); String declaredFieldName1 = Character.toLowerCase(declaredFieldName.charAt(0)) + new String(declaredFieldName.toCharArray(), 1, declaredFieldName.length() - 1); String declaredFieldName2 = "_" + declaredFieldName1; try {//from ww w. j a v a 2 s . com _field = getField(_declaringMeta._clazz, declaredFieldName1); } catch (NoSuchFieldException e) { try { _field = getField(_declaringMeta._clazz, declaredFieldName2); } catch (NoSuchFieldException e2) { } } if (_field != null) { _field.setAccessible(true); } else { throw new RuntimeException(New.str("Unable to find match field variable for ", declaredFieldName1, " or ", declaredFieldName2, " for meta ", this._declaringMeta._clazz.getName())); } Class fieldClass = _field.getType(); boolean valid = false; // check if the variable declared matches the Defn type, for enum and record losen up for (Class typeClass : typeClasses()) { if (typeClass.equals(fieldClass) || (this instanceof DefnEnum && typeClass.isAssignableFrom(fieldClass)) || (this instanceof DefnRecord && typeClass.isAssignableFrom(fieldClass))) { valid = true; } } if (!valid) { throw new RecordException( New.str("Invalid Type [", fieldClass, "] for field: " + _field.getType().getSimpleName())); } if (_defaultValue == null) { // set defaultValue if field is primitive type if (isFieldTypePrimitive()) { if (fieldClass == boolean.class) { _defaultValue = false; } else if (fieldClass == int.class) { _defaultValue = 0; } else if (fieldClass == long.class) { _defaultValue = (long) 0; } else if (fieldClass == short.class) { _defaultValue = (short) 0; } else if (fieldClass == byte.class) { _defaultValue = (byte) 0; } else { throw new RecordException("Unknown primitive type " + fieldClass.getName()); } } } try { // read is always from master String readFile = New.str(_declaringMeta.recordDir(true), File.separator, _field.getName()); String writeFile = New.str(_declaringMeta.recordDir(_declaringMeta._mode._isMaster), File.separator, _field.getName()); // should read size from Defn _channel = new FixedFilePartition(new File(readFile), new File(writeFile), 1024 * 1024 * FilePartitionSizeInMB, size()); _writeBytes = new byte[size()]; _writeDataIO = ByteBuffer.wrap(_writeBytes); _readBytes = new byte[size()]; _readDataIO = ByteBuffer.wrap(_readBytes); } catch (IOException e) { throw new RecordException(e); } }
From source file:org.apache.jasper.compiler.JspReader.java
boolean matchesIgnoreCase(String string) throws JasperException { Mark mark = mark();/* w w w . j ava2s .c o m*/ int ch = 0; int i = 0; do { ch = nextChar(); if (Character.toLowerCase((char) ch) != string.charAt(i++)) { reset(mark); return false; } } while (i < string.length()); reset(mark); return true; }
From source file:org.apache.ranger.plugin.util.RangerResourceTrie.java
private final Character getLookupChar(char ch) { if (optIgnoreCase) { ch = Character.toLowerCase(ch); }// ww w .j a v a2 s .c o m return Character.valueOf(ch); }
From source file:com.jabyftw.easiercommands.Util.java
public static int equalityOfChars(char[] string1, char[] string2) { int equality = 0; for (int i = 0; i < Math.min(string1.length, string2.length); i++) equality += Character.toLowerCase(string1[i]) == Character.toLowerCase(string2[i]) ? 1 : -1; return equality; }
From source file:org.apache.hyracks.data.std.primitive.UTF8StringPointable.java
/** * @param src,// w w w. j a v a 2 s. c o m * the source string. * @param pattern, * the pattern string. * @param ignoreCase, * to ignore case or not. * @param startMatch, * the start offset. * @return the byte offset of the first character of the matching string after <code>startMatchPos}</code>. * Not including the MetaLength. */ public static int find(UTF8StringPointable src, UTF8StringPointable pattern, boolean ignoreCase, int startMatch) { int startMatchPos = startMatch; final int srcUtfLen = src.getUTF8Length(); final int pttnUtfLen = pattern.getUTF8Length(); final int srcStart = src.getMetaDataLength(); final int pttnStart = pattern.getMetaDataLength(); int maxStart = srcUtfLen - pttnUtfLen; while (startMatchPos <= maxStart) { int c1 = startMatchPos; int c2 = 0; while (c1 < srcUtfLen && c2 < pttnUtfLen) { char ch1 = src.charAt(srcStart + c1); char ch2 = pattern.charAt(pttnStart + c2); if (ch1 != ch2) { if (!ignoreCase || ignoreCase && Character.toLowerCase(ch1) != Character.toLowerCase(ch2)) { break; } } c1 += src.charSize(srcStart + c1); c2 += pattern.charSize(pttnStart + c2); } if (c2 == pttnUtfLen) { return startMatchPos; } startMatchPos += src.charSize(srcStart + startMatchPos); } return -1; }
From source file:org.archive.modules.forms.HTMLForm.java
/** * Provide abbreviated annotation, of the form... * "form:Phhpt"/*w ww. ja va 2 s . c o m*/ * * ...where the first capital letter indicates submission * type, G[ET] or P[OST], and following lowercase letters * types of inputs in order, by their first letter. * * @return String suitable for brief crawl.log annotation */ public String asAnnotation() { StringBuilder sb = new StringBuilder(); sb.append("form:"); sb.append(Character.toUpperCase(method.charAt(0))); for (FormInput input : allInputs) { sb.append(Character.toLowerCase(input.type.charAt(0))); } return sb.toString(); }
From source file:it.scoppelletti.programmerpower.web.control.ActionBase.java
/** * Inizializza la base del nome delle operazioni dell’azione;. * /* ww w . j a v a 2 s . co m*/ * @return Valore. */ protected String initActionNameBase() { char c; String value; value = getClass().getSimpleName(); if (Strings.isNullOrEmpty(value)) { return ""; } if (value.endsWith(ActionBase.ACTION_SUFFIX)) { value = value.substring(0, value.length() - ActionBase.ACTION_SUFFIX.length()); if (value.isEmpty()) { return ""; } } c = value.charAt(0); if (Character.isUpperCase(c)) { value = String.valueOf(Character.toLowerCase(c)).concat(value.substring(1)); } return value; }