List of usage examples for org.apache.commons.lang StringUtils uncapitalize
public static String uncapitalize(String str)
Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .
From source file:com.evolveum.midpoint.prism.schema.PrismSchemaImpl.java
/** * Internal method to create a "nice" element name from the type name. */// w ww.j a v a 2 s . c om private String toElementName(String localTypeName) { String elementName = StringUtils.uncapitalize(localTypeName); if (elementName.endsWith("Type")) { return elementName.substring(0, elementName.length() - 4); } return elementName; }
From source file:com.simplexwork.mysql.tools.utils.DocumentUtils.java
/** * ?ServiceServiceIml//from w ww. java2s . c om * * @param tablesMap * @throws Exception */ public static void productService(Map<String, TableInfo> tablesMap) throws Exception { VelocityContext context = new VelocityContext(); Template templateService = Velocity.getTemplate("java-service.vm"); Template template2 = Velocity.getTemplate("java-service-impl.vm"); for (Entry<String, TableInfo> entry : tablesMap.entrySet()) { TableInfo tableInfo = entry.getValue(); String tableName = getJavaBeanName(StringUtils.capitalize(tableInfo.getTableName())); String serviceName = tableName + "Service"; context.put("serviceName", serviceName); context.put("beanName", tableName); context.put("beanNameTuoFeng", getStartSmallName(tableName)); context.put("mapperTuoFeng", getStartSmallName(tableName) + "Mapper"); context.put("beanVarName", StringUtils.uncapitalize(tableName)); context.put("pkgMapper", pkgMapper); context.put("pkgBean", pkgBean); context.put("pkgService", pkgService); context.put("pkgServiceImpl", pkgServiceImpl); context.put("tableComment", tableInfo.getTableComment()); String keyInBean = ""; // Bean???? String keyInColoum = ""; // ?? List<Object> fileds = new ArrayList<>(); for (Column column : tableInfo.getColumns()) { if (column.isKey()) { keyInBean = fixName(column.getName()); keyInColoum = column.getName(); } Map<String, Object> field = new HashMap<>(); String columnType = column.getType(); if (columnType.contains("(")) { columnType = columnType.substring(0, columnType.indexOf("(")); } String name = fixName(column.getName()); field.put("isKey", column.isKey()); field.put("sqlName", column.getName()); field.put("name", name); field.put("nameStartBig", getStartBigName(name)); field.put("comment", column.getComment()); field.put("isNullable", column.isNullable()); fileds.add(field); } context.put("tableName", tableInfo.getTableName()); context.put("keyInBean", keyInBean); context.put("keyInColoum", keyInColoum); context.put("fields", fileds); StringWriter writerService = new StringWriter(); templateService.merge(context, writerService); FileUtils.writeStringToFile(new File(generatedPath + "service/" + serviceName + ".java"), writerService.toString(), "UTF-8"); StringWriter writer2 = new StringWriter(); template2.merge(context, writer2); FileUtils.writeStringToFile(new File(generatedPath + "serviceImpl/" + serviceName + "Impl.java"), writer2.toString(), "UTF-8"); } }
From source file:com.haulmont.cuba.core.sys.MetaModelLoader.java
protected void initProperties(Class<?> clazz, MetaClassImpl metaClass, Collection<RangeInitTask> tasks) { if (!metaClass.getOwnProperties().isEmpty()) return;//from ww w . j a v a 2s .c o m // load collection properties after non-collection in order to have all inverse properties loaded up ArrayList<Field> collectionProps = new ArrayList<>(); for (Field field : clazz.getDeclaredFields()) { if (field.isSynthetic()) continue; final String fieldName = field.getName(); if (isMetaPropertyField(field)) { MetaPropertyImpl property = (MetaPropertyImpl) metaClass.getProperty(fieldName); if (property == null) { MetadataObjectInfo<MetaProperty> info; if (isCollection(field) || isMap(field)) { collectionProps.add(field); } else { info = loadProperty(metaClass, field); tasks.addAll(info.getTasks()); MetaProperty metaProperty = info.getObject(); onPropertyLoaded(metaProperty, field); } } else { log.warn("Field " + clazz.getSimpleName() + "." + field.getName() + " is not included in metadata because property " + property + " already exists"); } } } for (Field f : collectionProps) { MetadataObjectInfo<MetaProperty> info = loadCollectionProperty(metaClass, f); tasks.addAll(info.getTasks()); MetaProperty metaProperty = info.getObject(); onPropertyLoaded(metaProperty, f); } for (Method method : clazz.getDeclaredMethods()) { if (method.isSynthetic()) continue; String methodName = method.getName(); if (!methodName.startsWith("get") || method.getReturnType() == void.class) continue; if (isMetaPropertyMethod(method)) { String name = StringUtils.uncapitalize(methodName.substring(3)); MetaPropertyImpl property = (MetaPropertyImpl) metaClass.getProperty(name); if (property == null) { MetadataObjectInfo<MetaProperty> info; if (isCollection(method) || isMap(method)) { throw new UnsupportedOperationException( String.format("Method-based property %s.%s doesn't support collections and maps", clazz.getSimpleName(), method.getName())); } else if (method.getParameterCount() != 0) { throw new UnsupportedOperationException( String.format("Method-based property %s.%s doesn't support arguments", clazz.getSimpleName(), method.getName())); } else { info = loadProperty(metaClass, method, name); tasks.addAll(info.getTasks()); } MetaProperty metaProperty = info.getObject(); onPropertyLoaded(metaProperty, method); } else { log.warn("Method " + clazz.getSimpleName() + "." + method.getName() + " is not included in metadata because property " + property + " already exists"); } } } }
From source file:com.microsoft.office.plugin.AbstractUtility.java
public String uncapitalize(final String str) { return StringUtils.uncapitalize(str); }
From source file:com.haulmont.cuba.core.global.View.java
protected List<String> getInterfaceProperties(Class<?> intf) { List<String> result = new ArrayList<>(); for (Method method : intf.getDeclaredMethods()) { if (method.getName().startsWith("get") && method.getParameterTypes().length == 0) { result.add(StringUtils.uncapitalize(method.getName().substring(3))); }/*from ww w. java 2 s .c o m*/ } return result; }
From source file:gr.abiss.calipso.tiers.processor.ModelDrivenBeansGenerator.java
protected void createRepository(BeanDefinitionRegistry registry, ModelContext modelContext) throws NotFoundException, CannotCompileException { if (modelContext.getRepositoryDefinition() == null) { Class<?> repoSUperInterface = ModelRepository.class; String newBeanPackage = this.repositoryBasePackage + '.'; // grab the generic types List<Class<?>> genericTypes = modelContext.getGenericTypes(); // create the new interface Class<?> newRepoInterface = JavassistUtil.createInterface( newBeanPackage + modelContext.getGeneratedClassNamePrefix() + "Repository", repoSUperInterface, genericTypes);//from w w w . j ava2 s . c o m // register using the uncapitalised className as the key AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(ModelRepositoryFactoryBean.class) .addPropertyValue("repositoryInterface", newRepoInterface).getBeanDefinition(); registry.registerBeanDefinition(StringUtils.uncapitalize(newRepoInterface.getSimpleName()), def); // note the repo in context modelContext.setRepositoryDefinition(def); modelContext.setRepositoryType(newRepoInterface); } else { // mote the repository interface as a possible dependency to a service Class<?> beanClass = ClassUtils.getClass(modelContext.getRepositoryDefinition().getBeanClassName()); // get the actual interface in case of a factory if (ModelRepositoryFactoryBean.class.isAssignableFrom(beanClass)) { for (PropertyValue propertyValue : modelContext.getRepositoryDefinition().getPropertyValues() .getPropertyValueList()) { if (propertyValue.getName().equals("repositoryInterface")) { Object obj = propertyValue.getValue(); modelContext.setRepositoryType( String.class.isAssignableFrom(obj.getClass()) ? ClassUtils.getClass(obj.toString()) : (Class<?>) obj); } } } Assert.notNull(modelContext.getRepositoryType(), "Found a repository (factory) bean definition for " + modelContext.getGeneratedClassNamePrefix() + " but was unable to figure out the repository type."); } }
From source file:mrcg.MRCGInstance.java
private void createEditJSPs() throws Exception { for (JavaClass jclass : types.values()) { if (!(jclass.isEnum() || jclass.isMapping() || skipGui(jclass))) { Map<String, Object> map = new HashMap<String, Object>(); map.put("basePackage", basePackage); map.put("classUpper", StringUtils.capitalize(jclass.getName())); map.put("classUpperSpaced", Utils.toSpacedCamelCase(StringUtils.capitalize(jclass.getName()))); map.put("classLower", jclass.getName().toLowerCase()); map.put("classLowerCamel", StringUtils.uncapitalize(jclass.getName())); map.put("fields", jclass.getNonAutoHandledInstanceFields()); // map.put("mappings", convertToJspEditCode(jclass)); map.put("tagLibPrefix", tagLibPrefix); File file = new File(webPath + "admin/" + jclass.getName().toLowerCase() + "/edit.jsp"); velocity(file, getResourcePath("edit-jsp.vel"), map, false); file = new File(webPath + "admin/" + jclass.getName().toLowerCase() + "/edit-layout.jsp"); velocity(file, getResourcePath("edit-layout-jsp.vel"), map, true); }/*w w w.jav a 2 s . com*/ } }
From source file:gr.abiss.calipso.tiers.processor.ModelDrivenBeanGeneratingRegistryPostProcessor.java
protected void createRepository(BeanDefinitionRegistry registry, ModelContext modelContext) throws NotFoundException, CannotCompileException { if (modelContext.getRepositoryDefinition() == null) { Class<?> repoSUperInterface = ModelRepository.class; String newBeanPackage = modelContext.getBeansBasePackage() + ".repository"; // grab the generic types List<Class<?>> genericTypes = modelContext.getGenericTypes(); // create the new interface Class<?> newRepoInterface = JavassistUtil.createInterface( newBeanPackage + modelContext.getGeneratedClassNamePrefix() + "Repository", repoSUperInterface, genericTypes);/*from w w w. jav a2 s . c o m*/ // register using the uncapitalised className as the key AbstractBeanDefinition def = BeanDefinitionBuilder.rootBeanDefinition(ModelRepositoryFactoryBean.class) .addPropertyValue("repositoryInterface", newRepoInterface).getBeanDefinition(); registry.registerBeanDefinition(StringUtils.uncapitalize(newRepoInterface.getSimpleName()), def); // note the repo in context modelContext.setRepositoryDefinition(def); modelContext.setRepositoryType(newRepoInterface); } else { // mote the repository interface as a possible dependency to a // service Class<?> beanClass = ClassUtils.getClass(modelContext.getRepositoryDefinition().getBeanClassName()); // get the actual interface in case of a factory if (ModelRepositoryFactoryBean.class.isAssignableFrom(beanClass)) { for (PropertyValue propertyValue : modelContext.getRepositoryDefinition().getPropertyValues() .getPropertyValueList()) { if (propertyValue.getName().equals("repositoryInterface")) { Object obj = propertyValue.getValue(); modelContext.setRepositoryType( String.class.isAssignableFrom(obj.getClass()) ? ClassUtils.getClass(obj.toString()) : (Class<?>) obj); } } } Assert.notNull(modelContext.getRepositoryType(), "Found a repository (factory) bean definition for " + modelContext.getGeneratedClassNamePrefix() + " but was unable to figure out the repository type."); } }
From source file:com.ubikproducts.maven.plugins.argo2modello.ModelReader.java
private void parseAssociations(ModelClass modelClass, Object umlClass) throws IOException { // add attributes implementing associations Collection ends = facade.getAssociationEnds(umlClass); if (!ends.isEmpty()) { for (Object associationEnd : ends) { Object association = facade.getAssociation(associationEnd); Object otherAssociationEnd = facade.getNextEnd(associationEnd); String otherEndName = facade.getName(associationEnd); String otherTypeName = facade.getName(facade.getType(associationEnd)); String endName = facade.getName(otherAssociationEnd); String typeName = facade.getName(facade.getType(otherAssociationEnd)); if (!facade.isNavigable(otherAssociationEnd)) continue; // TODO: Check strange code if ("".equals(endName) || endName == null) { endName = StringUtils.uncapitalize(typeName); }//w w w . j a va 2s.co m ModelAssociation modelAssociation = new ModelAssociation(); //addTaggedValues(otherAssociationEnd, elemField); parseBaseElement(modelAssociation, otherAssociationEnd); modelAssociation.setName(endName); modelAssociation.setType(typeName); String multiplicity = facade.getName(facade.getMultiplicity(otherAssociationEnd)); if (multiplicity.indexOf("*") > -1) { //addElement(assoc, "multiplicity", "*"); modelAssociation.setMultiplicity("*"/*multiplicity*/); } else { //addElement(assoc, "multiplicity", "1"); modelAssociation.setMultiplicity("1"/*multiplicity*/); } // move the annotations to the association /* * if ( elemField.getChild( "annotations" ) != null ) { Element * annotations = (Element) elemField.getChild( "annotations" * ).clone(); assoc.addContent( annotations ); * elemField.removeChild( "annotations" ); } */ } } else { log.info("No association ends for '" + facade.getName(umlClass) + "'"); } }
From source file:adalid.commons.velocity.Writer.java
public Writer(Object subject, String subjectKey) { this.subject = subject == null ? this : subject; this.subjectKey = StringUtils.isBlank(subjectKey) ? StringUtils.uncapitalize(this.subject.getClass().getSimpleName()) : subjectKey.trim();//from w w w. j a v a2s .c om logger.info(this.subjectKey + "=" + this.subject.getClass().getName() + "(" + this.subject + ")"); // velocityPropertiesFile = PropertiesHandler.getVelocityPropertiesFile(); // velocityExtendedProperties = PropertiesHandler.getExtendedProperties(velocityPropertiesFile); // velocityFileResourceLoaderPathArray = velocityExtendedProperties.getStringArray(FILE_RESOURCE_LOADER_PATH); }