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:adalid.core.programmers.AbstractJavaProgrammer.java
@Override public String getJavaLowerClassName(String name) { return StringUtils.uncapitalize(StrUtils.getCamelCase(name, true)); }
From source file:com.smbtec.xo.orientdb.impl.OrientDbMetadataFactory.java
@Override public EdgeMetadata createRelationMetadata(final AnnotatedElement<?> annotatedElement, final Map<Class<?>, TypeMetadata> metadataByType) { Edge relationAnnotation;/*from ww w . j a v a2 s . co m*/ if (annotatedElement instanceof PropertyMethod) { relationAnnotation = ((PropertyMethod) annotatedElement).getAnnotationOfProperty(Edge.class); } else { relationAnnotation = annotatedElement.getAnnotation(Edge.class); } String name = null; if (relationAnnotation != null) { final String value = relationAnnotation.value(); if (!Edge.DEFAULT_VALUE.equals(value)) { name = value; } } if (name == null) { name = "_" + StringUtils.uncapitalize(annotatedElement.getName()); } return new EdgeMetadata(name); }
From source file:net.geoprism.ontology.Classifier.java
/** * MdMethod used for creating Classifiers. * //from w w w. j av a 2 s .c o m * @param termId * @param name * @return */ @Transaction public static TermAndRel create(Classifier dto, String parentId) { Classifier parent = Classifier.get(parentId); // If they didn't specify a package we can attempt to figure one out for them. if (dto.getClassifierPackage() == null || dto.getClassifierPackage().length() == 0) { String camelUniqueId = StringUtils.uncapitalize(parent.getClassifierId().trim().replaceAll("\\s+", "")); if (Classifier.getRoot().equals(parent)) { dto.setClassifierPackage(camelUniqueId); } else { dto.setClassifierPackage(parent.getClassifierPackage() + KEY_CONCATENATOR + camelUniqueId); } } dto.apply(); Relationship rel = dto.addLink(parent, ClassifierIsARelationship.CLASS); return new TermAndRel(dto, ClassifierIsARelationship.CLASS, rel.getId()); }
From source file:gr.abiss.calipso.tiers.processor.ModelDrivenBeansGenerator.java
protected void createController(BeanDefinitionRegistry registry, ModelContext modelContext) { if (modelContext.getControllerDefinition() == null) { String newBeanNameSuffix = "Controller"; String newBeanClassName = modelContext.getGeneratedClassNamePrefix() + newBeanNameSuffix; String newBeanRegistryName = StringUtils.uncapitalize(newBeanClassName); String newBeanPackage = this.controllerBasePackage + '.'; // grab the generic types List<Class<?>> genericTypes = modelContext.getGenericTypes(); genericTypes.add(modelContext.getServiceInterfaceType()); CreateClassCommand createControllerCmd = new CreateClassCommand(newBeanPackage + newBeanClassName, AbstractModelController.class); createControllerCmd.setGenericTypes(genericTypes); // add @Controller stereotype createControllerCmd.addTypeAnnotation(Controller.class, null); // set request mapping Map<String, Object> members = new HashMap<String, Object>(); String[] path = { "/api/rest" + modelContext.getPath() }; members.put("value", path); String[] produces = { "application/json", "application/xml" }; members.put("produces", produces); createControllerCmd.addTypeAnnotation(RequestMapping.class, members); // create and register controller class Class<?> controllerClass = JavassistUtil.createClass(createControllerCmd); // add service dependency String serviceDependency = StringUtils.uncapitalise(modelContext.getGeneratedClassNamePrefix()) + "Service"; AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(controllerClass) .addDependsOn(serviceDependency).setAutowireMode(Autowire.BY_TYPE.value()).getBeanDefinition(); registry.registerBeanDefinition(newBeanRegistryName, beanDefinition); }//w w w . j a v a2 s . com }
From source file:adalid.core.programmers.AbstractJavaProgrammer.java
@Override public String getJavaLowerVariableName(String name) { return StringUtils.uncapitalize(StrUtils.getCamelCase(name, true)); }
From source file:gr.abiss.calipso.tiers.processor.ModelDrivenBeanGeneratingRegistryPostProcessor.java
/** * Creates a controller for the given resource model. Consider the following * entity annotation:/*w w w. j a v a2 s . c o m*/ * * <pre> * {@code * @ModelResource(path = "countries", apiName = "Countries", apiDescription = "Operations about countries") one * } * </pre> * * created for the Country class: * * <pre> * { * @code * @Controller * @Api(tags = "Countries", description = "Operations about countries") * @RequestMapping(value = "/api/rest/countries", produces = { "application/json", * "application/xml" }, consumes = { "application/json", "application/xml" }) * public class CountryController extends AbstractModelController<Country, String, CountryService> { * private static final Logger LOGGER = LoggerFactory.getLogger(CountryController.class); * } * } * </pre> * * @param registry * @param modelContext */ protected void createController(BeanDefinitionRegistry registry, ModelContext modelContext) { if (modelContext.getControllerDefinition() == null) { String newBeanNameSuffix = "Controller"; String newBeanClassName = modelContext.getGeneratedClassNamePrefix() + newBeanNameSuffix; String newBeanRegistryName = StringUtils.uncapitalize(newBeanClassName); String newBeanPackage = modelContext.getBeansBasePackage() + ".controller"; // grab the generic types List<Class<?>> genericTypes = modelContext.getGenericTypes(); genericTypes.add(modelContext.getServiceInterfaceType()); CreateClassCommand createControllerCmd = new CreateClassCommand(newBeanPackage + newBeanClassName, modelContext.getControllerSuperClass()); createControllerCmd.setGenericTypes(genericTypes); LOGGER.info("Creating class " + newBeanClassName + ", super: " + modelContext.getControllerSuperClass().getName() + ", genericTypes: " + genericTypes); // add @Controller stereotype annotation Map<String, Object> controllerMembers = new HashMap<String, Object>(); controllerMembers.put("value", newBeanRegistryName); createControllerCmd.addTypeAnnotation(RestController.class, controllerMembers); // set swagger Api annotation Map<String, Object> apiMembers = modelContext.getApiAnnotationMembers(); if (MapUtils.isNotEmpty(apiMembers)) { createControllerCmd.addTypeAnnotation(Api.class, apiMembers); } // set request mapping annotation Map<String, Object> members = new HashMap<String, Object>(); String[] path = { "/api/rest" + modelContext.getPath() }; members.put("path", path); String[] types = { "application/json", "application/xml" }; members.put("produces", types); //members.put("consumes", types); createControllerCmd.addTypeAnnotation(RequestMapping.class, members); LOGGER.info("Adding request mapping " + members); // create and register controller class Class<?> controllerClass = JavassistUtil.createClass(createControllerCmd); // add service dependency String serviceDependency = StringUtils.uncapitalise(modelContext.getGeneratedClassNamePrefix()) + "Service"; AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(controllerClass) .addDependsOn(serviceDependency).setAutowireMode(Autowire.BY_NAME.value()).getBeanDefinition(); LOGGER.info("Registering bean " + newBeanRegistryName); registry.registerBeanDefinition(newBeanRegistryName, beanDefinition); } }
From source file:com.bstek.dorado.data.config.xml.DataParseContext.java
private String getFinalDataObjectName(String name, DataParseContext context) { if (name.charAt(0) == '#') { String resourceName = context.getResourceName(); if (StringUtils.isNotEmpty(resourceName)) { String prefix;//w w w . java 2s . c o m int i1 = resourceName.lastIndexOf('/'); int i2 = resourceName.lastIndexOf('.'); int i = (i1 > i2) ? i1 : i2; if (i > 0 && i < (resourceName.length() - 1)) { prefix = resourceName.substring(i + 1); } else { prefix = resourceName; } name = StringUtils.uncapitalize(prefix) + name; } } return name; }
From source file:com.google.gdt.eclipse.designer.gxt.databinding.wizards.autobindings.GxtDatabindingProvider.java
public String performSubstitutions(String code, ImportsManager imports) throws Exception { // bean class, field, name, field access String beanClassName = m_beanClass.getName().replace('$', '.'); String beanClassShortName = ClassUtils.getShortClassName(beanClassName); String fieldPrefix = JavaCore.getOption(JavaCore.CODEASSIST_FIELD_PREFIXES); String fieldName = fieldPrefix + StringUtils.uncapitalize(beanClassShortName); ////from ww w . j a v a2s .c o m Collection<String> importList = Sets.newHashSet(); // final List<PropertyAdapter> properties = Lists.newArrayList(); Display.getDefault().syncExec(new Runnable() { public void run() { m_packageName = m_firstPage.getPackageFragment().getElementName(); CollectionUtils.addAll(properties, m_propertiesViewer.getCheckedElements()); } }); // if (!ClassUtils.getPackageName(beanClassName).equals(m_packageName)) { importList.add(beanClassName); } beanClassName = beanClassShortName; // code = StringUtils.replace(code, "%BeanClass%", beanClassName); // if (ReflectionUtils.getConstructorBySignature(m_beanClass, "<init>()") == null) { code = StringUtils.replace(code, "%BeanField%", fieldName); } else { code = StringUtils.replace(code, "%BeanField%", fieldName + " = new " + beanClassName + "()"); } // IPreferenceStore preferences = ToolkitProvider.DESCRIPTION.getPreferences(); String accessPrefix = preferences.getBoolean(FieldUniqueVariableSupport.P_PREFIX_THIS) ? "this." : ""; String beanFieldAccess = accessPrefix + fieldName; // code = StringUtils.replace(code, "%BeanFieldAccess%", beanFieldAccess); code = StringUtils.replace(code, "%BeanName%", StringUtils.capitalize(beanClassShortName)); // boolean useGenerics = CoreUtils.useGenerics(m_javaProject); // StringBuffer fieldsCode = new StringBuffer(); StringBuffer widgetsCode = new StringBuffer(); StringBuffer bindingsCode = new StringBuffer(); // for (Iterator<PropertyAdapter> I = properties.iterator(); I.hasNext();) { PropertyAdapter property = I.next(); Object[] editorData = m_propertyToEditor.get(property); GxtWidgetDescriptor widgetDescriptor = (GxtWidgetDescriptor) editorData[0]; // String propertyName = property.getName(); String widgetClassName = ClassUtils.getShortClassName(widgetDescriptor.getWidgetClass()); String widgetFieldName = fieldPrefix + propertyName + widgetClassName; String widgetFieldAccess = accessPrefix + widgetFieldName; // if (useGenerics && widgetDescriptor.isGeneric()) { widgetClassName += "<" + convertTypes(property.getType().getName()) + ">"; } // fieldsCode.append("\r\nfield\r\n\tprivate " + widgetClassName + " " + widgetFieldName + ";"); // widgetsCode.append("\t\t" + widgetFieldName + " = new " + widgetClassName + "();\r\n"); widgetsCode.append("\t\t" + widgetFieldAccess + ".setFieldLabel(\"" + StringUtils.capitalize(propertyName) + "\");\r\n"); widgetsCode.append("\t\t" + accessPrefix + "m_formPanel.add(" + widgetFieldAccess + ", new FormData(\"100%\"));\r\n"); widgetsCode.append("\t\t//"); // importList.add(widgetDescriptor.getBindingClass()); bindingsCode.append("\t\tm_formBinding.addFieldBinding(new " + ClassUtils.getShortClassName(widgetDescriptor.getBindingClass()) + "(" + widgetFieldAccess + ",\"" + propertyName + "\"));\r\n"); // importList.add(widgetDescriptor.getWidgetClass()); // if (I.hasNext()) { fieldsCode.append("\r\n"); widgetsCode.append("\r\n"); } } // bindingsCode.append("\t\t//\r\n"); bindingsCode.append("\t\tm_formBinding.bind(" + beanFieldAccess + ");"); // replace template patterns code = StringUtils.replace(code, "%WidgetFields%", fieldsCode.toString()); code = StringUtils.replace(code, "%Widgets%", widgetsCode.toString()); code = StringUtils.replace(code, "%Bindings%", bindingsCode.toString()); // add imports for (String qualifiedTypeName : importList) { imports.addImport(qualifiedTypeName); } // return code; }
From source file:nc.noumea.mairie.organigramme.core.viewmodel.AbstractViewModel.java
/** * Retourne le service spring associe la classe de l'entit * /*from w ww . java 2 s.c om*/ * @return le service spring associe la classe de l'entit */ @SuppressWarnings("unchecked") public GenericService<T> getService() { return (GenericService<T>) ApplicationContextUtils.getApplicationContext() .getBean(StringUtils.uncapitalize(getEntityName()) + "Service"); }
From source file:com.fiveamsolutions.nci.commons.search.SearchCallback.java
@SuppressWarnings("PMD.SignatureDeclareThrowsException") public void callback(Method m, Object result, String objAlias) throws Exception { this.objectAlias = objAlias; String fieldName = StringUtils.uncapitalize(m.getName().substring("get".length())); String paramName = objectAlias + "_" + fieldName; if (result == null) { return;//from ww w .j a v a2 s . co m } SearchOptions searchOptions = new SearchOptions(m); validateSettings(searchOptions, result); if (result instanceof Collection<?>) { processCollectionField((Collection<?>) result, fieldName, this.objectAlias, searchOptions); } else if (!ArrayUtils.isEmpty(searchOptions.getFields())) { processFieldWithSubProp(result, fieldName, paramName, searchOptions, false); } else if (searchOptions.isNested()) { processNestedField(result, fieldName, paramName, searchOptions); } else { processSimpleField(result, fieldName, paramName, searchOptions); } }