if (!Modifier.isStatic(method.getModifiers()) && !method.getReturnType().equals(Void.class)) { if (name.startsWith("is")) { name = StringHelper.firstToLower(name.substring(2)); name = StringHelper.firstToLower(name.substring(3)); Method setter = null; try { setter = clazz.getMethod("set" + StringHelper.firstToUpper(name), method.getReturnType());
/** * checks if a string contains only digits, i.e. * no non-number char in string, even no whitespace. * * @param str the string to check * * @return true if no illegal char detected, false otherwise */ public static boolean isAllDigits(String str) { return isAllDigits(str, false); }
/** * Creates a string from an object array. * * @param objArray the array of objects * @param separator the string between two objects * @return the string */ public static String objectArrayToString(Object[] objArray, String separator) { StringBuilder buf = new StringBuilder(); if (objArray != null) { boolean addSeparator = false; for (Object obj: objArray) { if (addSeparator) { buf.append(separator); } buf.append(objectToLoggableString(obj)); addSeparator = true; } } return buf.toString(); }
name = name.substring(2); return StringHelper.firstToLower(name);
@SuppressWarnings("unchecked") private static Method getMethodForElement(Class<?> clazz, String element) { Method method = null; String camelName = StringHelper.firstToUpper(element); // camelcase name part try { method = clazz.getMethod(element); } catch (NoSuchMethodException ex1) { // try "is" try { method = clazz.getMethod("is" + camelName); } catch (NoSuchMethodException ex2) { // try "get" try { method = clazz.getMethod("get" + camelName); } catch (NoSuchMethodException ex3) { // return null below } } } return method; }
/** * Trims a string. * The method is nullpointer safe. * * @param s the string, may be null * @return the trimmed string, null if s == null * @see #trim(java.lang.String, int) */ public static String trim(String s) { return trim(s, 0); }
/** * Gets the basename of a classname(-like) string. * The basename is the last name of a pathname with dots. * * @param str the classname * @return the basename */ public static String getClassBaseName(String str) { return StringHelper.lastAfter(str, '.'); }
StringBuilder buf = new StringBuilder(unDiacrit(str, false)); // translate all diacrits
bindingPath = StringHelper.removeTrailingText(bindingPath, "Field"); bindingPath = StringHelper.removeTrailingText(bindingPath, "Bean"); bindingPath = StringHelper.removeTrailingText(bindingPath, "Comp"); bindingPath = StringHelper.removeTrailingText(bindingPath, "Component");
if (!StringHelper.isValidJavaIdentifier(name)) { throw new ValidationRuntimeException("invalid name '" + name + "' in " + scopeImplementation.getName());
/** * Gets the default validation path.<br> * The default implementation just returns the object's class basename * with the first letter in lowercase (according to variable name rules). * * @param object the object to validate * @return the default (root) validation path, null if object is null */ public String getDefaultValidationPath(Object object) { Class<?> clazz = EffectiveClassProvider.getEffectiveClass(object); return clazz == null ? "null" : StringHelper.firstToLower(ReflectionHelper.getClassBaseName(clazz)); }
token = StringHelper.firstToUpper(token); buf.append(token); if (omitCount >= 0) {
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append("#!").append(getLanguage()).append("{ "); if (code != null) { String codeInfo = StringHelper.trim(code.replace('\n', ' '), 64); buf.append(codeInfo); if (codeInfo.length() < code.length()) { buf.append(" ..."); } } else { buf.append("<null>"); } buf.append(" }"); return buf.toString(); }
StringHelper.lastAfter(prefName, '/')))) { return false;
public String apply(String str) { str = StringHelper.unDiacrit(str, false); // convert special characters and umlauts
bindingPath = StringHelper.removeTrailingText(bindingPath, "Field"); bindingPath = StringHelper.removeTrailingText(bindingPath, "Node"); bindingPath = StringHelper.removeTrailingText(bindingPath, "Comp"); bindingPath = StringHelper.removeTrailingText(bindingPath, "Component");
if (!StringHelper.isValidJavaIdentifier(name)) { throw new SecurityException("invalid name '" + name + "' in " + permissionImplementation.getName());
/** * Gets the member-name of the annotated element. * * @param element the annotated element * @return the element's name */ protected String getAnnotatedElementName(AnnotatedElement element) { if (element instanceof Field) { return ((Field) element).getName(); } else if (element instanceof Method) { return StringHelper.firstToLower(ReflectionHelper.getPathMethodName((Method) element)); } else if (element instanceof Class<?>) { return ((Class<?>) element).getName(); } else { throw new ValidationRuntimeException("cannot determine element name"); } }
token = StringHelper.firstToUpper(token); buf.append(token); if (omitCount >= 0) {