diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor')
23 files changed, 0 insertions, 1821 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java deleted file mode 100644 index 934a9aae9f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * Consolidate the behavior common to the typical vendors. - */ -abstract class AbstractVendor - implements Vendor -{ - - AbstractVendor() { - super(); - } - - public abstract String getDTPVendorName(); - - - // ********** catalog and schema support ********** - - abstract CatalogStrategy getCatalogStrategy(); - - public boolean supportsCatalogs(Database database) { - return this.getCatalogStrategy().supportsCatalogs(database); - } - - public List<Catalog> getCatalogs(Database database) { - return this.getCatalogStrategy().getCatalogs(database); - } - - public List<Schema> getSchemas(Database database) { - try { - return this.getCatalogStrategy().getSchemas(database); - } catch (Exception ex) { - throw new RuntimeException("vendor: " + this, ex); //$NON-NLS-1$ - } - } - - /** - * Typically, the name of the default catalog is the user name. - */ - public final List<String> getDefaultCatalogIdentifiers(Database database, String userName) { - if ( ! this.supportsCatalogs(database)) { - return Collections.emptyList(); - } - ArrayList<String> identifiers = new ArrayList<String>(); - this.addDefaultCatalogIdentifiersTo(database, userName, identifiers); - return identifiers; - } - - void addDefaultCatalogIdentifiersTo(@SuppressWarnings("unused") Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(this.convertNameToIdentifier(userName)); - } - - /** - * Typically, the name of the default schema is the user name. - */ - public final List<String> getDefaultSchemaIdentifiers(Database database, String userName) { - ArrayList<String> identifiers = new ArrayList<String>(); - this.addDefaultSchemaIdentifiersTo(database, userName, identifiers); - return identifiers; - } - - /** - * The user name passed in here was retrieved from DTP. - * DTP stores the user name that was passed to it during the connection - * to the database. As a result, this user name is an "identifier" not a "name". - * If the user name were retrieved from the JDBC connection it would probably - * be a "name". For example, you can connect to an Oracle database with the - * user name "scott", but that identifer is folded to the actual user name - * "SCOTT". DTP stores the original string "scott", while the Oracle JDBC - * driver stores the folded string "SCOTT". - */ - void addDefaultSchemaIdentifiersTo(@SuppressWarnings("unused") Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(userName); - } - - - // ********** folding strategy used to convert names and identifiers ********** - - /** - * The SQL spec says a "normal" (non-delimited) identifier should be - * folded to uppercase; but some databases do otherwise (e.g. Sybase). - */ - abstract FoldingStrategy getFoldingStrategy(); - - - // ********** name -> identifier ********** - - public String convertNameToIdentifier(String name, String defaultName) { - return this.nameRequiresDelimiters(name) ? this.delimitName(name) - : this.normalNamesMatch(name, defaultName) ? null : name; - } - - public String convertNameToIdentifier(String name) { - return this.nameRequiresDelimiters(name) ? this.delimitName(name) : name; - } - - /** - * Return whether the specified database object name must be delimited - * when used in an SQL statement. - * If the name has any "special" characters (as opposed to letters, - * digits, and other allowed characters [e.g. underscores]), it requires - * delimiters. - * If the name is mixed case and the database folds undelimited names - * (to either uppercase or lowercase), it requires delimiters. - */ - boolean nameRequiresDelimiters(String name) { - return (name.length() == 0) // an empty string must be delimited(?) - || this.nameContainsAnyNonNormalCharacters(name) - || this.nameIsNotFolded(name); - } - - /** - * Return whether the specified name contains any "non-normal" characters - * that require the name to be delimited. - * Pre-condition: the specified name is not empty - */ - boolean nameContainsAnyNonNormalCharacters(String name) { - char[] string = name.toCharArray(); - if (this.characterIsNonNormalNameStart(string[0])) { - return true; - } - for (int i = string.length; i-- > 1; ) { // note: stop at 1 - if (this.characterIsNonNormalNamePart(string[i])) { - return true; - } - } - return false; - } - - /** - * Return whether the specified character is "non-normal" for the first - * character of a name. - * Typically, databases are more restrictive about what characters can - * be used to *start* an identifier (as opposed to the characters - * allowed for the remainder of the identifier). - */ - boolean characterIsNonNormalNameStart(char c) { - return ! this.characterIsNormalNameStart(c); - } - - /** - * Return whether the specified character is "normal" for the first - * character of a name. - * The first character of an identifier can be: - * - a letter - * - any of the extended, vendor-specific, "normal" start characters - */ - boolean characterIsNormalNameStart(char c) { - // all vendors allow a letter - return Character.isLetter(c) - || this.characterIsExtendedNormalNameStart(c); - } - - boolean characterIsExtendedNormalNameStart(char c) { - return arrayContains(this.getExtendedNormalNameStartCharacters(), c); - } - - /** - * Return the "normal" characters, beyond letters, for the - * first character of a name. - * Return null if there are no "extended" characters. - */ - char[] getExtendedNormalNameStartCharacters() { - return null; - } - - /** - * Return whether the specified character is "non-normal" for the second - * and subsequent characters of a name. - */ - boolean characterIsNonNormalNamePart(char c) { - return ! this.characterIsNormalNamePart(c); - } - - /** - * Return whether the specified character is "normal" for the second and - * subsequent characters of a name. - * The second and subsequent characters of a "normal" name can be: - * - a letter - * - a digit - * - any of the extended, vendor-specific, "normal" start characters - * - any of the extended, vendor-specific, "normal" part characters - */ - boolean characterIsNormalNamePart(char c) { - // all vendors allow a letter or digit - return Character.isLetterOrDigit(c) - || this.characterIsExtendedNormalNameStart(c) - || this.characterIsExtendedNormalNamePart(c); - } - - boolean characterIsExtendedNormalNamePart(char c) { - return arrayContains(this.getExtendedNormalNamePartCharacters(), c); - } - - /** - * Return the "normal" characters, beyond letters and digits and the - * "normal" first characters, for the second and subsequent characters - * of an identifier. Return null if there are no additional characters. - */ - char[] getExtendedNormalNamePartCharacters() { - return null; - } - - /** - * Return whether the specified name is not folded to the database's - * case, requiring it to be delimited. - */ - boolean nameIsNotFolded(String name) { - return ! this.getFoldingStrategy().nameIsFolded(name); - } - - /** - * Return whether the specified "normal" names match. - */ - boolean normalNamesMatch(String name1, String name2) { - return this.normalIdentifiersAreCaseSensitive() ? - name1.equals(name2) - : - name1.equalsIgnoreCase(name2); - } - - /** - * Typically, "normal" identifiers are case-insensitive. - */ - boolean normalIdentifiersAreCaseSensitive() { - return this.getFoldingStrategy().normalIdentifiersAreCaseSensitive(); - } - - /** - * Wrap the specified name in delimiters (typically double-quotes), - * converting it to an identifier. - */ - String delimitName(String name) { - return StringTools.quote(name); - } - - - // ********** identifier -> name ********** - - // not sure how to handle an empty string: - // both "" and "\"\"" are converted to "" ... - // convert "" to 'null' since empty strings must be delimited? - public String convertIdentifierToName(String identifier) { - return (identifier == null) ? null : - this.identifierIsDelimited(identifier) ? - StringTools.undelimit(identifier) - : - this.getFoldingStrategy().fold(identifier); - } - - /** - * Return whether the specified identifier is "delimited". - * The SQL-92 spec says identifiers should be delimited by - * double-quotes; but some databases allow otherwise (e.g. Sybase). - */ - boolean identifierIsDelimited(String identifier) { - return StringTools.stringIsQuoted(identifier); - } - - - // ********** misc ********** - - @Override - public String toString() { - return this.getDTPVendorName(); - } - - /** - * static convenience method - array null check - */ - static boolean arrayContains(char[] array, char c) { - return (array != null) && ArrayTools.contains(array, c); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/CatalogStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/CatalogStrategy.java deleted file mode 100644 index 9c7a4b59c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/CatalogStrategy.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; - -/** - * Handle the variety of catalog (and schema) configurations generated by DTP. - */ -interface CatalogStrategy { - - /** - * Return whether the DTP database has real catalogs. - */ - boolean supportsCatalogs(Database database); - - /** - * Return the specified database's catalogs. - */ - List<Catalog> getCatalogs(Database database); - - /** - * Return the specified database's schemas. - */ - List<Schema> getSchemas(Database database); - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/DB2.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/DB2.java deleted file mode 100644 index 259d039185..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/DB2.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -class DB2 - extends AbstractVendor -{ - private final String dtpVendorName; - - private static final Vendor UDB = new DB2("DB2 UDB"); //$NON-NLS-1$ - private static final Vendor UDB_I_SERIES = new DB2("DB2 UDB iSeries"); //$NON-NLS-1$ - private static final Vendor UDB_Z_SERIES = new DB2("DB2 UDB zSeries"); //$NON-NLS-1$ - - static Vendor udb() { - return UDB; - } - - static Vendor udbISeries() { - return UDB_I_SERIES; - } - - static Vendor udbZSeries() { - return UDB_Z_SERIES; - } - - /** - * Ensure only static instances. - */ - private DB2(String dtpVendorName) { - super(); - this.dtpVendorName = dtpVendorName; - } - - @Override - public String getDTPVendorName() { - return this.dtpVendorName; - } - - @Override - CatalogStrategy getCatalogStrategy() { - return UnknownCatalogStrategy.instance(); // not verified yet... - } - - @Override - FoldingStrategy getFoldingStrategy() { - return UpperCaseFoldingStrategy.instance(); - } - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '_' }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java deleted file mode 100644 index 01bce02199..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; - -import org.eclipse.datatools.modelbase.sql.schema.Database; - -class Derby - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new Derby(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private Derby() { - super(); - } - - @Override - public String getDTPVendorName() { - return "Derby"; //$NON-NLS-1$ - } - - @Override - CatalogStrategy getCatalogStrategy() { - return FauxCatalogStrategy.instance(); - } - - @Override - FoldingStrategy getFoldingStrategy() { - return UpperCaseFoldingStrategy.instance(); - } - - @Override - void addDefaultSchemaIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(this.buildDefaultSchemaIdentifier(userName)); - } - - /** - * The default user name on Derby is "APP" when the user connects without - * a user name. - */ - private String buildDefaultSchemaIdentifier(String userName) { - return ((userName != null) && (userName.length() != 0)) ? userName : DEFAULT_USER_IDENTIFIER; - } - private static final String DEFAULT_USER_IDENTIFIER = "APP"; //$NON-NLS-1$ - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '_' }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/FauxCatalogStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/FauxCatalogStrategy.java deleted file mode 100644 index b5b5b4218d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/FauxCatalogStrategy.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; - -/** - * Catalog strategy for DTP databases that build a "virtual" catalog (that has - * no name) because the underlying JDBC driver does not return any catalogs - * (e.g. Oracle). - * @see java.sql.DatabaseMetaData#getCatalogs() - */ -class FauxCatalogStrategy - implements CatalogStrategy -{ - // singleton - private static final CatalogStrategy INSTANCE = new FauxCatalogStrategy(); - - /** - * Return the singleton. - */ - static CatalogStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private FauxCatalogStrategy() { - super(); - } - - public boolean supportsCatalogs(Database database) { - return false; - } - - public List<Catalog> getCatalogs(Database database) { - return Collections.emptyList(); - } - - @SuppressWarnings("unchecked") - public List<Schema> getSchemas(Database database) { - return this.getFauxCatalog(database.getCatalogs()).getSchemas(); - } - - private Catalog getFauxCatalog(List<Catalog> catalogs) { - if (catalogs == null) { - throw new IllegalStateException(); - } - if (catalogs.size() != 1) { - throw new IllegalStateException("not a single catalog: " + catalogs.size()); //$NON-NLS-1$ - } - - Catalog catalog = catalogs.get(0); - if (catalog.getName().length() != 0) { - throw new IllegalStateException("illegal name: " + catalog.getName()); //$NON-NLS-1$ - } - return catalog; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/FoldingStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/FoldingStrategy.java deleted file mode 100644 index 9527f568e2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/FoldingStrategy.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -/** - * Handle database-specific identifier-folding issues. - */ -interface FoldingStrategy { - - /** - * Fold the specified name. - */ - String fold(String name); - - /** - * Return whether the specified database object name is already folded, - * meaning, if it has no special characters, it requires no delimiters. - */ - boolean nameIsFolded(String name); - - /** - * Return whether the database is case-sensitive when using "normal" - * (i.e. non-delimited) identifiers. - */ - boolean normalIdentifiersAreCaseSensitive(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/HSQLDB.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/HSQLDB.java deleted file mode 100644 index 45f51b79b3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/HSQLDB.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; - -import org.eclipse.datatools.modelbase.sql.schema.Database; - -class HSQLDB - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new HSQLDB(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private HSQLDB() { - super(); - } - - @Override - public String getDTPVendorName() { - return "HSQLDB"; //$NON-NLS-1$ - } - - @Override - CatalogStrategy getCatalogStrategy() { - return UnknownCatalogStrategy.instance(); // not verified yet... - } - - @Override - FoldingStrategy getFoldingStrategy() { - return UpperCaseFoldingStrategy.instance(); - } - - @Override - void addDefaultSchemaIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(PUBLIC_SCHEMA_IDENTIFIER); - } - private static final String PUBLIC_SCHEMA_IDENTIFIER = "PUBLIC"; //$NON-NLS-1$ - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Informix.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Informix.java deleted file mode 100644 index 200c4b2de4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Informix.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -class Informix - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new Informix(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private Informix() { - super(); - } - - @Override - public String getDTPVendorName() { - return "Informix"; //$NON-NLS-1$ - } - - @Override - CatalogStrategy getCatalogStrategy() { - return UnknownCatalogStrategy.instance(); // not verified yet... - } - - @Override - FoldingStrategy getFoldingStrategy() { - return LowerCaseFoldingStrategy.instance(); - } - - @Override - char[] getExtendedNormalNameStartCharacters() { - return EXTENDED_NORMAL_NAME_START_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_START_CHARACTERS = new char[] { '_' }; - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '$' }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/LowerCaseFoldingStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/LowerCaseFoldingStrategy.java deleted file mode 100644 index 833c70f1d2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/LowerCaseFoldingStrategy.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * Fold "normal" identifiers to lower case. - * Ignore the case of "normal" identifiers. - */ -class LowerCaseFoldingStrategy - implements FoldingStrategy -{ - - // singleton - private static final FoldingStrategy INSTANCE = new LowerCaseFoldingStrategy(); - - /** - * Return the singleton. - */ - static FoldingStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private LowerCaseFoldingStrategy() { - super(); - } - - public String fold(String name) { - return name.toLowerCase(); - } - - public boolean nameIsFolded(String name) { - return StringTools.stringIsLowercase(name); - } - - public boolean normalIdentifiersAreCaseSensitive() { - return false; - } - - @Override - public String toString() { - return ClassTools.toStringClassNameForObject(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/MaxDB.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/MaxDB.java deleted file mode 100644 index 7d0818c7d8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/MaxDB.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -class MaxDB - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new MaxDB(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MaxDB() { - super(); - } - - @Override - public String getDTPVendorName() { - return "MaxDB"; //$NON-NLS-1$ - } - - @Override - CatalogStrategy getCatalogStrategy() { - return UnknownCatalogStrategy.instance(); // not verified yet... - } - - @Override - FoldingStrategy getFoldingStrategy() { - return UpperCaseFoldingStrategy.instance(); - } - - @Override - char[] getExtendedNormalNameStartCharacters() { - return EXTENDED_NORMAL_NAME_START_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_START_CHARACTERS = new char[] { '#', '@', '$' }; - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '_' }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/MySQL.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/MySQL.java deleted file mode 100644 index d0235b9b68..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/MySQL.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; - -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.jpt.utility.internal.StringTools; - -class MySQL - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new MySQL(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MySQL() { - super(); - } - - @Override - public String getDTPVendorName() { - return "MySql"; //$NON-NLS-1$ - } - - /** - * The DTP model for MySQL has a database that contains no catalogs; - * but, instead, directly holds a single schema with the same name as - * the database. (This is hard-coded in MySqlCatalogDatabase.getSchemas().) - * Although you can qualify identifiers with a database name - * in MySQL, only the database specified at login seems to be available - * in the DTP model.... - * - * NB: In MySQL DDL, SCHEMA is a synonym for DATABASE; but the JDBC - * method DatabaseMetaData.getSchemas() returns an empty list, - * while getCatalogs() returns a list of the available databases. - * You can also use the JDBC method Connection.setCatalog(String) to - * set the default database. - */ - @Override - CatalogStrategy getCatalogStrategy() { - return NoCatalogStrategy.instance(); - } - - /** - * MySQL is a bit unusual, so we force exact matches. - * (e.g. MySQL folds database and table names to lowercase on Windows - * by default; but that default can be changed by the - * 'lower_case_table_names' system variable. This is because databases are - * stored as directories and tables are stored as files in the underlying - * O/S; and the case-sensitivity of the names is determined by the behavior - * of filenames on the O/S. Then, to complicate things, - * none of the other identifiers, like index and column names, are folded; - * but they are case-insensitive, unless delimited. See - * http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html.) - */ - @Override - FoldingStrategy getFoldingStrategy() { - return NonFoldingStrategy.instance(); - } - - @Override - void addDefaultSchemaIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(this.convertNameToIdentifier(database.getName())); // hmmm... ~bjv - } - - /** - * MySQL is the only vendor that allows a digit. - * Although, the name cannnot be *all* digits. - */ - @Override - boolean characterIsNormalNameStart(char c) { - return Character.isDigit(c) || super.characterIsNormalNameStart(c); - } - - @Override - char[] getExtendedNormalNameStartCharacters() { - return EXTENDED_NORMAL_NAME_START_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_START_CHARACTERS = new char[] { '_', '$' }; - - /** - * By default, MySQL delimits identifiers with backticks (`); but it - * can also be configured to use double-quotes. - */ - @Override - boolean identifierIsDelimited(String identifier) { - return StringTools.stringIsDelimited(identifier, BACKTICK) - || super.identifierIsDelimited(identifier); - } - private static final char BACKTICK = '`'; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/NoCatalogStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/NoCatalogStrategy.java deleted file mode 100644 index a7fb79d9ba..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/NoCatalogStrategy.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; - -/** - * Catalog strategy for DTP databases that do not have catalogs - * (e.g. MySQL see bug 249013). - */ -class NoCatalogStrategy - implements CatalogStrategy -{ - // singleton - private static final CatalogStrategy INSTANCE = new NoCatalogStrategy(); - - /** - * Return the singleton. - */ - static CatalogStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NoCatalogStrategy() { - super(); - } - - public boolean supportsCatalogs(Database database) { - return false; - } - - public List<Catalog> getCatalogs(Database database) { - return Collections.emptyList(); - } - - @SuppressWarnings("unchecked") - public List<Schema> getSchemas(Database database) { - return database.getSchemas(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/NonFoldingStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/NonFoldingStrategy.java deleted file mode 100644 index e63c1ad71d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/NonFoldingStrategy.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import org.eclipse.jpt.utility.internal.ClassTools; - -/** - * Do not fold "normal" identifiers. - * Respect the case of "normal" identifiers. - */ -class NonFoldingStrategy - implements FoldingStrategy -{ - - // singleton - private static final FoldingStrategy INSTANCE = new NonFoldingStrategy(); - - /** - * Return the singleton. - */ - static FoldingStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NonFoldingStrategy() { - super(); - } - - /** - * Since identifiers are not folded to upper- or lower-case, the name is - * already "folded". - */ - public String fold(String name) { - return name; - } - - /** - * Since identifiers are not folded to upper- or lower-case, the name is - * already "folded". - * (Non-folding databases do not require delimiters around mixed-case - * "normal" identifiers.) - */ - public boolean nameIsFolded(String name) { - return true; - } - - public boolean normalIdentifiersAreCaseSensitive() { - return true; - } - - @Override - public String toString() { - return ClassTools.toStringClassNameForObject(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Oracle.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Oracle.java deleted file mode 100644 index cb04f9f36c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Oracle.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -class Oracle - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new Oracle(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private Oracle() { - super(); - } - - @Override - public String getDTPVendorName() { - return "Oracle"; //$NON-NLS-1$ - } - - @Override - CatalogStrategy getCatalogStrategy() { - return FauxCatalogStrategy.instance(); - } - - @Override - FoldingStrategy getFoldingStrategy() { - return UpperCaseFoldingStrategy.instance(); - } - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '_', '$', '#' }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/PostgreSQL.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/PostgreSQL.java deleted file mode 100644 index 3ecad54899..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/PostgreSQL.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; - -class PostgreSQL - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new PostgreSQL(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private PostgreSQL() { - super(); - } - - @Override - public String getDTPVendorName() { - return "postgres"; //$NON-NLS-1$ - } - - /** - * The PostgreSQL JDBC driver returns a single catalog from the call to - * DatabaseMetaData.getCatalogs() that has the same name as the - * database initially specified by the connection (in the JDBC URL). - * DTP uses this configuration unmodified. Unfortunately, the DTP - * database's name is not the same as the PostgreSQL database's - * name. - */ - @Override - CatalogStrategy getCatalogStrategy() { - return SimpleCatalogStrategy.instance(); - } - - @Override - FoldingStrategy getFoldingStrategy() { - return LowerCaseFoldingStrategy.instance(); - } - - /** - * The PostgreSQL database holds a single catalog that has the same name as - * the database. - */ - @Override - void addDefaultCatalogIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(this.buildDefaultCatalogIdentifier(database)); - } - - private String buildDefaultCatalogIdentifier(Database database) { - return this.convertNameToIdentifier(this.buildDefaultCatalogName(database)); - } - - private String buildDefaultCatalogName(Database database) { - return ((Catalog) database.getCatalogs().get(0)).getName(); - } - - /** - * PostgreSQL has a "schema search path". The default is: - * "$user",public - * If the "$user" schema is not found, use the "public" schema. - */ - @Override - void addDefaultSchemaIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - super.addDefaultSchemaIdentifiersTo(database, userName, identifiers); - identifiers.add(PUBLIC_SCHEMA_IDENTIFIER); - } - private static final String PUBLIC_SCHEMA_IDENTIFIER = "public"; //$NON-NLS-1$ - - @Override - char[] getExtendedNormalNameStartCharacters() { - return EXTENDED_NORMAL_NAME_START_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_START_CHARACTERS = new char[] { '_' }; - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '$' }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/SQLServer.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/SQLServer.java deleted file mode 100644 index c6e597ca82..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/SQLServer.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; - -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.jpt.utility.internal.StringTools; - -class SQLServer - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new SQLServer(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SQLServer() { - super(); - } - - @Override - public String getDTPVendorName() { - return "SQL Server"; //$NON-NLS-1$ - } - - @Override - CatalogStrategy getCatalogStrategy() { - return SimpleCatalogStrategy.instance(); - } - - /** - * By default, SQL Server identifiers are case-sensitive, even without - * delimiters. This can depend on the collation setting.... - */ - @Override - FoldingStrategy getFoldingStrategy() { - return NonFoldingStrategy.instance(); - } - - /** - * SQL Server will use the user-requested database; if that database is not - * found, it will default to 'master'. - */ - @Override - void addDefaultCatalogIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(database.getName()); - identifiers.add(MASTER_CATALOG_IDENTIFIER); - } - private static final String MASTER_CATALOG_IDENTIFIER = "master"; //$NON-NLS-1$ - - /** - * The default schema on SQL Server for any database (catalog) is 'dbo'. - */ - @Override - void addDefaultSchemaIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(DEFAULT_SCHEMA_IDENTIFIER); - } - private static final String DEFAULT_SCHEMA_IDENTIFIER = "dbo"; //$NON-NLS-1$ - - @Override - char[] getExtendedNormalNameStartCharacters() { - return EXTENDED_NORMAL_NAME_START_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_START_CHARACTERS = new char[] { '_', '@', '#' }; - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '$' }; - - /** - * By default, SQL Server delimits identifiers with brackets ([]); but it - * can also be configured to use double-quotes. - */ - @Override - boolean identifierIsDelimited(String identifier) { - return StringTools.stringIsBracketed(identifier) - || super.identifierIsDelimited(identifier); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/SimpleCatalogStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/SimpleCatalogStrategy.java deleted file mode 100644 index 8a1a04129e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/SimpleCatalogStrategy.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; - -/** - * Catalog strategy for DTP databases that simply model the catalogs returned - * by the underlying JDBC driver (e.g. Sybase). - * @see java.sql.DatabaseMetaData#getCatalogs() - */ -class SimpleCatalogStrategy - implements CatalogStrategy -{ - // singleton - private static final CatalogStrategy INSTANCE = new SimpleCatalogStrategy(); - - /** - * Return the singleton. - */ - static CatalogStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SimpleCatalogStrategy() { - super(); - } - - public boolean supportsCatalogs(Database database) { - return true; - } - - @SuppressWarnings("unchecked") - public List<Catalog> getCatalogs(Database database) { - return database.getCatalogs(); - } - - public List<Schema> getSchemas(Database database) { - return Collections.emptyList(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java deleted file mode 100644 index c195d2198a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; - -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.jpt.utility.internal.StringTools; - -class Sybase - extends AbstractVendor -{ - private final String dtpVendorName; - - static final Vendor ASA = new Sybase("Sybase_ASA"); //$NON-NLS-1$ - static final Vendor ASE = new Sybase("Sybase_ASE"); //$NON-NLS-1$ - - static Vendor asa() { - return ASA; - } - - static Vendor ase() { - return ASE; - } - - /** - * Ensure only static instances. - */ - private Sybase(String dtpVendorName) { - super(); - this.dtpVendorName = dtpVendorName; - } - - @Override - public String getDTPVendorName() { - return this.dtpVendorName; - } - - @Override - CatalogStrategy getCatalogStrategy() { - return SimpleCatalogStrategy.instance(); - } - - /** - * By default, Sybase identifiers are case-sensitive, even without - * delimiters. This can depend on the collation setting.... - */ - @Override - FoldingStrategy getFoldingStrategy() { - return NonFoldingStrategy.instance(); - } - - /** - * Sybase will use the user-requested database; if that database is not - * found, it will default to 'master'. - */ - @Override - void addDefaultCatalogIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(database.getName()); - identifiers.add(MASTER_CATALOG_IDENTIFIER); - } - private static final String MASTER_CATALOG_IDENTIFIER = "master"; //$NON-NLS-1$ - - /** - * The typical default schema on Sybase for any database (catalog) is - * 'dbo'. - * - * Actually, the default schema is more like a search path: - * The server looks for a schema object (e.g. a table) first in the user's - * schema, then it looks for the schema object in the database owner's - * schema (dbo). As a result, it's really not possible to specify - * the "default" schema without knowing the schema object we are - * looking for. - * - * (Note: the current 'user' is not the same thing as the current - * 'login' - see sp_adduser and sp_addlogin; so we probably can't - * use ConnectionProfile#getUserName().) - */ - @Override - void addDefaultSchemaIdentifiersTo(Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(DEFAULT_SCHEMA_IDENTIFIER); - } - private static final String DEFAULT_SCHEMA_IDENTIFIER = "dbo"; //$NON-NLS-1$ - - @Override - char[] getExtendedNormalNameStartCharacters() { - return EXTENDED_NORMAL_NAME_START_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_START_CHARACTERS = new char[] { '_', '@' }; - - @Override - char[] getExtendedNormalNamePartCharacters() { - return EXTENDED_NORMAL_NAME_PART_CHARACTERS; - } - private static final char[] EXTENDED_NORMAL_NAME_PART_CHARACTERS = new char[] { '$', '¥', '£', '#' }; - - /** - * By default, Sybase delimits identifiers with brackets ([]); but it - * can also be configured to use double-quotes. - */ - @Override - boolean identifierIsDelimited(String identifier) { - return StringTools.stringIsBracketed(identifier) - || super.identifierIsDelimited(identifier); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UnknownCatalogStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UnknownCatalogStrategy.java deleted file mode 100644 index ea9a729e35..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UnknownCatalogStrategy.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; - -/** - * Catalog strategy for unknown DTP databases. - * @see java.sql.DatabaseMetaData#getCatalogs() - */ -class UnknownCatalogStrategy - implements CatalogStrategy -{ - // singleton - private static final CatalogStrategy INSTANCE = new UnknownCatalogStrategy(); - - /** - * Return the singleton. - */ - static CatalogStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private UnknownCatalogStrategy() { - super(); - } - - @SuppressWarnings("unchecked") - public boolean supportsCatalogs(Database database) { - List<Catalog> catalogs = database.getCatalogs(); - if ((catalogs == null) || catalogs.isEmpty()) { - return false; - } - - return this.getFauxCatalog(catalogs) == null; - } - - @SuppressWarnings("unchecked") - public List<Catalog> getCatalogs(Database database) { - List<Catalog> catalogs = database.getCatalogs(); - // if there are no catalogs, the database must hold the schemata directly - if ((catalogs == null) || catalogs.isEmpty()) { - return Collections.emptyList(); - } - - Catalog fauxCatalog = this.getFauxCatalog(catalogs); - return (fauxCatalog == null) ? catalogs : Collections.<Catalog>emptyList(); - } - - @SuppressWarnings("unchecked") - public List<Schema> getSchemas(Database database) { - List<Catalog> catalogs = database.getCatalogs(); - // if there are no catalogs, the database must hold the schemata directly - if ((catalogs == null) || catalogs.isEmpty()) { - return database.getSchemas(); - } - - Catalog fauxCatalog = this.getFauxCatalog(catalogs); - return (fauxCatalog != null) ? fauxCatalog.getSchemas() : Collections.emptyList(); - } - - private Catalog getFauxCatalog(List<Catalog> catalogs) { - if (catalogs.size() == 1) { - Catalog catalog = catalogs.get(0); - if (catalog.getName().equals("")) { //$NON-NLS-1$ - return catalog; - } - } - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UnrecognizedVendor.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UnrecognizedVendor.java deleted file mode 100644 index f5751232ff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UnrecognizedVendor.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -/** - * - */ -class UnrecognizedVendor - extends AbstractVendor -{ - // singleton - private static final Vendor INSTANCE = new UnrecognizedVendor(); - - /** - * Return the singleton. - */ - static Vendor instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private UnrecognizedVendor() { - super(); - } - - @Override - public String getDTPVendorName() { - return "Unrecognized Vendor"; //$NON-NLS-1$ - } - - /** - * Not sure what to do here.... - * Assume the DTP database is organized into one or more catalogs and - * the schemata are contained by those catalogs. This appears to be the - * default way DTP builds models these days (i.e. a database with at - * least one catalog, instead of the database holding schemata - * directly). - */ - @Override - CatalogStrategy getCatalogStrategy() { - return UnknownCatalogStrategy.instance(); - } - - @Override - FoldingStrategy getFoldingStrategy() { - return UpperCaseFoldingStrategy.instance(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UpperCaseFoldingStrategy.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UpperCaseFoldingStrategy.java deleted file mode 100644 index 748d4dd162..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/UpperCaseFoldingStrategy.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * Fold "normal" identifiers to upper case. - * Ignore the case of "normal" identifiers. - */ -class UpperCaseFoldingStrategy - implements FoldingStrategy -{ - - // singleton - private static final FoldingStrategy INSTANCE = new UpperCaseFoldingStrategy(); - - /** - * Return the singleton. - */ - static FoldingStrategy instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private UpperCaseFoldingStrategy() { - super(); - } - - public String fold(String name) { - return name.toUpperCase(); - } - - public boolean nameIsFolded(String name) { - return StringTools.stringIsUppercase(name); - } - - public boolean normalIdentifiersAreCaseSensitive() { - return false; - } - - @Override - public String toString() { - return ClassTools.toStringClassNameForObject(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Vendor.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Vendor.java deleted file mode 100644 index c73d774eb0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Vendor.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.List; - -import org.eclipse.datatools.modelbase.sql.schema.Catalog; -import org.eclipse.datatools.modelbase.sql.schema.Database; -import org.eclipse.datatools.modelbase.sql.schema.Schema; - -/** - * Delegate vendor-specific behavior to implementations of this interface: - * - catalog support - * - default catalog and schema - * - converting names to identifiers and vice-versa - * - * Note: - * We use "name" when dealing with the unmodified name of a database object - * as supplied by the database itself (i.e. it is not delimited and it is always - * case-sensitive). - * We use "identifier" when dealing with a string representation of a database - * object name (i.e. it may be delimited and, depending on the vendor, it may - * be case-insensitive). - */ -public interface Vendor { - - /** - * This must match the DTP vendor name. - * @see org.eclipse.datatools.modelbase.sql.schema.Database#getVendor() - */ - String getDTPVendorName(); - - /** - * Return whether the vendor supports "real" catalogs (e.g. Sybase). - */ - boolean supportsCatalogs(Database database); - - /** - * Return the specified database's catalogs. - */ - List<Catalog> getCatalogs(Database database); - - /** - * Return the specified database's default catalog identifiers for the - * specified user. - */ - List<String> getDefaultCatalogIdentifiers(Database database, String userName); - - /** - * Return the specified database's schemas. - */ - List<Schema> getSchemas(Database database); - - /** - * Return the specified database's default schema identifiers for the - * specified user. - */ - List<String> getDefaultSchemaIdentifiers(Database database, String userName); - - /** - * Convert the specified database object name to a vendor identifier. - * Return null if the identifier matches the specified default name. - */ - String convertNameToIdentifier(String name, String defaultName); - - /** - * Convert the specified database object name to a vendor identifier. - */ - String convertNameToIdentifier(String name); - - /** - * Convert the specified database object identifier to a vendor name. - */ - String convertIdentifierToName(String identifier); - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/VendorRepository.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/VendorRepository.java deleted file mode 100644 index 468f09ea44..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/VendorRepository.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.db.internal.vendor; - -import java.util.ArrayList; -import java.util.Iterator; - -public class VendorRepository { - private final Vendor[] vendors; - - // singleton - private static final VendorRepository INSTANCE = new VendorRepository(); - - /** - * Return the singleton. - */ - public static VendorRepository instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private VendorRepository() { - super(); - this.vendors = this.buildVendors(); - } - - private Vendor[] buildVendors() { - ArrayList<Vendor> list = new ArrayList<Vendor>(); - this.addVendorsTo(list); - return list.toArray(new Vendor[list.size()]); - } - - private void addVendorsTo(ArrayList<Vendor> list) { - this.addVendorTo(DB2.udb(), list); - this.addVendorTo(DB2.udbISeries(), list); - this.addVendorTo(DB2.udbZSeries(), list); - this.addVendorTo(Derby.instance(), list); - this.addVendorTo(HSQLDB.instance(), list); - this.addVendorTo(Informix.instance(), list); - this.addVendorTo(MaxDB.instance(), list); - this.addVendorTo(MySQL.instance(), list); - this.addVendorTo(Oracle.instance(), list); - this.addVendorTo(PostgreSQL.instance(), list); - this.addVendorTo(SQLServer.instance(), list); - this.addVendorTo(Sybase.asa(), list); - this.addVendorTo(Sybase.ase(), list); - } - - private void addVendorTo(Vendor vendor, ArrayList<Vendor> list) { - String name = vendor.getDTPVendorName(); - for (Iterator<Vendor> stream = list.iterator(); stream.hasNext(); ) { - if (stream.next().getDTPVendorName().equals(name)) { - throw new IllegalArgumentException("Duplicate vendor: " + name); //$NON-NLS-1$ - } - } - list.add(vendor); - } - - public Vendor getVendor(String dtpVendorName) { - for (int i = this.vendors.length; i-- > 0;) { - Vendor vendor = this.vendors[i]; - if (vendor.getDTPVendorName().equals(dtpVendorName)) { - return vendor; - } - } - return UnrecognizedVendor.instance(); - } - -} |