/** * Set of semicolon-separated resource paths of metadata files or jars * supplied by user via auto-configuration. */ public void setResources(String rsrcs) { // keep list mutable so subclasses can add implicit locations this.rsrcs = (StringUtil.isEmpty(rsrcs)) ? null : new ArrayList<String>(Arrays.asList(StringUtil.split(rsrcs, ";", 0))); }
/** * Return the proper getter method of the {@link Reflection} helper for * a field or getter method of the given type. */ private Method getReflectionGetterMethod(Class type, Class argType) throws NoSuchMethodException { String name = "get"; if (type.isPrimitive()) name += StringUtil.capitalize(type.getName()); return Reflection.class.getMethod(name, new Class[] { Object.class, argType }); }
/** * Set the 'JTA' ConnectionFactoryName. Input will be trimmed to null before being stored. */ public void setConnectionFactoryName(String connectionFactoryName) { this._connectionFactoryName = StringUtil.trimToNull(connectionFactoryName); }
/** * Replace all instances of <code>from</code> in <code>str</code> * with <code>to</code>. * * @param str the candidate string to replace * @param from the token to replace * @param to the new token * @return the string with all the replacements made */ public static String replace(String str, String from, String to) { if (from.equals(to)) { return str; } String[] split = split(str, from, Integer.MAX_VALUE); return join(split, to); }
/** * Sets the names of the columns on which a unique constraint is set. * @param columnsNames are passed as a single String concatenated with * a '|' character. This method parses it back to array of Strings. */ public void setUniqueColumns(String columnNames) { _uniqueColumnNames = (StringUtil.isEmpty(columnNames)) ? null : DBIdentifier.split(columnNames, DBIdentifierType.COLUMN, IdentifierUtil.BAR); }
private void serializeUniqueConstraint(Unique unique, AnnotationBuilder ab) { StringBuilder sb = new StringBuilder(); Column[] columns = unique.getColumns(); for (Column column:columns) { if (sb.length() > 0) sb.append(", "); sb.append(column.getName()); } if (columns.length > 1) sb.insert(0, "{").append("}"); ab.add("columnNames", sb.toString()); if (StringUtil.isNotEmpty(unique.getName())) { ab.add("name", unique.getName()); } }
/** * Return a default Java identifier-formatted name for the given * column/table name. */ public String getFieldName(String name, ClassMapping dec) { name = replaceInvalidCharacters(name); if (allUpperCase(name)) name = name.toLowerCase(); else name = Character.toLowerCase(name.charAt(0)) + name.substring(1); StringBuilder buf = new StringBuilder(); String[] subs = StringUtil.split(name, "_", 0); for (int i = 0; i < subs.length; i++) { if (i > 0) subs[i] = StringUtil.capitalize(subs[i]); buf.append(subs[i]); } return getUniqueName(buf.toString(), dec); }
/** * add CAST for a scalar function where operand is a param * * @param func original string * @param target substring to look for * @param asString * @return updated string (func) */ private String addCastAsString(String func, String target, String asString) { String fstring = func; if (func.indexOf(target) != -1) { fstring = StringUtil.replace(func, target, "CAST(" + target + asString + ")"); } return fstring; }
protected String getInternalString() { return StringUtil.join(_values, ", "); }
/** * Provided for auto-configuration. Add the given semicolon-separated * class names to the set of class names we know cannot be proxied correctly * by this manager. */ public void setUnproxyable(String clsNames) { if (clsNames != null) _unproxyable.addAll(Arrays.asList(StringUtil.split(clsNames, ";", 0))); }
public StringId(Class<?> cls, String key) { super(cls); this.key = (key == null) ? "" : StringUtil.stripEnd(key, null); }
/** * Convert the given value to a value consumable by OpenJPA kernel constructs. */ Object convertUserValue(String key, Object value, Class<?> targetType) { if (JPAProperties.isValidKey(key)) return JPAProperties.convertToKernelValue(targetType, key, value); if (value instanceof String) { if ("null".equals(value)) { return null; } else { String val = (String) value; int parenIndex = val.indexOf('('); if (!String.class.equals(targetType) && (parenIndex > 0)) { val = val.substring(0, parenIndex); } return StringUtil.parse(val, targetType); } } else if (value instanceof AutoDetachType) { EnumSet<AutoDetachType> autoDetachFlags = EnumSet.noneOf(AutoDetachType.class); autoDetachFlags.add((AutoDetachType)value); return autoDetachFlags; } else if (value instanceof AutoDetachType[]) { EnumSet<AutoDetachType> autoDetachFlags = EnumSet.noneOf(AutoDetachType.class); autoDetachFlags.addAll(Arrays.asList((AutoDetachType[])value)); return autoDetachFlags; } return value; }
@Override public String[] getCreateTableSQL(Table table) { String[] sql = super.getCreateTableSQL(table); if (!StringUtil.isEmpty(tableType)) sql[0] = sql[0] + " ENGINE = " + tableType; return sql; }
private void serializeUniqueConstraint(Unique unique, AnnotationBuilder ab) { StringBuilder sb = new StringBuilder(); Column[] columns = unique.getColumns(); for (Column column:columns) { if (sb.length() > 0) sb.append(", "); sb.append(column.getName()); } if (columns.length > 1) sb.insert(0, "{").append("}"); ab.add("columnNames", sb.toString()); if (StringUtil.isNotEmpty(unique.getName())) { ab.add("name", unique.getName()); } }
/** * Return a default Java identifier-formatted name for the given * column/table name. */ public String getFieldName(String name, ClassMapping dec) { name = replaceInvalidCharacters(name); if (allUpperCase(name)) name = name.toLowerCase(); else name = Character.toLowerCase(name.charAt(0)) + name.substring(1); StringBuilder buf = new StringBuilder(); String[] subs = StringUtil.split(name, "_", 0); for (int i = 0; i < subs.length; i++) { if (i > 0) subs[i] = StringUtil.capitalize(subs[i]); buf.append(subs[i]); } return getUniqueName(buf.toString(), dec); }
/** * Replace all instances of <code>from</code> in <code>str</code> * with <code>to</code>. * * @param str the candidate string to replace * @param from the token to replace * @param to the new token * @return the string with all the replacements made */ public static String replace(String str, String from, String to) { if (from.equals(to)) { return str; } String[] split = split(str, from, Integer.MAX_VALUE); return join(split, to); }
/** * add CAST for a scalar function where operand is a param * * @param func original string * @param target substring to look for * @param asString * @return updated string (func) */ private String addCastAsString(String func, String target, String asString) { String fstring = func; if (func.indexOf(target) != -1) { fstring = StringUtil.replace(func, target, "CAST(" + target + asString + ")"); } return fstring; }
protected String getInternalString() { return StringUtil.join(_values, ", "); }
/** * Provided for auto-configuration. Add the given semicolon-separated * class names to the set of class names we know cannot be proxied correctly * by this manager. */ public void setUnproxyable(String clsNames) { if (clsNames != null) _unproxyable.addAll(Arrays.asList(StringUtil.split(clsNames, ";", 0))); }
public StringId(Class<?> cls, String key) { super(cls); this.key = (key == null) ? "" : StringUtil.stripEnd(key, null); }