List of usage examples for org.apache.commons.lang3 StringUtils uncapitalize
public static String uncapitalize(final String str)
Uncapitalizes a String, changing the first letter to lower case as per Character#toLowerCase(char) .
From source file:org.gvnix.web.exception.handler.roo.addon.addon.WebExceptionHandlerOperationsImpl.java
/** * Updates the selected language file with the title and the description of * the new Exception./*from w ww . j av a 2 s .c o m*/ * * @param exceptionName Name of the Exception. * @param exceptionTitle Title of the Exception. * @param exceptionDescription Description of the Exception. */ private void createMultiLanguageMessages(String exceptionName, String exceptionTitle, String exceptionDescription, String propertyFileName) { String exceptionNameUncapitalize = StringUtils.uncapitalize(exceptionName); SortedSet<FileDetails> propertiesFiles = getPropertiesFiles(); Map<String, String> params = new HashMap<String, String>(10); // Parameters params.put(ERROR + exceptionNameUncapitalize + TITLE, exceptionTitle); params.put(ERROR + exceptionNameUncapitalize + PROBLEM_DESCRIPTION, exceptionDescription); String propertyFilePath = "/WEB-INF/i18n/"; String canonicalPath; String fileName; String tmpProperty; for (Entry<String, String> entry : params.entrySet()) { for (FileDetails fileDetails : propertiesFiles) { canonicalPath = fileDetails.getCanonicalPath(); fileName = propertyFilePath.concat(getFilename(canonicalPath)); if (propertyFileName.compareTo(fileName.substring(1)) == 0) { tmpProperty = propFileOperations.getProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), fileName, entry.getKey()); if (tmpProperty == null) { propFileOperations.changeProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), propertyFileName, entry.getKey(), entry.getValue()); } else if (tmpProperty.compareTo(entry.getValue()) != 0) { propFileOperations.changeProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), propertyFileName, entry.getKey(), entry.getValue()); } } else { // Updates the file if the property doesn't exists. if (propFileOperations.getProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), fileName, entry.getKey()) == null) { propFileOperations.changeProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), fileName, entry.getKey(), entry.getKey()); } } } } }
From source file:org.gvnix.web.exception.handler.roo.addon.addon.WebExceptionHandlerOperationsImpl.java
/** * Updates the selected language file with the title and the description of * the new Exception./*from w ww . j a v a 2s. c o m*/ * * @param exceptionName Name of the Exception. * @param exceptionTitle Title of the Exception. * @param exceptionDescription Description of the Exception. */ private void updateMultiLanguageMessages(String exceptionName, String exceptionTitle, String exceptionDescription, String propertyFileName) { String exceptionNameUncapitalize = StringUtils.uncapitalize(exceptionName); Map<String, String> params = new HashMap<String, String>(10); // Parameters params.put(ERROR + exceptionNameUncapitalize + TITLE, exceptionTitle); params.put(ERROR + exceptionNameUncapitalize + PROBLEM_DESCRIPTION, exceptionDescription); for (Entry<String, String> entry : params.entrySet()) { String tmpProperty = propFileOperations.getProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), propertyFileName, entry.getKey()); if (tmpProperty == null) { propFileOperations.changeProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), propertyFileName, entry.getKey(), entry.getValue()); } else if (tmpProperty.compareTo(entry.getValue()) != 0) { propFileOperations.changeProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), propertyFileName, entry.getKey(), entry.getValue()); } } }
From source file:org.gvnix.web.exception.handler.roo.addon.addon.WebExceptionHandlerOperationsImpl.java
/** * Removes the Language messages properties of the Exception. * // w ww . j a v a 2s. c o m * @param exceptionName Exception Name to remove. */ private void removeMultiLanguageMessages(String exceptionName) { String exceptionNameUncapitalize = StringUtils.uncapitalize(exceptionName); SortedSet<FileDetails> propertiesFiles = getPropertiesFiles(); Map<String, String> params = new HashMap<String, String>(10); // Parameters params.put(ERROR + exceptionNameUncapitalize + TITLE, ""); params.put(ERROR + exceptionNameUncapitalize + PROBLEM_DESCRIPTION, ""); String propertyFilePath = "/WEB-INF/i18n/"; String fileName; String canonicalPath; for (Entry<String, String> entry : params.entrySet()) { for (FileDetails fileDetails : propertiesFiles) { canonicalPath = fileDetails.getCanonicalPath(); fileName = propertyFilePath.concat(getFilename(canonicalPath)); propFileOperations.removeProperty(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), fileName, entry.getKey()); } } }
From source file:org.gvnix.web.exception.handler.roo.addon.addon.WebExceptionHandlerOperationsImplTest.java
/** * Checks method//from w ww . j a va 2 s.c om * {@link WebExceptionHandlerOperationsImpl#updateWebMvcConfig()} * * @throws Exception */ @Test public void testUpdateWebMvcConfig() throws Exception { String result; String expected; String exceptionName; String exceptionJspxPath; /* * Test 1 - Aade una excepcin al archivo de configuracin WEB_XML_PATH * * exceptionName - java.lang.Exception */ exceptionName = "java.lang.Exception"; expected = "Exception"; exceptionJspxPath = EXC_JSPX_PATH.concat(StringUtils.uncapitalize(expected)).concat(".jspx"); expect(pathResolver.getIdentifier(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), WEB_XML_PATH)) .andReturn(EXC_WEB_XML); expect(fileManager.exists(EXC_WEB_XML)).andReturn(true); expect(fileManager.updateFile(EXC_WEB_XML)).andReturn(webXmlMutableFile); expect(webXmlMutableFile.getInputStream()).andReturn(getClass().getResourceAsStream(EXC_WEB_XML)); // Search for an existing Exception jspx mapping expect(pathResolver.getIdentifier(LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), "WEB-INF/views/" + StringUtils.uncapitalize(expected) + ".jspx")).andReturn(exceptionJspxPath); expect(fileManager.exists(exceptionJspxPath)).andReturn(false); // Output Stream expect(webXmlMutableFile.getOutputStream()) .andReturn(new FileOutputStream("/tmp/exceptions-webmvc-config.xml")); replay(pathResolver, fileManager, webXmlMutableFile); result = webExceptionHandlerOperationsImpl.updateWebMvcConfig(exceptionName); assertEquals("Test 1 \nThere isn't new exception defined in " + EXC_WEB_XML + " file", StringUtils.uncapitalize(expected), result); logger.log(Level.INFO, "Test 1 \nNew Exception view: '" + result + "' defined in: " + EXC_WEB_XML); reset(pathResolver, fileManager, webXmlMutableFile); }
From source file:org.hibernate.ejb.metamodel.EntityTypeImpl.java
public String getName() { return StringUtils.uncapitalize(jpaEntityName); }
From source file:org.icatproject.idav.IcatMapper.java
private String createWhere(List<IcatEntity> hierarchy, HashMap<String, String> icatEntityValues, int currentPosition, boolean child) { LOG.info("Creating the WHERE part of the query"); String where = " WHERE "; IcatEntity parentEntity = hierarchy.get(currentPosition - 1); IcatEntity childEntity = hierarchy.get(currentPosition); String childName = childEntity.getEntity(); String parentName = parentEntity.getEntity(); LOG.info("Child name = " + childName); LOG.info("Parent name = " + parentName); if (!child) { LOG.info("Not a child!"); String childWhereValue = ""; String childValue = icatEntityValues.get(childEntity.getEntity()); // Handle the possible combined columns if (childName.equals("Investigation")) { // If combined columns split the name and visit id if (childValue.contains(childEntity.getColumnCombineValue())) { String[] investigationValues = childValue.split(childEntity.getColumnCombineValue()); childWhereValue = " investigation.name='" + investigationValues[0].trim() + "' AND investigation.visitId='" + investigationValues[1].trim() + "'"; }//from w w w.j av a2 s . c om } else if (childName.equals("Dataset")) { if (parentName.equals("Investigation")) { String parentValue = icatEntityValues.get(parentName); // If combined columns split the name and visit id if (parentValue.contains(parentEntity.getColumnCombineValue())) { String[] investigationValues = parentValue.split(parentEntity.getColumnCombineValue()); childWhereValue = " investigation.name='" + investigationValues[0].trim() + "' AND investigation.visitId='" + investigationValues[1].trim() + "' AND "; } } childWhereValue += StringUtils.uncapitalize(childEntity.getEntity()) + "." + childEntity.getAttribute() + "='" + childValue + "'"; } else if (childName.equals("Instrument")) { // TODO - KP 22/12/16 - why is fullName specified here when we have specified // Instrument should use the attribute 'name' in the idav.structure file? childWhereValue = " instrument.fullName='" + childValue + "'"; } else { childWhereValue = StringUtils.uncapitalize(childEntity.getEntity()) + "." + childEntity.getAttribute() + "='" + childValue + "'"; } where += childWhereValue; } // If parent is FacilityCycle want to do between startDate and endDate of child entity. else if (parentEntity.getEntity().equals("FacilityCycle")) { IcatEntity grandParentEntity = hierarchy.get(currentPosition - 2); String parentWhereValue = StringUtils.uncapitalize(grandParentEntity.getEntity()) + "." + grandParentEntity.getAttribute() + "='" + icatEntityValues.get(grandParentEntity.getEntity()) + "' AND facilityCycle.name='" + icatEntityValues.get(parentEntity.getEntity()) + "' AND investigationInstrument.name= instrument.name AND " + StringUtils.uncapitalize(childEntity.getEntity()) + ".startDate BETWEEN facilityCycle.startDate AND facilityCycle.endDate "; where += parentWhereValue; } else { String parentWhereValue = ""; String parentValue = icatEntityValues.get(parentEntity.getEntity()); if (parentEntity.getEntity().equals("Investigation") && !parentEntity.getColumnCombineValue().equals("")) { String[] investigationValues = parentValue.split(parentEntity.getColumnCombineValue()); parentWhereValue = " investigation.name='" + investigationValues[0].trim() + "' AND investigation.visitId='" + investigationValues[1].trim() + "'"; } else if (childName.equals("Datafile")) { // Get all of the values needed String investigation = icatEntityValues.get("Investigation"); String[] investigationAndVisit = IcatStore .getInvestigationAndVisit(Utils.escapeStringForIcatQuery(investigation)); investigation = investigationAndVisit[0]; String visitId = investigationAndVisit[1]; String dataset = icatEntityValues.get("Dataset"); String facility = icatEntityValues.get("Facility"); parentWhereValue = " dataset.name='" + dataset + "' AND investigation.name='" + investigation + "' AND investigation.visitId='" + visitId + "' AND facility.name='" + facility + "'"; } else { parentWhereValue = StringUtils.uncapitalize(parentEntity.getEntity()) + "." + parentEntity.getAttribute() + "='" + parentValue + "'"; } where += parentWhereValue; } LOG.info("WHERE = [" + where + "]"); return where; }
From source file:org.icatproject.idav.IcatMapper.java
public String createQuery(List<IcatEntity> hierarchy, HashMap<String, String> icatEntityValues, int currentPosition, boolean child, String userId) { // If we are in the MyData folder, we need to call the other mapper class to deal with the specific // queries that we need to do in this folder. if (icatEntityValues.get("Facility") != null && icatEntityValues.get("Facility").equals("My Data")) { LOG.info("Calling MyDataMapper to create the query"); MyDataMapper mapper = new MyDataMapper(); return mapper.createQuery(hierarchy, icatEntityValues, currentPosition, child, userId); }/* w w w . ja va 2s .com*/ LOG.debug("Creating SELECT part of query"); LOG.info("Current position = " + currentPosition); IcatEntity entity = hierarchy.get(currentPosition); LOG.info("Entity = " + entity.getEntity()); LOG.info("Boolean child = " + child); String finalQuery = ""; String select = "SELECT "; String entityName = entity.getEntity(); // Child is if we need to get all children else we only need the specific entity. if (child) { // If combined columns required to hold uniqueness then need to combine visitId and Name if (entityName.equals("Investigation") && !entity.getColumnCombineValue().equals("")) { select = "SELECT investigation FROM Investigation investigation "; } else if (entityName.equals("Instrument")) { // TODO - KP 22/12/16 - why is fullName specified here when we have specified // Instrument should use the attribute 'name' in the idav.structure file? select = "SELECT instrument.fullName FROM Instrument instrument"; } else if (entityName.equals("Datafile")) { select = "SELECT datafile.name FROM Datafile datafile"; } else { select += StringUtils.uncapitalize(entityName) + "." + entity.getAttribute() + " FROM " + entity.getEntity() + " " + StringUtils.uncapitalize(entityName); } } else { select += StringUtils.uncapitalize(entityName) + " FROM " + entity.getEntity() + " " + StringUtils.uncapitalize(entityName); } finalQuery += select; LOG.info("SELECT = [" + select + "]"); // Only do Join and where if past root. if (currentPosition > 0) { // Only need a join if getting all the children or a Dataset or Datafile. if (child || entityName.equals("Dataset") || entityName.equals("Datafile")) { finalQuery += createJoin(hierarchy, currentPosition, child); } finalQuery += createWhere(hierarchy, icatEntityValues, currentPosition, child); } LOG.info("Full query: " + finalQuery); return finalQuery; }
From source file:org.jboss.forge.roaster.model.impl.AbstractJavaSourceMemberHolder.java
private String extractPropertyName(Method<O, ?> method) { if (GET_SET_PATTERN.matcher(method.getName()).matches()) { return StringUtils.uncapitalize(method.getName().substring(3)); }//w ww . j a va 2 s . c o m return null; }
From source file:org.jrb.commons.web.controller.AbstractController.java
protected String entityRel(Class<?> classname) { return StringUtils.uncapitalize(English.plural(classname.getSimpleName())); }
From source file:org.jrb.commons.web.controller.CrudControllerUtils.java
/** * Calculates an entity link relation from a given class name. This relation * is built from the camel case of the plural of the class name. * /*from w w w . ja va 2s .co m*/ * @param classname * the entity class name * @return the link relation */ protected String entityRel(final Class<?> classname) { return StringUtils.uncapitalize(English.plural(classname.getSimpleName())); }