List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:org.aver.fft.impl.FlatFileTransformer.java
/** * Reads the specified class and loads into (if not already loaded) a map * containing the bean class name to a {@link Record} instance. The Record * instance will contain metadata about the record format. * // www. j a v a 2 s.c o m * @param destClazz */ private void parseRecordMappingDetails() { if (!recordMap.containsKey(clazz.getName())) { synchronized (recordMap) { Record rec = new Record(clazz.getName()); recordMap.put(rec.getName(), rec); for (Method m : clazz.getMethods()) { if (m.isAnnotationPresent(org.aver.fft.annotations.Column.class)) { String colname = m.getName(); if (m.getName().startsWith("get") || m.getName().startsWith("set")) { colname = colname.substring(3); } colname = Character.toLowerCase(colname.charAt(0)) + colname.substring(1); org.aver.fft.annotations.Column annot = m .getAnnotation(org.aver.fft.annotations.Column.class); // String name, String type, boolean required, int // index, String format, boolean skip Column col = new Column(colname, m.getReturnType().getName(), annot.required(), annot.position(), annot.format(), annot.skip()); col.setStartColumn(annot.start()); col.setEndColumn(annot.end()); rec.addColumn(col); } } } } }
From source file:org.geoserver.opensearch.eo.store.JDBCOpenSearchAccess.java
private FeatureType buildProductFeatureType(DataStore delegate) throws IOException { SimpleFeatureType flatSchema = delegate.getSchema(PRODUCT); TypeBuilder typeBuilder = new TypeBuilder(CommonFactoryFinder.getFeatureTypeFactory(null)); // map the source attributes AttributeTypeBuilder ab = new AttributeTypeBuilder(); for (AttributeDescriptor ad : flatSchema.getAttributeDescriptors()) { String name = ad.getLocalName(); String namespaceURI = this.namespaceURI; // hack to avoid changing the whole product attributes prefixes from eo to eop if (name.startsWith(EO_PREFIX)) { name = "eop" + name.substring(2); }//from w w w . ja v a 2 s. c o m for (ProductClass pc : ProductClass.values()) { String prefix = pc.getPrefix(); if (name.startsWith(prefix)) { name = name.substring(prefix.length()); char c[] = name.toCharArray(); c[0] = Character.toLowerCase(c[0]); name = new String(c); namespaceURI = pc.getNamespace(); break; } } // get a more predictable name structure (will have to do something for oracle // like names too I guess) if (StringUtils.isAllUpperCase(name)) { name = name.toLowerCase(); } // map into output type ab.init(ad); ab.name(name).namespaceURI(namespaceURI).userData(SOURCE_ATTRIBUTE, ad.getLocalName()); AttributeDescriptor mappedDescriptor; if (ad instanceof GeometryDescriptor) { GeometryType at = ab.buildGeometryType(); ab.setCRS(((GeometryDescriptor) ad).getCoordinateReferenceSystem()); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } else { AttributeType at = ab.buildType(); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } typeBuilder.add(mappedDescriptor); } // adding the metadata property AttributeDescriptor metadataDescriptor = buildSimpleDescriptor(METADATA_PROPERTY_NAME, String.class); typeBuilder.add(metadataDescriptor); // adding the quicklook property AttributeDescriptor quicklookDescriptor = buildSimpleDescriptor(QUICKLOOK_PROPERTY_NAME, byte[].class); typeBuilder.add(quicklookDescriptor); // map OGC links AttributeDescriptor linksDescriptor = buildFeatureListDescriptor(OGC_LINKS_PROPERTY_NAME, delegate.getSchema("product_ogclink")); typeBuilder.add(linksDescriptor); typeBuilder.setName(PRODUCT); typeBuilder.setNamespaceURI(namespaceURI); return typeBuilder.feature(); }
From source file:com.tecapro.inventory.common.util.BeanUtil.java
/** * Create object Map of Object bean/*from w w w. j av a2 s .co m*/ * * @param name * @param target * @param bean * @param info * @throws InvocationTargetException * @throws IllegalAccessException */ @SuppressWarnings("unchecked") private void describe(String name, Map<String, Object> target, Object bean, boolean info) throws InvocationTargetException, IllegalAccessException { if (bean == null) { return; } Method[] methods = bean.getClass().getMethods(); Object[] param = new Object[] {}; for (int i = 0, j = methods.length; i < j; i++) { String methodName = methods[i].getName(); if (!methodName.startsWith("get")) { continue; } if (!info && methodName.equals("getInfo")) { continue; } if (methods[i].getParameterTypes().length != 0) { continue; } Object value = methods[i].invoke(bean, param); if (value == null || value == bean) { continue; } String propName = String.valueOf(Character.toLowerCase(methodName.charAt(3))); if (methodName.length() > 4) { propName += methodName.substring(4); } if (value instanceof List) { Iterator<Object> itr = (Iterator<Object>) ((List<Object>) value).iterator(); for (int k = 0; itr.hasNext(); k++) { describeObject(name, target, itr.next(), new StringBuffer().append(propName).append("[").append(k).append("]").toString(), info); } } else { describeObject(name, target, value, propName, info); } } }
From source file:com.opendoorlogistics.core.utils.strings.Strings.java
/** * Standardised version of a string value. * Calculation is optimised as much as possible. * @param s/*from w ww. j a va2 s. co m*/ * @return */ public static String std(String s) { if (s == null) { return ""; } int n = s.length(); StringBuilder b = new StringBuilder(n); // find first non-whitespace int firstNonWS = n; for (int i = 0; i < n; i++) { char c = s.charAt(i); if (!Character.isWhitespace(c)) { firstNonWS = i; break; } } // get last non-whitespace char int lastNonWS = -1; for (int i = n - 1; i >= 0; i--) { char c = s.charAt(i); if (!Character.isWhitespace(c)) { lastNonWS = i; break; } } boolean inWhiteSpace = false; char c; for (int i = firstNonWS; i <= lastNonWS; i++) { c = Character.toLowerCase(s.charAt(i)); if (inWhiteSpace) { if (Character.isWhitespace(c)) { // never add two whitespaces in a row } else { // no longer in whitespace inWhiteSpace = false; b.append(c); } } else { if (Character.isWhitespace(c)) { // always treat whitespace as a space b.append(' '); inWhiteSpace = true; } else { b.append(c); } } } return b.toString(); }
From source file:org.bonitasoft.web.designer.model.widget.Widget.java
public static String spinalCase(String widgetId) { char firstLetter = Character.toLowerCase(widgetId.charAt(0)); return firstLetter + widgetId.substring(1).replaceAll("([A-Z])", "-$1").toLowerCase(); }
From source file:CharArrayMap.java
private int getHashCode(char[] text, int len) { int code = 0; if (ignoreCase) { for (int i = 0; i < len; i++) { code = code * 31 + Character.toLowerCase(text[i]); }//from w w w. j ava 2s .co m } else { for (int i = 0; i < len; i++) { code = code * 31 + text[i]; } } return code; }
From source file:com.chiorichan.ConsoleColor.java
/** * Translates a string using an alternate color code character into a string that uses the internal * ConsoleColor.COLOR_CODE color code character. The alternate color code character will only be replaced if it is * immediately followed by 0-9, A-F, a-f, K-O, k-o, R or r. * /* www .j a v a 2 s . co m*/ * @param altColorChar * The alternate color code character to replace. Ex: & * @param textToTranslate * Text containing the alternate color code character. * @return Text containing the ChatColor.COLOR_CODE color code character. */ public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) { char[] b = textToTranslate.toCharArray(); for (int i = 0; i < b.length - 1; i++) { if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { b[i] = ConsoleColor.COLOR_CHAR; b[i + 1] = Character.toLowerCase(b[i + 1]); } } return new String(b); }
From source file:com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.java
private static void process(final ClassConfiguration classConfiguration, final String hostClassName, final String expectedBrowserName, final float browserVersionNumeric) { final String simpleClassName = hostClassName.substring(hostClassName.lastIndexOf('.') + 1); CLASS_NAME_MAP_.put(hostClassName, simpleClassName); final Map<String, Method> allGetters = new HashMap<>(); final Map<String, Method> allSetters = new HashMap<>(); for (final Constructor<?> constructor : classConfiguration.getHostClass().getDeclaredConstructors()) { for (final Annotation annotation : constructor.getAnnotations()) { if (annotation instanceof JsxConstructor) { if (isSupported(((JsxConstructor) annotation).value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.setJSConstructor(constructor); }/*ww w .j ava 2 s.c o m*/ } } } for (final Method method : classConfiguration.getHostClass().getDeclaredMethods()) { for (final Annotation annotation : method.getAnnotations()) { if (annotation instanceof JsxGetter) { final JsxGetter jsxGetter = (JsxGetter) annotation; if (isSupported(jsxGetter.value(), expectedBrowserName, browserVersionNumeric)) { String property; if (jsxGetter.propertyName().isEmpty()) { final int prefix = method.getName().startsWith("is") ? 2 : 3; property = method.getName().substring(prefix); property = Character.toLowerCase(property.charAt(0)) + property.substring(1); } else { property = jsxGetter.propertyName(); } allGetters.put(property, method); } } else if (annotation instanceof JsxSetter) { final JsxSetter jsxSetter = (JsxSetter) annotation; if (isSupported(jsxSetter.value(), expectedBrowserName, browserVersionNumeric)) { String property; if (jsxSetter.propertyName().isEmpty()) { property = method.getName().substring(3); property = Character.toLowerCase(property.charAt(0)) + property.substring(1); } else { property = jsxSetter.propertyName(); } allSetters.put(property, method); } } else if (annotation instanceof JsxFunction) { if (isSupported(((JsxFunction) annotation).value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.addFunction(method); } } else if (annotation instanceof JsxStaticGetter) { final JsxStaticGetter jsxStaticGetter = (JsxStaticGetter) annotation; if (isSupported(jsxStaticGetter.value(), expectedBrowserName, browserVersionNumeric)) { final int prefix = method.getName().startsWith("is") ? 2 : 3; String property = method.getName().substring(prefix); property = Character.toLowerCase(property.charAt(0)) + property.substring(1); classConfiguration.addStaticProperty(property, method, null); } } else if (annotation instanceof JsxStaticFunction) { if (isSupported(((JsxStaticFunction) annotation).value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.addStaticFunction(method); } } else if (annotation instanceof JsxConstructor) { if (isSupported(((JsxConstructor) annotation).value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.setJSConstructor(method); } } } } for (final Field field : classConfiguration.getHostClass().getDeclaredFields()) { final JsxConstant jsxConstant = field.getAnnotation(JsxConstant.class); if (jsxConstant != null && isSupported(jsxConstant.value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.addConstant(field.getName()); } } for (final Entry<String, Method> getterEntry : allGetters.entrySet()) { final String property = getterEntry.getKey(); classConfiguration.addProperty(property, getterEntry.getValue(), allSetters.get(property)); } }
From source file:com.duowan.common.spring.jdbc.BeanPropertyRowMapper.java
/** * Convert a name in camelCase to an underscored name in lower case. * Any upper case letters are converted to lower case with a preceding underscore. * @param name the string containing original name * @return the converted name//from w w w. j av a 2 s. com */ private String underscoreName(String name) { StringBuilder result = new StringBuilder(); if (name != null && name.length() > 0) { result.append(name.substring(0, 1).toLowerCase()); for (int i = 1; i < name.length(); i++) { char c = name.charAt(i); if (Character.isUpperCase(c) && !Character.isDigit(c)) { result.append("_"); result.append(Character.toLowerCase(c)); } else { result.append(c); } } } return result.toString(); }
From source file:io.stallion.reflection.PropertyUtils.java
public static List<String> getPropertyNames(Class clazz) throws PropertyException { Method[] methods = clazz.getMethods(); List<String> names = list(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; String name = method.getName(); if (method.getModifiers() == Modifier.PUBLIC && method.getParameterTypes().length == 0 && (name.startsWith("get") || name.startsWith("is")) && containsSetterForGetter(clazz, method)) { String propertyName;//from www.ja va2s . com if (name.startsWith("get")) propertyName = Character.toLowerCase(name.charAt(3)) + name.substring(4); else propertyName = Character.toLowerCase(name.charAt(2)) + name.substring(3); names.add(propertyName); } } return names; }