/** * 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); }
public DBIdentifier getValidTableIdentifier(DBIdentifier name, Schema schema, int maxLen) { if (DBIdentifier.isNull(name)) { return name; } String rule = name.getType().name(); maxLen = getMaxLen(rule, name, maxLen); DBIdentifier sName = makeName(rule, name, null); return makeIdentifierValid(sName, schema.getSchemaGroup(), maxLen, true); }
/** * Converts a column alias to use the appropriate delimiters */ public String convertAlias(String alias) { if (!needsConversion(getIdentifierConfiguration())) { return alias; } String[] names = Normalizer.splitName(alias); if (names.length <= 1) { // Nothing to split return alias; } // Skip the the first name. It is the alias (T0, T1, etc.) for (int i = 1; i < names.length; i++) { names[i] = toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().toString(), names[i], true); } return joinNames(getIdentifierConfiguration().getDefaultIdentifierRule(), names); }
/** * Converts the identifier to a format appropriate for the configuration using * the default naming rule. * @param delimit If false, do not delimit. Otherwise, delimit if necessary. */ public String toDBName(String name, boolean delimit) { return toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().getName(), name, delimit); }
/** * Converts the name to a name which can be used within a SQL statement. Uses * the appropriate delimiters and separators. * @parm name a DBIdentifier * @param delimit If true, allows the name to be delimited, if necessary. * Otherwise, the identifier is not delimited. */ public String toDBName(DBIdentifier name, boolean delimit) { if (DBIdentifier.isNull(name)) { return null; } if (getIdentifierConfiguration().getSupportsDelimitedIdentifiers() && delimit && getIdentifierConfiguration().delimitAll() && !name.isDelimited()) { return delimit(name, true); } String rule = name.getType().name(); if (name instanceof QualifiedDBIdentifier) { QualifiedDBIdentifier path = (QualifiedDBIdentifier)name; return convertFull(Normalizer.getNamingConfiguration(), rule, path.getName()); } return convert(Normalizer.getNamingConfiguration(), rule, name.getName()); }
String rule = sname.getType().name(); maxLen = getMaxLen(rule, validName, maxLen); nameLen = validName.getName().length(); if (isReservedWord(rule, validName.getName())) { if (nameLen == maxLen) validName = DBIdentifier.truncate(validName, 1); String delimCase = getIdentifierConfiguration().getDelimitedCase(); if (delimCase.equals(CASE_LOWER)) { return DBIdentifier.toLower(validName,true);
public DBIdentifier getValidColumnIdentifier(DBIdentifier name, Table table, int maxLen, boolean checkForUniqueness) { if (DBIdentifier.isNull(name)) { return name; } String rule = name.getType().name(); maxLen = getMaxLen(rule, name, maxLen); DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE); return makeIdentifierValid(sName, table, maxLen, checkForUniqueness); }
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; }
return DBIdentifier.NULL; if (!getIdentifierConfiguration().getSupportsDelimitedIdentifiers()) { return DBIdentifier.newIdentifier(name, id); String delimCase = getIdentifierConfiguration().getDelimitedCase(); String nonDelimCase = getIdentifierConfiguration().getSchemaCase(); String caseName = name; boolean delimit = !caseName.equals(name) || getIdentifierConfiguration().delimitAll(); return DBIdentifier.newIdentifier((delimit ? name : caseName), id, false, delimit, !delimCase.equals(CASE_PRESERVE));
public DBIdentifier makeNameValid(String name, NameSet set, int maxLen, int nameType, boolean checkForUniqueness) { DBIdentifierType id = DBIdentifierType.DEFAULT; switch (nameType) { case DBIdentifierUtil.TABLE: id = DBIdentifierType.TABLE; break; case DBIdentifierUtil.SEQUENCE: id = DBIdentifierType.SEQUENCE; break; case DBIdentifierUtil.COLUMN: id = DBIdentifierType.COLUMN; break; } return makeIdentifierValid(DBIdentifier.newIdentifier(name, id), set, maxLen, checkForUniqueness); }
public String delimit(DBIdentifier name, boolean force) { String rule = name.getType().name(); // If this is a compound path, each item must be delimited // separately if (name instanceof QualifiedDBIdentifier) { QualifiedDBIdentifier path = (QualifiedDBIdentifier)name; // Make sure this is a qualified path before delimiting // separately if (!((path.getType() == DBIdentifierType.COLUMN && path.isUnqualifiedColumn()) || (path.getType() != DBIdentifierType.COLUMN && path.isUnqualifiedObject()))) { DBIdentifier[] names = QualifiedDBIdentifier.splitPath(name); for (int i = 0; i < names.length; i++) { DBIdentifier sName = names[i].getUnqualifiedName(); if (!sName.isDelimited()) { String pRule = sName.getType().name(); names[i].setName(delimit(pRule, sName.getName(), force)); } } return QualifiedDBIdentifier.newPath(names).getName(); } } return delimit(rule, name.getName(), force); }
/** * Converts the name to a name which can be used within a SQL statement. Uses * the appropriate delimiters and separators. * @parm name a DBIdentifier * @param delimit If true, allows the name to be delimited, if necessary. * Otherwise, the identifier is not delimited. */ public String toDBName(DBIdentifier name, boolean delimit) { if (DBIdentifier.isNull(name)) { return null; } if (getIdentifierConfiguration().getSupportsDelimitedIdentifiers() && delimit && getIdentifierConfiguration().delimitAll() && !name.isDelimited()) { return delimit(name, true); } String rule = name.getType().name(); if (name instanceof QualifiedDBIdentifier) { QualifiedDBIdentifier path = (QualifiedDBIdentifier)name; return convertFull(Normalizer.getNamingConfiguration(), rule, path.getName()); } return convert(Normalizer.getNamingConfiguration(), rule, name.getName()); }
String rule = sname.getType().name(); maxLen = getMaxLen(rule, validName, maxLen); nameLen = validName.getName().length(); if (isReservedWord(rule, validName.getName())) { if (nameLen == maxLen) validName = DBIdentifier.truncate(validName, 1); String delimCase = getIdentifierConfiguration().getDelimitedCase(); if (delimCase.equals(CASE_LOWER)) { return DBIdentifier.toLower(validName,true);
/** * Converts the identifier to a format appropriate for the configuration using * the default naming rule. * @param delimit If false, do not delimit. Otherwise, delimit if necessary. */ public String toDBName(String name, boolean delimit) { return toDBName(getIdentifierConfiguration().getDefaultIdentifierRule().getName(), name, delimit); }
public DBIdentifier getValidColumnIdentifier(DBIdentifier name, Table table, int maxLen, boolean checkForUniqueness) { if (DBIdentifier.isNull(name)) { return name; } String rule = name.getType().name(); maxLen = getMaxLen(rule, name, maxLen); DBIdentifier sName = DBIdentifier.removeLeading(name, IdentifierUtil.UNDERSCORE); return makeIdentifierValid(sName, table, maxLen, checkForUniqueness); }
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; }
return DBIdentifier.NULL; if (!getIdentifierConfiguration().getSupportsDelimitedIdentifiers()) { return DBIdentifier.newIdentifier(name, id); String delimCase = getIdentifierConfiguration().getDelimitedCase(); String nonDelimCase = getIdentifierConfiguration().getSchemaCase(); String caseName = name; boolean delimit = !caseName.equals(name) || getIdentifierConfiguration().delimitAll(); return DBIdentifier.newIdentifier((delimit ? name : caseName), id, false, delimit, !delimCase.equals(CASE_PRESERVE));
public DBIdentifier makeNameValid(String name, NameSet set, int maxLen, int nameType, boolean checkForUniqueness) { DBIdentifierType id = DBIdentifierType.DEFAULT; switch (nameType) { case DBIdentifierUtil.TABLE: id = DBIdentifierType.TABLE; break; case DBIdentifierUtil.SEQUENCE: id = DBIdentifierType.SEQUENCE; break; case DBIdentifierUtil.COLUMN: id = DBIdentifierType.COLUMN; break; } return makeIdentifierValid(DBIdentifier.newIdentifier(name, id), set, maxLen, checkForUniqueness); }
public String delimit(DBIdentifier name, boolean force) { String rule = name.getType().name(); // If this is a compound path, each item must be delimited // separately if (name instanceof QualifiedDBIdentifier) { QualifiedDBIdentifier path = (QualifiedDBIdentifier)name; // Make sure this is a qualified path before delimiting // separately if (!((path.getType() == DBIdentifierType.COLUMN && path.isUnqualifiedColumn()) || (path.getType() != DBIdentifierType.COLUMN && path.isUnqualifiedObject()))) { DBIdentifier[] names = QualifiedDBIdentifier.splitPath(name); for (int i = 0; i < names.length; i++) { DBIdentifier sName = names[i].getUnqualifiedName(); if (!sName.isDelimited()) { String pRule = sName.getType().name(); names[i].setName(delimit(pRule, sName.getName(), force)); } } return QualifiedDBIdentifier.newPath(names).getName(); } } return delimit(rule, name.getName(), force); }
public DBIdentifier getValidSequenceIdentifier(DBIdentifier name, Schema schema, int maxLen) { if (DBIdentifier.isNull(name)) { return name; } String rule = name.getType().name(); maxLen = getMaxLen(rule, name, maxLen); DBIdentifier sName = makeName(rule, name, "S"); return makeIdentifierValid(sName, schema.getSchemaGroup(), maxLen, true); }