List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:org.diorite.config.impl.actions.AbstractPropertyAction.java
@Override public ActionMatcherResult matchesAction(Method method) { MethodInvoker methodInvoker = new MethodInvoker(method); if (methodInvoker.isStatic() || methodInvoker.isNative()) { return FAIL; }//from w w w .j a v a2 s .com for (Pattern pattern : this.patterns) { Matcher matcher = pattern.matcher(method.getName()); if (matcher.matches() && (matcher.groupCount() > 0)) { String property = matcher.group("property"); if ((property == null) || property.isEmpty()) { return FAIL; } char firstChar = property.charAt(0); if (Character.isUpperCase(firstChar)) { property = Character.toLowerCase(firstChar) + property.substring(1); } return new ActionMatcherResult( this.matchesAction0(methodInvoker, methodInvoker.getParameterTypes()), property); } } return FAIL; }
From source file:org.eclipse.wb.internal.rcp.model.rcp.ActionFactoryCreationSupport.java
/** * @param name/*w w w . jav a 2s . c o m*/ * then name of field from {@link ActionFactory}. * * @return the {@link ActionInfo} for {@link IWorkbenchAction} from {@link ActionFactory}. */ public static ActionInfo createNew(JavaInfo root, String name) throws Exception { // prepare new Action_Info ActionInfo action; { AstEditor editor = root.getEditor(); action = (ActionInfo) JavaInfoUtils.createJavaInfo(editor, "org.eclipse.jface.action.IAction", new ActionFactoryCreationSupport(name)); } // set default variable name { StringBuffer newName = new StringBuffer(name.length() + 16); boolean hasUnderscore = false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c == '_') { hasUnderscore = true; continue; } else { if (hasUnderscore) { c = Character.toUpperCase(c); hasUnderscore = false; } else { c = Character.toLowerCase(c); } newName.append(c); } } newName.append("Action"); // do set default variable name JavaInfoUtils.setParameter(action, NamesManager.NAME_PARAMETER, newName.toString()); } // OK, we have Action_Info return action; }
From source file:com.adaptris.core.marshaller.xstream.XStreamUtils.java
/** * Converts a camelcase name into a lowercase hyphen separated format for output to XML. Used by the marshalling process to * convert a java class/field name into an xml element name. * * @param fieldName - Current element name to be processed. * @return translated name// ww w . ja v a 2 s.co m */ public static String toXmlElementName(String fieldName) { if (fieldName == null) { return null; } if (fieldName.length() == 0) { return fieldName; } if (fieldName.length() == 1) { return fieldName.toLowerCase(); } // -- Follow the Java beans Introspector::decapitalize // -- convention by leaving alone String that start with // -- 2 uppercase characters. if (Character.isUpperCase(fieldName.charAt(0)) && Character.isUpperCase(fieldName.charAt(1))) { return fieldName; } // -- process each character StringBuilder cbuff = new StringBuilder(fieldName); cbuff.setCharAt(0, Character.toLowerCase(cbuff.charAt(0))); boolean ucPrev = false; for (int i = 1; i < cbuff.length(); i++) { char ch = cbuff.charAt(i); if (Character.isUpperCase(ch)) { if (ucPrev) { continue; } ucPrev = true; cbuff.insert(i, '-'); ++i; cbuff.setCharAt(i, Character.toLowerCase(ch)); } else { ucPrev = false; } } return cbuff.toString(); }
From source file:org.apache.activemq.artemis.utils.uri.FluentPropertyBeanIntrospectorWithIgnores.java
private String propertyName(Method m) { String methodName = m.getName().substring(getWriteMethodPrefix().length()); return (methodName.length() > 1) ? Character.toLowerCase(methodName.charAt(0)) + methodName.substring(1) : methodName.toLowerCase(Locale.ENGLISH); }
From source file:com.google.publicalerts.cap.CapUtil.java
static String toCase(String s, boolean camel) { String[] parts = s.split("_"); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { String part = parts[i];/* w w w . j ava 2 s . com*/ if (part.length() > 0) { sb.append(part.substring(0, 1).toUpperCase()).append(part.substring(1).toLowerCase()); } } if (!camel && sb.length() > 0) { sb.replace(0, 1, String.valueOf(Character.toLowerCase(sb.charAt(0)))); } return sb.toString(); }
From source file:org.eclipse.ecr.core.storage.sql.jdbc.JDBCBackend.java
@Override public void initialize(RepositoryImpl repository) throws StorageException { this.repository = repository; RepositoryDescriptor repositoryDescriptor = repository.getRepositoryDescriptor(); // instantiate the datasource String className = repositoryDescriptor.xaDataSourceName; Class<?> klass;//from w ww . ja va2 s . com try { klass = Class.forName(className); } catch (ClassNotFoundException e) { throw new StorageException("Unknown class: " + className, e); } Object instance; try { instance = klass.newInstance(); } catch (Exception e) { throw new StorageException("Cannot instantiate class: " + className, e); } if (!(instance instanceof XADataSource)) { throw new StorageException("Not a XADataSource: " + className); } xadatasource = (XADataSource) instance; // set JavaBean properties on the datasource for (Entry<String, String> entry : repositoryDescriptor.properties.entrySet()) { String name = entry.getKey(); Object value = Framework.expandVars(entry.getValue()); if (name.contains("/")) { // old syntax where non-String types were explicited name = name.substring(0, name.indexOf('/')); } // transform to proper JavaBean convention if (Character.isLowerCase(name.charAt(1))) { name = Character.toLowerCase(name.charAt(0)) + name.substring(1); } try { BeanUtils.setProperty(xadatasource, name, value); } catch (Exception e) { log.error(String.format("Cannot set %s = %s", name, value)); } } }
From source file:com.thoughtworks.twist.migration.brt.BRTMigrator.java
private String camelCase(String text) { String[] splits = text.split(" "); StringBuilder sb = new StringBuilder(); char[] chars = splits[0].toCharArray(); chars[0] = Character.toLowerCase(chars[0]); sb.append(String.valueOf(chars)); for (int i = 1; i < splits.length; i++) sb.append(WordUtils.capitalize(splits[i])); return sb.toString(); }
From source file:bboss.org.apache.velocity.runtime.parser.node.PropertyExecutor.java
/** * @param clazz//from ww w. ja v a 2 s .c om * @param property */ protected void discover(final Class clazz, final String property) { /* * this is gross and linear, but it keeps it straightforward. */ try { Object[] params = {}; StringBuffer sb = new StringBuffer("get"); 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 getter for '" + property; log.error(msg, e); throw new VelocityException(msg, e); } }
From source file:edu.rit.flick.genetics.FastaFileInflator.java
@Override protected void writeNucleotide(final byte base) { byte nucleotide = (byte) (inTandemRepeat ? Character.toLowerCase(base) : base); nucleotide = isRNAData() && nucleotide == t ? u : nucleotide; super.writeNucleotide(nucleotide); }
From source file:org.brushingbits.jnap.persistence.factory.DaoFactoryPostProcessor.java
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { Assert.isAssignable(DefaultListableBeanFactory.class, registry.getClass(), "The DaoFactoryPostProcessor only works within a DefaultListableBeanFactory capable" + "BeanFactory, your BeanDefinitionRegistry is " + registry.getClass()); final DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) registry; // get already defined beans of type Dao final Set<Class<? extends PersistentModel>> alreadyDefinedDaos = new HashSet<Class<? extends PersistentModel>>(); for (String beanName : beanFactory.getBeanNamesForType(Dao.class, true, false)) { Dao<? extends PersistentModel> dao = beanFactory.getBean(beanName, Dao.class); alreadyDefinedDaos.add(dao.getEntityClass()); }// ww w. java 2 s.co m for (String sessionFactoryName : beanFactory.getBeanNamesForType(SessionFactory.class)) { final SessionFactory sessionFactory = beanFactory.getBean(sessionFactoryName, SessionFactory.class); Map<String, ClassMetadata> entitiesMetadata = sessionFactory.getAllClassMetadata(); for (ClassMetadata entityMetadata : entitiesMetadata.values()) { Class<? extends PersistentModel> entityClass = entityMetadata.getMappedClass(EntityMode.POJO); if (entityClass != null && !alreadyDefinedDaos.contains(entityClass)) { String daoName = entityClass.getSimpleName() + "Dao"; daoName = Character.toLowerCase(daoName.charAt(0)) + daoName.substring(1); beanFactory.registerBeanDefinition(daoName, createDaoDefinition(entityClass, sessionFactory)); } } } }