protected String removeHungarianNotation(String columnName) { return Normalizer.removeHungarianNotation(columnName); }
/** * Splits a string delimited by the specified delimiter of a given name type * into an array of DBIdentifier objects. * Example: COL1|"COL 2"|COL3 delim=| --> DBIdentifier[]{ COL1, "COL 2", COL3 } * @param name * @param id * @param delim */ public static DBIdentifier[] split(String name, DBIdentifierType id, String delim) { if (!Normalizer.canSplit(name, delim)) { return new DBIdentifier[] { new DBIdentifier(name, id) }; } String[] names = Normalizer.splitName(name, delim); if (names.length == 0) { return new DBIdentifier[] { }; } DBIdentifier[] sNames = new DBIdentifier[names.length]; for (int i = 0; i < names.length ; i++) { sNames[i] = new DBIdentifier(names[i], id); } return sNames; }
/** * Combines an array of names names using standard combining rules and * returns an identifier of the specified type. */ public static DBIdentifier combine(DBIdentifierType id, String...names) { return newIdentifier(Normalizer.combine(names), id); }
/** * Normalizes a name, if not delimited, converts to uppercase. * @param name */ public static String normalizeUpper(String name) { String nName = normalizeString(name); // Do not convert delimited names to upper case. They may have // been delimited to preserve case. if (!isDelimited(nName)) { nName = name.toUpperCase(); } return nName; }
/** * The sequence table name. Defaults to <code>OPENJPA_SEQUENCE_TABLE</code>. * By default, the table will be placed in the first schema listed in your * <code>openjpa.jdbc.Schemas</code> property, or in the default schema if * the property is not given. If you specify a table name in the form * <code><schema>.<table></code>, then the given schema * will be used. */ public void setTable(String name) { // Split the name into its individual parts String[] names = Normalizer.splitName(name); // Join the name back together. This will delimit as appropriate. _table = DBIdentifier.newTable(Normalizer.joinNames(names)); }
/** * Returns true if the identifier is delimited. */ public boolean isDelimited() { if (DBIdentifier.isEmpty(this)) { return false; } return Normalizer.isDelimited(getNameInternal()); }
/** * Converts the identifier to a format appropriate for the configuration using * the specified naming rule. * @param delimit If false, do not delimit. Otherwise, delimit if necessary. */ private String toDBName(String rule, String name, boolean delimit) { if (name == null) { return null; } if (getIdentifierConfiguration().getSupportsDelimitedIdentifiers() && delimit && getIdentifierConfiguration().delimitAll() && !Normalizer.isDelimited(name)) { return delimit(rule, name, true); } return convert(Normalizer.getNamingConfiguration(), rule, name); }
/** * Set the name of the identifier and optionally force delimiting of the identifier. */ public void setName(String name, boolean delimit) { assertNotNull(); // Normalize the name, if necessary. Do not normalize constants or column definitions. if (DBIdentifierType.CONSTANT != getType() && DBIdentifierType.COLUMN_DEFINITION != getType()) { if (delimit) { name = Normalizer.delimit(name, true); } else { name = Normalizer.normalizeString(name); } } super.setName(name); }
/** * Joins two names using the default identifier rules. * @param names * @return */ public static String joinNames(String name1, String name2) { return joinNames(new String[] { name1, name2}); }
private DBIdentifier makeName(String rule, DBIdentifier name, Table tbl, String prefix) { DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE); String tableName = tbl.getIdentifier().getName(); int len = Math.min(tableName.length(), 7); // Combine the names using the normalized configuration. String str = combineNames(Normalizer.getNamingConfiguration(), rule, new String[] { prefix == null ? "" : prefix, shorten(tableName, len), sName.getName() }); sName.setName(str); return sName; }
/** * Returns a new DBIdentifier with the given string appended. * @param name * @param length * @return */ public static DBIdentifier append(DBIdentifier name, String str) { DBIdentifier sName = name.clone(); String strName = sName.getNameInternal(); strName = Normalizer.append(strName, str); sName.setNameInternal(strName); return sName; }
/** * Returns a new identifier with delimiters removed. * @param name */ public static DBIdentifier removeDelimiters(DBIdentifier name) { if (DBIdentifier.isNull(name)) { return name; } DBIdentifier sName = name.clone(); if (isEmpty(sName)) { return sName; } String strName = sName.getNameInternal(); strName = Normalizer.removeDelimiters(strName); sName.setNameInternal(strName); return sName; }
/** * Returns true if the identifier is delimited. */ public boolean isDelimited() { if (DBIdentifier.isEmpty(this)) { return false; } return Normalizer.isDelimited(getNameInternal()); }
/** * Normalizes a name, if not delimited, converts to uppercase. * @param name * @return */ public static String normalizeUpper(String name) { String nName = normalizeString(name); // Do not convert delimited names to upper case. They may have // been delimited to preserve case. if (!isDelimited(nName)) { nName = name.toUpperCase(); } return nName; }
/** * The sequence table name. Defaults to <code>OPENJPA_SEQUENCE_TABLE</code>. * By default, the table will be placed in the first schema listed in your * <code>openjpa.jdbc.Schemas</code> property, or in the default schema if * the property is not given. If you specify a table name in the form * <code><schema>.<table></code>, then the given schema * will be used. */ public void setTable(String name) { // Split the name into its individual parts String[] names = Normalizer.splitName(name); // Join the name back together. This will delimit as appropriate. _table = DBIdentifier.newTable(Normalizer.joinNames(names)); }
/** * Converts the identifier to a format appropriate for the configuration using * the specified naming rule. * @param delimit If false, do not delimit. Otherwise, delimit if necessary. */ private String toDBName(String rule, String name, boolean delimit) { if (name == null) { return null; } if (getIdentifierConfiguration().getSupportsDelimitedIdentifiers() && delimit && getIdentifierConfiguration().delimitAll() && !Normalizer.isDelimited(name)) { return delimit(rule, name, true); } return convert(Normalizer.getNamingConfiguration(), rule, name); }
/** * Set the name of the identifier and optionally force delimiting of the identifier. */ public void setName(String name, boolean delimit) { assertNotNull(); // Normalize the name, if necessary. Do not normalize constants or column definitions. if (DBIdentifierType.CONSTANT != getType() && DBIdentifierType.COLUMN_DEFINITION != getType()) { if (delimit) { name = Normalizer.delimit(name, true); } else { name = Normalizer.normalizeString(name); } } super.setName(name); }
/** * Joins two names using the default identifier rules. * @param names */ public static String joinNames(String name1, String name2) { return joinNames(new String[] { name1, name2}); }
private DBIdentifier makeName(String rule, DBIdentifier name, Table tbl, String prefix) { DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE); String tableName = tbl.getIdentifier().getName(); int len = Math.min(tableName.length(), 7); // Combine the names using the normalized configuration. String str = combineNames(Normalizer.getNamingConfiguration(), rule, new String[] { prefix == null ? "" : prefix, shorten(tableName, len), sName.getName() }); sName.setName(str); return sName; }
/** * Returns a new DBIdentifier with the given string appended. * @param name * @param length */ public static DBIdentifier append(DBIdentifier name, String str) { DBIdentifier sName = name.clone(); String strName = sName.getNameInternal(); strName = Normalizer.append(strName, str); sName.setNameInternal(strName); return sName; }