List of usage examples for org.apache.commons.lang StringUtils capitalize
public static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:io.github.redpanda4552.SimpleEgg.util.LoreExtractor.java
private void livingEntity(LivingEntity livingEntity) { livingEntity.setCustomName(attributeMap.get("Custom Name")); AttributeInstance attrInst;//from www . j av a 2 s. c o m for (Attribute attribute : Attribute.values()) { attrInst = livingEntity.getAttribute(attribute); if (attrInst != null) { String attrName = attribute.toString(); String[] components = attrName.split("_"); String label = ""; // Skip the first for (int i = 1; i < components.length; i++) { label += StringUtils.capitalize(components[i].toLowerCase()) + " "; } double value = Double.parseDouble(attributeMap.get(label.trim())); attrInst.setBaseValue(value); } } // Needs to happen after attributes, so health doesn't exceed the max livingEntity.setHealth(Double.parseDouble(attributeMap.get("Health"))); }
From source file:de.espend.idea.shopware.util.ShopwareUtil.java
public static String toCamelCase(String value, boolean startWithLowerCase) { String[] strings = StringUtils.split(value.toLowerCase(), "_"); for (int i = startWithLowerCase ? 1 : 0; i < strings.length; i++) { strings[i] = StringUtils.capitalize(strings[i]); }// w w w.j av a 2 s.c om return StringUtils.join(strings); }
From source file:com.simplexwork.mysql.tools.utils.DocumentUtils.java
/** * ?mybatis?mapper/*from ww w . j a v a 2s.com*/ * * @param tablesMap * @throws Exception */ public static void productMyBatisMapper(Map<String, TableInfo> tablesMap) throws Exception { VelocityContext context = new VelocityContext(); Template template1 = Velocity.getTemplate("mapper-java.vm"); // org/simplexwork/mysql/tools/velocity/mapper-java.vm Template template2 = Velocity.getTemplate("mapper-xml.vm"); for (Entry<String, TableInfo> entry : tablesMap.entrySet()) { TableInfo tableInfo = entry.getValue(); String tableName = getJavaBeanName(StringUtils.capitalize(tableInfo.getTableName())); String interfaceName = tableName + "Mapper"; context.put("interfaceName", interfaceName); context.put("beanName", tableName); context.put("resultMapId", getStartSmallName(tableName + "Map")); context.put("beanVarName", StringUtils.uncapitalize(tableName)); context.put("pkgMapper", pkgMapper); context.put("pkgBean", pkgBean); context.put("tableComment", tableInfo.getTableComment()); StringWriter writer1 = new StringWriter(); template1.merge(context, writer1); FileUtils.writeStringToFile(new File(generatedPath + "mapper/" + interfaceName + ".java"), writer1.toString(), "UTF-8"); 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("(")); } field.put("isKey", column.isKey()); field.put("sqlName", column.getName()); field.put("name", fixName(column.getName())); fileds.add(field); } context.put("tableName", tableInfo.getTableName()); context.put("keyInBean", keyInBean); context.put("keyInColoum", keyInColoum); context.put("fields", fileds); StringWriter writer2 = new StringWriter(); template2.merge(context, writer2); FileUtils.writeStringToFile(new File(generatedPath + getMapperXmlName(interfaceName) + ".xml"), writer2.toString(), "UTF-8"); } }
From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.EntityTypePropertyTypeBO.java
private EntityTypePE findEntityType(String entityTypeCode) { EntityTypePE entityType = getEntityTypeDAO(entityKind).tryToFindEntityTypeByCode(entityTypeCode); if (entityType == null) { throw new UserFailureException(String.format("%s type '%s' does not exist.", StringUtils.capitalize(entityKind.getLabel()), entityTypeCode)); }/* w ww. j av a2 s. c om*/ return entityType; }
From source file:edu.ku.brc.specify.utilapps.morphbank.BaseFileNameParser.java
@Override public Integer getRecordId(final String baseName) { Integer recId = null;/* ww w . j av a2 s. c o m*/ if (pStmt == null) { String whereStr = QueryAdjusterForDomain.getInstance().getSpecialColumns(this.tblInfo, false); String sql = String.format("SELECT %s FROM %s WHERE BINARY %s=? %s ", tblInfo.getIdColumnName(), tblInfo.getName(), StringUtils.capitalize(this.fieldName), whereStr != null ? (" AND " + whereStr) : ""); try { System.out.println(sql); pStmt = DBConnection.getInstance().getConnection().prepareStatement(sql); } catch (SQLException e) { e.printStackTrace(); return null; } } if (pStmt != null) { try { //String baseName = FilenameUtils.getBaseName(fileName); String fieldNameValue = fldInfo.getFormatter() == null ? baseName : getTrimmedFileName(baseName); pStmt.setString(1, fieldNameValue); ResultSet rs = pStmt.executeQuery(); if (rs.next()) { recId = rs.getInt(1); } rs.close(); } catch (SQLException e) { e.printStackTrace(); } } return recId; }
From source file:com.eviware.soapui.impl.GenericPanelBuilderTest.java
private boolean isEnum(String key) { try {//from w ww .ja va 2s. c o m Method getter = modelItem.getClass().getMethod("get" + StringUtils.capitalize(key)); boolean isEnum = getter.getReturnType().isEnum(); return isEnum; } catch (NoSuchMethodException e) { return false; } }
From source file:io.github.redpanda4552.SimpleEgg.util.LorePacker.java
private ArrayList<String> livingEntity(LivingEntity livingEntity) { ArrayList<String> ret = new ArrayList<String>(); if (livingEntity.getCustomName() != null) { ret.add("Custom Name: " + livingEntity.getCustomName()); }/*from ww w .j ava 2s .c o m*/ ret.add("Health: " + livingEntity.getHealth()); AttributeInstance attrInst; for (Attribute attribute : Attribute.values()) { attrInst = livingEntity.getAttribute(attribute); if (attrInst != null) { String attrName = attribute.toString(); String[] components = attrName.split("_"); String label = ""; // Skip the first for (int i = 1; i < components.length; i++) { label += StringUtils.capitalize(components[i].toLowerCase()) + " "; } ret.add(label.trim() + ": " + attrInst.getBaseValue()); } } return ret; }
From source file:com.frameworkset.orm.engine.model.JavaNameGenerator.java
/** * Converts a database schema name to java object name. Operates * same as underscoreMethod but does not convert anything to * lowercase.//from w w w.jav a 2s. com * * @param schemaName name to be converted. * @return converted name. * @see com.frameworkset.orm.engine.model.NameGenerator * @see #underscoreMethod(String) */ protected String javanameMethod(String schemaName, boolean IGNORE_FIRST_TOKEN) { StringBuffer name = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); boolean first = true; String firstNamepart = null; while (tok.hasMoreTokens()) { if (first && IGNORE_FIRST_TOKEN) { firstNamepart = (String) tok.nextElement(); first = false; continue; } String namePart = (String) tok.nextElement(); name.append(StringUtils.capitalize(namePart)); } // remove the SCHEMA_SEPARATOR_CHARs and capitalize // the tokens if (name.length() > 0) schemaName = name.toString(); else if (IGNORE_FIRST_TOKEN && firstNamepart != null) schemaName = firstNamepart; name = new StringBuffer(); tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); name.append(StringUtils.capitalize(namePart)); } return name.toString(); }
From source file:com.square.composant.prestations.square.server.service.PrestationServiceGwtImpl.java
@Override public List<LigneDecompteModel> recupererLignesPrestationsByNumeroDecompte(Long idAdherent, String numeroDecompte, String colonneTri, int triAsc) { final PrestationCriteresRechercheDto criterias = new PrestationCriteresRechercheDto(); criterias.setNumeroDecompteExact(numeroDecompte); criterias.setIdAssure(idAdherent);/*w w w. j a va 2 s .c o m*/ final RemotePagingCriteriasDto<PrestationCriteresRechercheDto> criteres = new RemotePagingCriteriasDto<PrestationCriteresRechercheDto>( criterias, 0, Integer.MAX_VALUE); final List<RemotePagingSort> listeSorts = new ArrayList<RemotePagingSort>(); listeSorts.add(new RemotePagingSort(colonneTri, triAsc)); // si on trie par date, on ajoute un tri sur la colonne if (colonneTri.equals(adherentMappingService.getOrderDecompteByDateSoin())) { listeSorts.add(new RemotePagingSort(adherentMappingService.getOrderDecompteByNumeroCouplage(), RemotePagingSort.REMOTE_PAGING_SORT_ASC)); } criteres.setListeSorts(listeSorts); final RemotePagingResultsDto<PrestationResultatRechercheDto> results = prestationService .rechercherPrestationParCritreres(criteres); final List<LigneDecompteModel> lignesDecomptes = new ArrayList<LigneDecompteModel>(); for (PrestationResultatRechercheDto ligne : results.getListResults()) { final LigneDecompteModel ligneModel = mapperDozerBean.map(ligne, LigneDecompteModel.class); ligneModel.setBeneficiaire(ligne.getNomBeneficiaire().toUpperCase() + " " + StringUtils.capitalize(ligne.getPrenomBeneficiaire())); ligneModel.setTauxRemboursementCompl( Integer.valueOf((int) Math.round(ligne.getRemboursementCompl() / ligne.getMontant() * 100))); ligneModel.setTauxRemboursementSecu( Integer.valueOf((int) Math.round(ligne.getRemboursementSecu() / ligne.getMontant() * 100))); lignesDecomptes.add(ligneModel); } return lignesDecomptes; }
From source file:gov.nih.nci.cabig.caaers.web.ae.ReporterTab.java
private InputField createContactField(String base, String contactType, boolean required) { return createContactField(base, contactType, StringUtils.capitalize(contactType), required); }