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:mrcg.utils.Utils.java
public static String toSpacedCamelCase(String[] parts) { StringBuilder b = new StringBuilder(); for (String a : parts) { b.append(StringUtils.capitalize(a)).append(" "); }/* w w w. ja v a 2 s.c o m*/ return b.toString().trim(); }
From source file:graph.module.cli.ManualDisjointnessCommand.java
private int processDisjointPair(String conceptA, String conceptB, DirectedAcyclicGraph dag, int index, int total) throws Exception { NLPToStringModule nlpModule = (NLPToStringModule) dag.getModule(NLPToStringModule.class); DAGNode nodeA = (DAGNode) dag.findOrCreateNode(conceptA, null, false); DAGNode nodeB = (DAGNode) dag.findOrCreateNode(conceptB, null, false); BufferedReader in = getPortHandler().getReader(); QueryObject qo = new QueryObject(CommonConcepts.DISJOINTWITH.getNode(dag), nodeA, nodeB); print("(" + index + "/" + total + ") " + StringUtils.capitalize(nlpModule.edgeToString(qo, true, false, false)) + " " + qo.toString() + "\n(1:disjoint, 0:not disjoint, -1/EMPTY:unknown, Q:quit): "); flushOut();/*from ww w .j av a 2 s . c o m*/ String decision = in.readLine().trim(); if (decision.equalsIgnoreCase("Q")) return -13; else if (decision.equals("0")) return 0; else if (decision.equals("1")) return 1; else return -1; }
From source file:edu.usu.sdl.openstorefront.web.action.APIAction.java
@HandlesEvent("API") public Resolution apiDetails() { try {/*w w w . j av a 2s .c om*/ classPathDescription = StringUtils.capitalize(classPath); Class resource = Class .forName("edu.usu.sdl.openstorefront.web.rest." + classPath + "." + resourceClass); resourceModel = JaxrsProcessor.processRestClass(resource, RestConfiguration.APPLICATION_BASE_PATH); } catch (ClassNotFoundException ex) { return new ErrorResolution(404, "resource not found"); } return new ForwardResolution("/WEB-INF/securepages/api/apidetails.jsp"); }
From source file:com.anrisoftware.sscontrol.services.ServiceLoad.java
private Pattern filePattern(String name) { String fileName = StringUtils.capitalize(name); String regex = format(SERVICE_FILE_PATTERN, fileName); return compile(regex); }
From source file:edu.usu.sdl.openstorefront.validation.ValidationUtil.java
private static List<RuleResult> validateFields(final ValidationModel validateModel, Class dataClass, String parentFieldName, String parentType) { List<RuleResult> ruleResults = new ArrayList<>(); if (validateModel.getDataObject() == null && validateModel.isAcceptNull() == false) { RuleResult validationResult = new RuleResult(); validationResult.setMessage("The whole data object is null."); validationResult.setValidationRule("Don't allow null object"); validationResult.setEntityClassName(parentType); validationResult.setFieldName(parentFieldName); ruleResults.add(validationResult); } else {//ww w . ja va 2 s . c o m if (validateModel.getDataObject() != null) { if (dataClass.getSuperclass() != null) { ruleResults.addAll(validateFields(validateModel, dataClass.getSuperclass(), null, null)); } for (Field field : dataClass.getDeclaredFields()) { Class fieldClass = field.getType(); boolean process = true; if (validateModel.isConsumeFieldsOnly()) { ConsumeField consumeField = (ConsumeField) field.getAnnotation(ConsumeField.class); if (consumeField == null) { process = false; } } if (process) { if (ReflectionUtil.isComplexClass(fieldClass)) { //composition class if (Logger.class.getName().equals(fieldClass.getName()) == false && fieldClass.isEnum() == false) { try { Method method = validateModel.getDataObject().getClass().getMethod( "get" + StringUtils.capitalize(field.getName()), (Class<?>[]) null); Object returnObj = method.invoke(validateModel.getDataObject(), (Object[]) null); boolean check = true; if (returnObj == null) { NotNull notNull = (NotNull) fieldClass.getAnnotation(NotNull.class); if (notNull == null) { check = false; } } if (check) { ruleResults.addAll( validateFields(ValidationModel.copy(validateModel, returnObj), fieldClass, field.getName(), validateModel.getDataObject().getClass().getSimpleName())); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new OpenStorefrontRuntimeException(ex); } } } else if (fieldClass.getSimpleName().equalsIgnoreCase(List.class.getSimpleName()) || fieldClass.getSimpleName().equalsIgnoreCase(Map.class.getSimpleName()) || fieldClass.getSimpleName().equalsIgnoreCase(Collection.class.getSimpleName()) || fieldClass.getSimpleName().equalsIgnoreCase(Set.class.getSimpleName())) { //multi if (fieldClass.getSimpleName().equalsIgnoreCase(Map.class.getSimpleName())) { try { Method method = validateModel.getDataObject().getClass().getMethod( "get" + StringUtils.capitalize(field.getName()), (Class<?>[]) null); Object returnObj = method.invoke(validateModel.getDataObject(), (Object[]) null); Map mapObj = (Map) returnObj; for (Object entryObj : mapObj.entrySet()) { ruleResults.addAll( validateFields(ValidationModel.copy(validateModel, entryObj), entryObj.getClass(), field.getName(), validateModel.getDataObject().getClass().getSimpleName())); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new OpenStorefrontRuntimeException(ex); } } else { try { Method method = validateModel.getDataObject().getClass().getMethod( "get" + StringUtils.capitalize(field.getName()), (Class<?>[]) null); Object returnObj = method.invoke(validateModel.getDataObject(), (Object[]) null); if (returnObj != null) { for (Object itemObj : (Collection) returnObj) { if (itemObj != null) { ruleResults.addAll(validateFields( ValidationModel.copy(validateModel, itemObj), itemObj.getClass(), field.getName(), validateModel.getDataObject().getClass().getSimpleName())); } else { log.log(Level.WARNING, "There is a NULL item in a collection. Check data passed in to validation."); } } } else { NotNull notNull = field.getAnnotation(NotNull.class); if (notNull != null) { RuleResult ruleResult = new RuleResult(); ruleResult.setMessage("Collection is required"); ruleResult.setEntityClassName( validateModel.getDataObject().getClass().getSimpleName()); ruleResult.setFieldName(field.getName()); ruleResult.setValidationRule("Requires value"); ruleResults.add(ruleResult); } } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new OpenStorefrontRuntimeException(ex); } } } else { //simple case for (BaseRule rule : rules) { //Stanize if requested if (validateModel.getSantize()) { Sanitize santize = field.getAnnotation(Sanitize.class); if (santize != null) { try { Sanitizer santizer = santize.value().newInstance(); Method method = dataClass.getMethod( "get" + StringUtils.capitalize(field.getName()), (Class<?>[]) null); Object returnObj = method.invoke(validateModel.getDataObject(), (Object[]) null); Object newValue = santizer.santize(returnObj); method = dataClass.getMethod( "set" + StringUtils.capitalize(field.getName()), String.class); method.invoke(validateModel.getDataObject(), newValue); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | InvocationTargetException ex) { throw new OpenStorefrontRuntimeException(ex); } } } RuleResult validationResult = rule.processField(field, validateModel.getDataObject()); if (validationResult != null) { ruleResults.add(validationResult); } } } } } } } return ruleResults; }
From source file:net.rptools.gui.listeners.fxml.ScriptController.java
/** * This is a helper to improve readibility of scripts. It does not use * resources and is far from perfect./* w w w.j a v a 2 s . c o m*/ * @param id id of the script * @return improved readible name */ @ThreadPolicy(ThreadPolicy.ThreadId.ANY) private String heuristicName(final String id) { // For the time being this + strangeness is to avoid a wrong checkstyle warning :-) final String name = id.replaceAll("-", " ").replaceAll("\\.js$", "").replace("s" + "cript", ""); return StringUtils.capitalize(name.trim()); }
From source file:net.sf.eclipsefp.haskell.ui.internal.backend.InstallExecutableDialog.java
private String getExtraNames() { StringBuilder sb = new StringBuilder(); String sep = ""; for (InstallExecutableRunnable.Package p : getExtras()) { sb.append(sep);/*w w w . j a v a 2 s . c om*/ sep = ", "; sb.append(StringUtils.capitalize(p.getPkgName())); } return sb.toString(); }
From source file:io.github.moosbusch.lumpi.gui.form.spi.AbstractDynamicForm.java
protected final Form.Section createSection(Class<?> beanClass, PropertyDescriptor[] propDescs) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Form.Section result = new Form.Section(); String sectHeading = getSectionHeading(); Map<String, Class<?>> propertyMap = new HashMap<>(); propertyMap.setComparator(Comparator.naturalOrder()); if ((isShowSectionHeading()) && (StringUtils.isNotBlank(sectHeading))) { result.setHeading(sectHeading);// www.j a v a 2 s. c om } for (PropertyDescriptor propDesc : propDescs) { propertyMap.put(propDesc.getName(), propDesc.getPropertyType()); } for (String propertyName : propertyMap) { Class<?> propertyClass = ClassUtils.primitiveToWrapper(propertyMap.get(propertyName)); FormEditor<? extends Component> editor; if (!isExcludedProperty(beanClass, propertyName)) { editor = getEditor(beanClass.getName(), propertyClass.getName(), propertyName); if (editor != null) { Component cmp = editor.getComponent(); PropertyUtils.setProperty(cmp, editor.getDataBindingKeyPropertyName(), propertyName); setLabel(cmp, StringUtils.capitalize(propertyName)); if (editor.isScrollable()) { ScrollPane scroll = Objects.requireNonNull(createScrollPane()); scroll.setView(cmp); result.add(scroll); } else { result.add(cmp); } } } } return result; }
From source file:ch.cyberduck.core.AbstractProtocol.java
@Override public String getPrefix() { return String.format("%s.%s", this.getClass().getPackage().getName(), StringUtils.capitalize(this.getType().name())); }
From source file:com.evanzeimet.queryinfo.jpa.result.AbstractTupleToPojoQueryInfoResultConverter.java
protected MethodHandle findFieldSetterHandle(String memberName, Class<?> elementJavaType) { MethodHandle result = null;// w w w.j av a 2s .co m String methodSuffix = StringUtils.capitalize(memberName); String setterName = String.format("set%s", methodSuffix); MethodType methodType = methodType(void.class, elementJavaType); Class<QueryInfoResultType> resultClass = getResultClass(); try { result = MethodHandles.lookup().findVirtual(resultClass, setterName, methodType); } catch (NoSuchMethodException | IllegalAccessException e) { String message = String.format("Could not find field setter handle [%s] for field [%s]", setterName, memberName); logger.debug(message); } return result; }