/** * Filter a URI fragment to remove illegal characters * @param s the relevant string * @return the filtered string */ public static String javaiseClassName(String s) { String filtered = s; StringBuffer sb = new StringBuffer(); for (StringTokenizer st = new StringTokenizer(filtered, " _-"); st.hasMoreTokens();) { sb.append(StringUtil.capitalise(st.nextToken().replaceAll("\\W", ""))); } filtered = sb.toString(); return filtered; }
/** * Filter a URI fragment to remove illegal characters * @param s the relevant string * @return the filtered string */ public static String javaiseClassName(String s) { String filtered = s; StringBuffer sb = new StringBuffer(); for (StringTokenizer st = new StringTokenizer(filtered, " _-"); st.hasMoreTokens();) { sb.append(StringUtil.capitalise(st.nextToken().replaceAll("\\W", ""))); } filtered = sb.toString(); return filtered; }
m = clazz.getMethod("set" + StringUtil.capitalise(subAttribute), new Class[] {String.class}); if (m != null) { if (m == null) { m = field.get(this).getClass(). getMethod("set" + StringUtil.capitalise(subAttribute), new Class[] {int.class}); if (m != null) {
m = clazz.getMethod("set" + StringUtil.capitalise(subAttribute), new Class[] {String.class}); if (m != null) { if (m == null) { m = field.get(this).getClass(). getMethod("set" + StringUtil.capitalise(subAttribute), new Class[] {int.class}); if (m != null) {
public void testCapitalise() throws Exception { assertEquals("A", StringUtil.capitalise("a")); assertEquals("A", StringUtil.capitalise("A")); assertEquals("Aaaa", StringUtil.capitalise("aaaa")); assertEquals("AaaaBbbb", StringUtil.capitalise("aaaaBbbb")); assertEquals("", StringUtil.capitalise("")); assertNull(StringUtil.capitalise(null)); }
/** * Creates a column name for the "outward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getOutwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else if (version == 1) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
/** * Creates a column name for the "inward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getInwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else if (version == 1) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
/** * Creates a column name for the "inward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getInwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else if (version == 1) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
/** * Creates a column name for the "outward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getOutwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else if (version == 1) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }