List of usage examples for org.apache.commons.lang3 StringUtils capitalize
public static String capitalize(final String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:it.larusba.integration.neo4j.jsonloader.transformer.UnrefactoredDomainBasedJsonTransformer.java
/** * @param documentId//w w w . j av a 2s . com * @param documentType * @param documentMap * @param objectDescriptors * @return */ @SuppressWarnings("unchecked") private String transform(String documentId, String documentType, Map<String, Object> documentMap, JsonObjectDescriptorHelper objectDescriptorHelper, Integer position) { boolean firstAttr = true; boolean firstUniqueAttr = true; List<String> childNodes = new ArrayList<String>(); List<String> childRelationships = new ArrayList<String>(); StringBuffer rootNode = new StringBuffer(); String nodeLabel = buildNodeLabel(documentType, documentMap, objectDescriptorHelper); String nodeReference = buildNodeReference(position, nodeLabel); //TODO implement if (objectDescriptorHelper.hasUniqueKeyAttributes(nodeLabel)) { } else { } rootNode.append("MERGE (").append(nodeReference).append(":").append(nodeLabel); StringBuffer nodeAttributes = new StringBuffer(); for (String attributeName : documentMap.keySet()) { Object attributeValue = documentMap.get(attributeName); if (attributeValue instanceof Map) { childNodes.add(transform(documentId, StringUtils.capitalize(attributeName), (Map<String, Object>) attributeValue, objectDescriptorHelper, null)); childRelationships .add(new StringBuffer().append("CREATE (").append(nodeReference).append(")-[").append(":") .append(nodeReference.toUpperCase()).append("_").append(attributeName.toUpperCase()) .append("]->(").append(attributeName).append(")").toString()); } else if (attributeValue instanceof List) { List<Object> attributeValueList = (List<Object>) attributeValue; if (attributeValueList.size() > 0) { if (attributeValueList.get(0) instanceof Map) { for (int i = 0; i < attributeValueList.size(); i++) { Object attributeValueElement = attributeValueList.get(i); if (attributeValueElement instanceof Map) { childNodes.add(transform(documentId, StringUtils.capitalize(attributeName), (Map<String, Object>) attributeValueElement, objectDescriptorHelper, i)); childRelationships.add(new StringBuffer().append("MERGE (").append(nodeReference) .append(")-[").append(":").append(nodeReference.toUpperCase()).append("_") .append(attributeName.toUpperCase()).append("]->(") .append(attributeName + i).append(")").toString()); } } } else { if (firstAttr) { nodeAttributes.append("ON CREATE SET "); if (documentId != null) { nodeAttributes.append(nodeReference).append(".").append("_documentId = '") .append(documentId).append("', "); } firstAttr = false; } else { nodeAttributes.append(", "); } nodeAttributes.append(nodeReference).append(".").append(attributeName).append(" = ["); for (int i = 0; i < attributeValueList.size(); i++) { Object attributeValueElement = attributeValueList.get(i); if (attributeValueElement != null) { if (i != 0) nodeAttributes.append(", "); if (attributeValueElement instanceof String) { nodeAttributes.append("'").append(attributeValueElement).append("'"); } else { nodeAttributes.append(attributeValueElement); } } } nodeAttributes.append("]"); } } } else { if (objectDescriptorHelper.isAttributeInUniqueKey(nodeLabel, attributeName)) { if (firstUniqueAttr) { rootNode.append(" { "); firstUniqueAttr = false; } else { rootNode.append(", "); } rootNode.append(attributeName).append(": "); if (attributeValue instanceof String) { rootNode.append("'").append(attributeValue).append("'"); } else { rootNode.append(attributeValue); } } else { if (attributeValue != null) { if (firstAttr) { nodeAttributes.append("ON CREATE SET "); if (documentId != null) { nodeAttributes.append(nodeReference).append(".").append("_documentId = '") .append(documentId).append("', "); } firstAttr = false; } else { nodeAttributes.append(", "); } nodeAttributes.append(nodeReference).append(".").append(attributeName).append(" = "); if (attributeValue instanceof String) { nodeAttributes.append("'").append(attributeValue).append("'"); } else { nodeAttributes.append(attributeValue); } } } } } if (firstAttr == firstUniqueAttr) { rootNode.append("}"); } rootNode.append(")").append(System.lineSeparator()).append(nodeAttributes); StringBuffer cypher = new StringBuffer(); cypher.append(rootNode); for (String childNode : childNodes) { cypher.append(System.lineSeparator()).append(childNode); } for (String childRelationship : childRelationships) { cypher.append(System.lineSeparator()).append(childRelationship); } return cypher.toString(); }
From source file:kenh.xscript.Environment.java
/** * Initials an element through element package and element name. * @param elementPackage/* w w w . ja v a 2 s. co m*/ * @param elementName * @return */ private Element getElement_(String elementPackage, String elementName) { if (StringUtils.isBlank(elementPackage)) return null; if (StringUtils.isBlank(elementName)) return null; try { if (StringUtils.isNotBlank(elementPackage)) { Element element = (Element) Class .forName(elementPackage + "." + StringUtils.capitalize(elementName)).newInstance(); return element; } } catch (Exception e) { } return null; }
From source file:fr.evercraft.essentials.command.EESpawnMob.java
private boolean commandSpawnMob(final EPlayer player, EntityTemplate format, int amount, Vector3d location) { for (int cpt = 0; cpt < amount; cpt++) { Entity entity = player.getWorld().createEntityNaturally(format.getType(), location); format.apply(entity, player.get()); player.getWorld().spawnEntity(entity, Cause.source(this.plugin).owner(player.get()).notifier(player.get()).build()); }/*from www.j av a2s . c om*/ EEMessages.SPAWNMOB_MOB.sender().replace("<amount>", String.valueOf(amount)) .replace("<entity>", StringUtils.capitalize(format.getName())).sendTo(player); return true; }
From source file:at.beris.jarcommander.helper.ModelViewController.java
public Method getPropertySetter(Object object, String propertyName, Class valueType) { try {//from www .j av a 2s .co m return object.getClass().getDeclaredMethod("set" + StringUtils.capitalize(propertyName), valueType); } catch (NoSuchMethodException e) { logException(e); } return null; }
From source file:gov.nih.nci.caintegrator.web.ajax.GenomicDataSourceAjaxUpdater.java
/** * Updates studyConfiguration status./*from w ww. j a v a 2s . co m*/ * @param username to update the status to. * @param genomicSource to update. * @param checkDeployButton determines whether to update the deploy button or not. */ public void updateJobStatus(String username, GenomicDataSourceConfiguration genomicSource, boolean checkDeployButton) { Util utilThis = getDwrUtil(username); String genomicSourceId = genomicSource.getId().toString(); utilThis.setValue(JOB_HOST_NAME + genomicSourceId, genomicSource.getServerProfile().getHostname()); utilThis.setValue(JOB_EXPERIMENT_IDENTIFIER + genomicSourceId, genomicSource.getExperimentIdentifier()); updateRowFileDescriptions(utilThis, genomicSource, genomicSourceId); utilThis.setValue(JOB_DATA_TYPE + genomicSourceId, genomicSource.getDataType().getValue()); utilThis.setValue(JOB_DEPLOYMENT_STATUS + genomicSourceId, getStatusMessage(genomicSource.getStatus())); utilThis.setValue(JOB_LAST_MODIFIED_DATE + genomicSourceId, genomicSource.getDisplayableLastModifiedDate()); utilThis.setValue(JOB_NEW_DATA_AVAILABLE + genomicSourceId, StringUtils.capitalize(BooleanUtils.toStringYesNo(genomicSource.isDataRefreshed()))); updateRowActions(genomicSource, utilThis, genomicSourceId); }
From source file:gov.nih.nci.caintegrator.web.ajax.StudyDeploymentAjaxUpdater.java
/** * Updates studyConfiguration status./*from ww w . j av a 2s. c o m*/ * @param username to update the status to. * @param studyConfiguration to update. */ public void updateJobStatus(String username, StudyConfiguration studyConfiguration) { Util utilThis = getDwrUtil(username); String studyConfigurationId = studyConfiguration.getId().toString(); String descriptionDivId = JOB_STUDY_DESCRIPTION + "div_" + studyConfigurationId; utilThis.setValue(JOB_STUDY_NAME + studyConfigurationId, studyConfiguration.getStudy().getShortTitleText()); utilThis.setValue(JOB_STUDY_DESCRIPTION + studyConfigurationId, "<s:div id=\"" + descriptionDivId + "\">" + studyConfiguration.getStudy().getLongTitleText() + "</s:div>"); utilThis.setValue(JOB_LAST_MODIFIED_BY + studyConfigurationId, studyConfiguration.getLastModifiedBy().getUsername()); utilThis.setValue(JOB_STUDY_STATUS + studyConfigurationId, getStatusMessage(studyConfiguration.getStatus())); utilThis.setValue(JOB_START_DATE + studyConfigurationId, getDateString(studyConfiguration.getDeploymentStartDate())); utilThis.setValue(JOB_FINISH_DATE + studyConfigurationId, getDateString(studyConfiguration.getDeploymentFinishDate())); utilThis.setValue(JOB_NEW_DATA_AVAILABLE + studyConfigurationId, StringUtils.capitalize(BooleanUtils.toStringYesNo(studyConfiguration.isDataRefreshed()))); updateRowActions(studyConfiguration, utilThis, studyConfigurationId); utilThis.addFunctionCall("truncateDescriptionDiv", descriptionDivId); }
From source file:com.moto.miletus.application.tabs.ComponentsAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { final ComponentWrapper componentWrapper = mDataSet.get(position); holder.componentName.setText(StringUtils.capitalize(componentWrapper.getTraitName().replace("_", ""))); String value1 = ""; String value2 = ""; int count = 0; for (StateWrapper stateWrapper : componentWrapper.getStates()) { String stateValue = stateWrapper.getValue().getValue(); String stateName = stateWrapper.getStateName(); try {//from w ww. j a va 2 s.c o m if (StringUtils.containsIgnoreCase(stateName, Strings.TEMPERATURE)) { stateValue = Precision.round(Float.parseFloat(stateValue), 1) + ""; stateValue = stateValue + Strings.CELSIUS; } else if (StringUtils.containsIgnoreCase(stateName, Strings.LIGHT)) { stateValue = stateValue + Strings.LUX; } else if (StringUtils.containsIgnoreCase(stateName, Strings.HUMIDITY)) { stateValue = Math.round(Precision.round(Float.parseFloat(stateValue), 0)) + ""; stateValue = stateValue + "%"; } } catch (NumberFormatException nfe) { Log.e(TAG, stateName + ": " + Strings.NEW_LINE + stateValue); } if (count == 0) { value1 = value1 + stateName + ": " + stateValue; } else { value2 = value2 + stateName + ": " + stateValue + Strings.NEW_LINE; } count++; } value1 = value1.replace("_", ""); value2 = value2.replace("_", ""); holder.stateValue1.setText(value1); holder.stateValue2.setText(value2); if (value2.isEmpty()) { holder.arrow.setVisibility(View.GONE); holder.showMore.setVisibility(View.GONE); } else { holder.arrow.setVisibility(View.VISIBLE); holder.showMore.setVisibility(View.VISIBLE); } }
From source file:com.google.code.siren4j.util.ReflectionUtils.java
/** * Retrieve the setter for the specified class/field if it exists. * * @param clazz// w w w .ja v a 2 s .c om * @param f * @return */ public static Method getSetter(Class<?> clazz, Field f) { Method setter = null; for (Method m : clazz.getMethods()) { if (ReflectionUtils.isSetter(m) && m.getName().equals(SETTER_PREFIX + StringUtils.capitalize(f.getName()))) { setter = m; break; } } return setter; }
From source file:com.paladin.mvc.ActionServlet.java
/** * Action//w ww. j ava 2 s .c om * * @param _actionName * @return */ private Object loadAction(final String _actionName) { try { Object action = actions.get(_actionName); if (action == null) for (String pkg : actionPackages) {// package,?Action String cls = pkg + '.' + StringUtils.capitalize(_actionName/* ? */) + "Action"; action = loadActionOfFullname(_actionName, cls); if (action != null) break; } return action; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:ch.cyberduck.ui.cocoa.controller.ProgressController.java
@Override public void transferDidStop(final Transfer transfer) { invoke(new DefaultMainAction() { @Override/*from ww w . j a v a2s .c o m*/ public void run() { progressBar.stopAnimation(null); progressBar.setIndeterminate(true); progressBar.setHidden(true); setMessage(StringUtils.EMPTY); setProgress(MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"), sizeFormatter.format(transfer.getTransferred()), sizeFormatter.format(transfer.getSize()))); setStatus( LocaleFactory .localizedString( LocaleFactory .localizedString( transfer.isComplete() ? String.format("%s complete", StringUtils.capitalize( transfer.getType().name())) : "Transfer incomplete", "Status"), "Status")); statusIconView.setImage(transfer.isComplete() ? GREEN_ICON : RED_ICON); } }); }