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:io.cloudslang.lang.compiler.validator.PreCompileValidatorImpl.java
@Override public void validateStringValue(String name, Serializable value, InOutTransformer transformer) { String prefix = StringUtils.capitalize(getMessagePart(transformer.getTransformedObjectsClass())) + ": '" + name;/*from w w w . j a v a2 s . co m*/ validateStringValue(prefix, value); }
From source file:com.google.testing.pogen.generator.test.java.TestCodeGenerator.java
/** * Appends a getter method for the attribute of html tag which contains the variable specified by * the name into the given string builder. * //from w w w . j av a2s . co m * @param methodBuilder {@link StringBuilder} the generated method will be appended to * @param variableName the variable name * @param attributeName the name of the attribute which contains template variables * @param assignedAttributeValue the attribute value assigned to the html tag * @param isRepeated the boolean whether the specified html tag appears in a repeated part */ private void appendAttributeGetter(StringBuilder methodBuilder, String variableName, String attributeName, String assignedAttributeValue, boolean isRepeated) { if (!isRepeated) { appendGetter(methodBuilder, variableName, ".getAttribute(\"" + attributeName + "\")", "String", "AttributeOf" + StringUtils.capitalize(attributeName) + "On"); } else { appendListGetter(methodBuilder, variableName, ".getAttribute(\"" + attributeName + "\")", "String", "AttributesOf" + StringUtils.capitalize(attributeName) + "On", assignedAttributeValue); } }
From source file:com.aol.one.patch.DefaultPatcher.java
private void invokeReplaceMethod(Object object, String fieldName, JsonNode valueNode) throws IllegalAccessException, InvocationTargetException, PatchException { if (object instanceof Patchable) { Patchable patchable = (Patchable) object; patchable.replaceValue(fieldName, valueNode); return;/*from w w w .ja v a2 s .c om*/ } boolean isFieldNameNumeric = StringUtils.isNumeric(fieldName); if (isFieldNameNumeric && object instanceof java.util.List) { List tmpList = (List) object; // WARN: inserting JsonNode into list // NOTE: not add, but set. tmpList.set(Integer.parseInt(fieldName), valueNode); return; } if (isFieldNameNumeric && object instanceof java.util.Map) { Map tmpMap = (Map) object; // WARN: removing string key from Map, key type of Map not known. tmpMap.remove(fieldName); // WARN: adding JsonNode into Map tmpMap.put(fieldName, valueNode); return; } // first try to find replace+CapitalizedField List<String> methodNames = new ArrayList<>(); methodNames.add("replace" + StringUtils.capitalize(fieldName)); // next, set + capitalizedField methodNames.add("set" + StringUtils.capitalize(fieldName)); List<MethodData> methodDataList = generateMethodData(methodNames, valueNode); // final try, standard method List<Class<?>> argTypes = new ArrayList<>(); argTypes.add(String.class); argTypes.add(JsonNode.class); List<Object> params = new ArrayList<>(); params.add(fieldName); params.add(valueNode); MethodData standardMethodData = new MethodData(STANDARD_REPLACE_METHOD, argTypes, params); methodDataList.add(standardMethodData); invokeMethodFromMethodDataList(object, methodDataList); }
From source file:com.systematic.healthcare.fhir.generator.Generator.java
private void addField(JavaClassSource javaClass, Map<String, ResourceParser.FieldInfo> fieldInfo, ElementDefinitionDt element, String elementName) { if (!element.getSlicing().getDiscriminator().isEmpty()) { sliced.add(element.getPath());//w w w. ja v a 2s . c om slicedPathToEnumType.put(element.getPath(), element.getShort()); lastSlicedValue = new CompositeValue(element.getPath(), element.getSlicing().getDescription()); slicePathToValues.put(element.getPath(), lastSlicedValue); } else { // The ElementDefinition is part of the last slice. if (lastSlicedValue != null && element.getPath().startsWith(lastSlicedValue.path)) { if (element.getPath().equals(lastSlicedValue.path)) { // This defines the name of slice. lastSlicedValueField = new CompositeValueField(element.getName()); lastSlicedValue.fields.add(lastSlicedValueField); } else if (element.getPath().equals(lastSlicedValue.path + ".code.coding.system")) { lastSlicedValueField.url = ((UriDt) element.getFixed()).getValue(); } else if (element.getPath().equals(lastSlicedValue.path + ".code.coding.code")) { lastSlicedValueField.fixedCode = String.valueOf(element.getFixed()); } else if (element.getPath().equals(lastSlicedValue.path + ".value[x]")) { lastSlicedValueField.type = String.valueOf(element.getFixed()); } return; } else if (elementName.indexOf('.') != -1) { //Dont know why we need theese sub elements. (.code and .code.system etc..) return; } } ResourceParser.FieldInfo inheritedField = fieldInfo.get(elementName.toLowerCase()); FieldSource<JavaClassSource> field = javaClass.addField() .setName("my" + StringUtils.capitalize(elementName)).setPrivate(); existingFieldsChanged.add(field); if (Collection.class.isAssignableFrom(inheritedField.getType())) { List<Class<?>> cl = FluentIterable.from(element.getType()) .transform(new TypeClassFunction(inheritedField)).toList(); if (cl.size() == 0) { setFieldTypeGeneric(javaClass, inheritedField, field); } else { String args = Joiner.on(',') .join(FluentIterable.from(cl).transform(new ClassToSimpleNameFunction())); field.setType(inheritedField.getType().getCanonicalName() + "<" + args + ">"); } } else { if (element.getBinding() != null && isBindingStrengthNotExample(element.getBinding()) && element.getBinding().getValueSet() instanceof ResourceReferenceDt) { ResourceReferenceDt ref = (ResourceReferenceDt) element.getBinding().getValueSet(); if (ref.getReference().getValue().startsWith(HL7_FHIR_REFERENCE_URL_START)) { if (BoundCodeableConceptDt.class.isAssignableFrom(inheritedField.getType())) { setFieldTypeGeneric(javaClass, inheritedField, field); } else if (BoundCodeDt.class.isAssignableFrom(inheritedField.getType())) { setFieldTypeGeneric(javaClass, inheritedField, field); } else { field.setType(inheritedField.getType()); } } else { field.setType(inheritedField.getType()); } } else { field.setType(inheritedField.getType()); } } List<Class<?>> fieldType = FluentIterable.from(element.getType()) .transform(new TypeClassFunction(inheritedField)).toList(); AnnotationSource<JavaClassSource> childAnnotation = addFieldChildAnnotation(element, elementName, field, false); childAnnotation.setClassArrayValue("type", fieldType.toArray(new Class[fieldType.size()])); addFieldDescriptionAnnotation(element, field); }
From source file:com.github.lucapino.sheetmaker.parsers.mediainfo.MovieInfoImpl.java
String localizeLanguage(String language) {
Locale langlocale = Locale.forLanguageTag(language);
return StringUtils.capitalize(langlocale.getDisplayLanguage(langlocale));
}
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement.java
/** * Returns the pathname portion of the link's URL. * @return the pathname portion of the link's URL * @throws Exception if an error occurs/*from w ww . ja v a 2 s . c o m*/ * @see <a href="http://msdn.microsoft.com/en-us/library/ms534332.aspx">MSDN Documentation</a> */ @JsxGetter public String getPathname() throws Exception { try { final URL url = getUrl(); if (!url.getProtocol().startsWith("http") && getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_NONE_FOR_NONE_HTTP_URL)) { return ""; } if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); String href = anchor.getHrefAttribute(); if (href.length() > 1 && Character.isLetter(href.charAt(0)) && ':' == href.charAt(1)) { if (getBrowserVersion().hasFeature(JS_ANCHOR_PROTOCOL_COLON_UPPER_CASE_DRIVE_LETTERS)) { href = StringUtils.capitalize(href); } if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL)) { href = "/" + href; } return href; } } return url.getPath(); } catch (final MalformedURLException e) { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); if (anchor.getHrefAttribute().startsWith("http") && getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL)) { return ""; } return "/"; } }
From source file:android.databinding.tool.reflection.ModelClass.java
/** * Returns the getter method or field that the name refers to. * @param name The name of the field or the body of the method name -- can be name(), * getName(), or isName()./*from w ww . j a va2 s . c om*/ * @param staticOnly Whether this should look for static methods and fields or instance * versions * @return the getter method or field that the name refers to or null if none can be found. */ public Callable findGetterOrField(String name, boolean staticOnly) { if ("length".equals(name) && isArray()) { return new Callable(Type.FIELD, name, ModelAnalyzer.getInstance().loadPrimitive("int"), 0); } String capitalized = StringUtils.capitalize(name); String[] methodNames = { "get" + capitalized, "is" + capitalized, name }; for (String methodName : methodNames) { ModelMethod[] methods = getMethods(methodName, new ArrayList<ModelClass>(), staticOnly); for (ModelMethod method : methods) { if (method.isPublic() && (!staticOnly || method.isStatic()) && !method.getReturnType(Arrays.asList(method.getParameterTypes())).isVoid()) { int flags = DYNAMIC; if (method.isStatic()) { flags |= STATIC; } if (method.isBindable()) { flags |= CAN_BE_INVALIDATED; } else { // if method is not bindable, look for a backing field final ModelField backingField = getField(name, true, method.isStatic()); L.d("backing field for method %s is %s", method.getName(), backingField == null ? "NOT FOUND" : backingField.getName()); if (backingField != null && backingField.isBindable()) { flags |= CAN_BE_INVALIDATED; } } final Callable result = new Callable(Callable.Type.METHOD, methodName, method.getReturnType(null), flags); return result; } } } // could not find a method. Look for a public field ModelField publicField = null; if (staticOnly) { publicField = getField(name, false, true); } else { // first check non-static publicField = getField(name, false, false); if (publicField == null) { // check for static publicField = getField(name, false, true); } } if (publicField == null) { return null; } ModelClass fieldType = publicField.getFieldType(); int flags = 0; if (!publicField.isFinal()) { flags |= DYNAMIC; } if (publicField.isBindable()) { flags |= CAN_BE_INVALIDATED; } if (publicField.isStatic()) { flags |= STATIC; } return new Callable(Callable.Type.FIELD, name, fieldType, flags); }
From source file:jongo.filter.DefaultFormatFilter.java
/** * Generates a new {@linkplain javax.ws.rs.core.Response} for a given * {@link jongo.rest.xstream.JongoHead} generating the appropriate XML or JSON representation * and setting the Content-Location header. * @param response a {@link jongo.rest.xstream.JongoSuccess} to be converted to JSON or XML. * @param mime the {@linkplain javax.ws.rs.core.MediaType} used to determine the transport format. * @param status the current HTTP code of the response. * @return a new {@linkplain javax.ws.rs.core.Response} with the new headers. *//*from w w w.j a va 2s . c o m*/ private Response formatHeadResponse(final JongoHead response, final MediaType mime, final Integer status) { final List<String> args = new ArrayList<String>(); for (Row row : response.getRows()) { final String columnname = row.getCells().get("columnName"); final String columntype = row.getCells().get("columnType"); final String columnsize = row.getCells().get("columnSize"); StringBuilder b = new StringBuilder(columnname).append("=").append(columntype).append("(") .append(columnsize).append(")"); args.add(b.toString()); } String res = StringUtils.join(args, ";"); return Response.status(status).type(mime).header("Content-Location", response.getResource()) .header(StringUtils.capitalize(response.getResource()), res).build(); }
From source file:at.gridtec.lambda4j.generator.processors.impl.NameProcessor.java
/** * Capitalizes the given type name and returns the result. * * @param typeName The name of the type to capitalize * @return Capitalizes the given type name and returns the result. *//* w w w . j a v a2 s .com*/ private String cap(@Nonnull final String typeName) { return StringUtils.capitalize(typeName); }
From source file:edu.toronto.cs.cidb.ncbieutils.NCBIEUtilsAccessService.java
private static String fixCase(String text) { if (text == null || text.length() == 0) { return ""; }//from w w w . j av a 2s. c om if (StringUtils.isAllUpperCase(text.replaceAll("[^a-zA-Z]", ""))) { return StringUtils.capitalize(text.toLowerCase()); } return text; }