Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorbvosburgh2007-05-04 14:57:09 +0000
committerbvosburgh2007-05-04 14:57:09 +0000
commita4e8a2c43e075adc823250df753a9957465339cb (patch)
treed9a3fe15dfa09dbf7f57e4ab339d4ae9eac78fdd /jpa
parent38f339b6dbe8ee73e6bb841f929f74169aca19d8 (diff)
downloadwebtools.dali-a4e8a2c43e075adc823250df753a9957465339cb.tar.gz
webtools.dali-a4e8a2c43e075adc823250df753a9957465339cb.tar.xz
webtools.dali-a4e8a2c43e075adc823250df753a9957465339cb.zip
converted to JDK 5 stuff
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java49
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java98
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java65
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java106
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java7
24 files changed, 464 insertions, 329 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java
index 4097b08014..2278497b80 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java
@@ -1,28 +1,29 @@
/*******************************************************************************
* Copyright (c) 2007 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.
- *
+ * 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;
import java.text.Collator;
-import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
+import org.eclipse.emf.common.util.EList;
/**
* Wrap a DTP Catalogs
*/
-final class Catalog extends DTPWrapper {
+final class Catalog extends DTPWrapper implements Comparable<Catalog> {
private final Database database;
- private final org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog;
+ final org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog;
+ @SuppressWarnings("unused")
private ICatalogObjectListener catalogListener; //TODO listen for change
// ********** constructors **********
@@ -35,10 +36,12 @@ final class Catalog extends DTPWrapper {
// ********** behavior **********
+ @Override
protected boolean connectionIsOnline() {
return this.database.connectionIsOnline();
}
+ @SuppressWarnings("unused")
private ICatalogObjectListener buildCatalogListener() {
return new ICatalogObjectListener() {
public void notifyChanged( final ICatalogObject catalog, final int eventType) {
@@ -50,16 +53,18 @@ final class Catalog extends DTPWrapper {
};
}
+ @Override
protected void dispose() {
// this.removeCatalogObjectListener(( ICatalogObject) this.dtpCatalog, this.catalogListener);
}
- boolean wraps( org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog) {
- return this.dtpCatalog == dtpCatalog;
+ boolean wraps( org.eclipse.datatools.modelbase.sql.schema.Catalog catalog) {
+ return this.dtpCatalog == catalog;
}
// ********** queries **********
+ @Override
public String getName() {
return this.dtpCatalog.getName();
}
@@ -74,12 +79,13 @@ final class Catalog extends DTPWrapper {
// ***** schemata
- synchronized Set buildSchemata() {
- Collection dtpSchemata = this.dtpCatalog.getSchemas();
+ @SuppressWarnings("unchecked")
+ synchronized Set<Schema> buildSchemata() {
+ EList<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata = this.dtpCatalog.getSchemas();
- Set result = new HashSet( dtpSchemata.size());
- for( Iterator i = dtpSchemata.iterator(); i.hasNext(); ) {
- result.add( this.wrap(( org.eclipse.datatools.modelbase.sql.schema.Schema)i.next()));
+ Set<Schema> result = new HashSet<Schema>( dtpSchemata.size());
+ for (org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema : dtpSchemata) {
+ result.add( this.wrap(dtpSchema));
}
return result;
}
@@ -91,8 +97,8 @@ final class Catalog extends DTPWrapper {
// ********** Comparable implementation **********
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( Catalog)o).getName());
+ public int compareTo( Catalog catalog) {
+ return Collator.getInstance().compare( this.getName(), catalog.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java
index 54ff56f94f..298c7ae6a8 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java
@@ -1,15 +1,16 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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;
import java.text.Collator;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
import org.eclipse.datatools.modelbase.sql.datatypes.DataType;
@@ -20,7 +21,7 @@ import org.eclipse.jpt.utility.internal.NameTools;
/**
* Wrap a DTP Column
*/
-public final class Column extends DTPWrapper {
+public final class Column extends DTPWrapper implements Comparable<Column> {
private final Table table;
private final org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn;
private ICatalogObjectListener columnListener;
@@ -46,6 +47,7 @@ public final class Column extends DTPWrapper {
}
}
+ @Override
protected boolean connectionIsOnline() {
return this.table.connectionIsOnline();
}
@@ -61,6 +63,7 @@ public final class Column extends DTPWrapper {
};
}
+ @Override
protected void dispose() {
this.removeCatalogObjectListener(( ICatalogObject) this.dtpColumn, this.columnListener);
@@ -68,6 +71,7 @@ public final class Column extends DTPWrapper {
// ********** queries **********
+ @Override
public String getName() {
return this.dtpColumn.getName();
}
@@ -122,8 +126,8 @@ public final class Column extends DTPWrapper {
// ********** Comparable implementation **********
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( Column)o).getName());
+ public int compareTo( Column column) {
+ return Collator.getInstance().compare( this.getName(), column.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java
index e3ce55897c..3e1e7365db 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -15,7 +15,7 @@ import java.text.Collator;
/**
* Connection wrapper base class.
*/
-public abstract class Connection extends DTPWrapper {
+public abstract class Connection extends DTPWrapper implements Comparable<Connection> {
// ********** constructors **********
@@ -52,14 +52,15 @@ public abstract class Connection extends DTPWrapper {
public abstract String getFactoryId();
+ @Override
protected boolean connectionIsOnline() {
return this.isConnected();
}
// ********** Comparable implementation **********
- public int compareTo(Object o) {
- return Collator.getInstance().compare( this.getName(), ((Connection)o).getName());
+ public int compareTo(Connection connection) {
+ return Collator.getInstance().compare( this.getName(), connection.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java
index 32528cf083..d778cbb1e4 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java
index 6016824c5e..96f2597932 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -11,12 +11,13 @@ package org.eclipse.jpt.db.internal;
import java.text.Collator;
import java.util.NoSuchElementException;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
/**
* ConnectionProfile wrapper base class.
*/
-public abstract class ConnectionProfile extends DTPWrapper {
+public abstract class ConnectionProfile extends DTPWrapper implements Comparable<ConnectionProfile> {
private Connection connection; // Lazy initialized
private Database database; // Lazy initialized
@@ -49,19 +50,20 @@ public abstract class ConnectionProfile extends DTPWrapper {
protected abstract Database buildDatabase();
- abstract void databaseChanged( Database database, int eventType);
+ abstract void databaseChanged( Database db, int eventType);
- abstract void catalogChanged( Catalog catalog, Database database, int eventType);
+ abstract void catalogChanged( Catalog catalog, Database db, int eventType);
- abstract void schemaChanged( Schema schema, Database database, int eventType);
+ abstract void schemaChanged( Schema schema, Database db, int eventType);
- abstract void tableChanged( Table table, Schema schema, Database database, int eventType);
+ abstract void tableChanged( Table table, Schema schema, Database db, int eventType);
protected void refreshDatabase() {
this.disposeDatabase();
this.database = null;
}
+ @Override
protected void dispose() {
this.disengageConnectionListener();
@@ -118,6 +120,7 @@ public abstract class ConnectionProfile extends DTPWrapper {
public abstract boolean isConnected();
+ @Override
protected boolean connectionIsOnline() {
return this.isConnected();
}
@@ -180,39 +183,39 @@ public abstract class ConnectionProfile extends DTPWrapper {
private ConnectionListener buildConnectionListener() {
return new ConnectionListener() {
- public void aboutToClose(Connection connection) {
+ public void aboutToClose(Connection c) {
// not interested to this event.
}
- public void closed(Connection connection) {
+ public void closed(Connection c) {
ConnectionProfile.this.refreshDatabase();
- }
+ }
- public void modified(Connection connection) {
+ public void modified(Connection c) {
// not interested to this event.
return;
- }
+ }
- public boolean okToClose(Connection connection) {
+ public boolean okToClose(Connection c) {
// not interested to this event.
return true;
}
- public void opened(Connection connection) {
+ public void opened(Connection c) {
ConnectionProfile.this.refreshDatabase();
}
- public void databaseChanged(Connection connection, final Database database) {
+ public void databaseChanged(Connection c, final Database db) {
// not interested to this event.
return;
- }
+ }
- public void schemaChanged(Connection connection, final Schema schema) {
+ public void schemaChanged(Connection c, final Schema schema) {
// not interested to this event.
return;
- }
+ }
- public void tableChanged(Connection connection, final Table table) {
+ public void tableChanged(Connection c, final Table table) {
// not interested to this event.
return;
}
@@ -237,8 +240,8 @@ public abstract class ConnectionProfile extends DTPWrapper {
// ********** Comparable implementation **********
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( ConnectionProfile)o).getName());
+ public int compareTo( ConnectionProfile connectionProfile) {
+ return Collator.getInstance().compare( this.getName(), connectionProfile.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java
index e23c37572c..25e7ea7acd 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -27,7 +27,7 @@ public class ConnectionProfileRepository {
private LocalRepositoryListener repositoryListener;
private LocalProfileListener profileListener;
- private Set profiles;
+ private Set<ConnectionProfile> profiles;
private static ConnectionProfileRepository INSTANCE;
@@ -65,8 +65,8 @@ public class ConnectionProfileRepository {
}
public void disposeListeners() {
- for( Iterator i = profiles(); i.hasNext(); ) {
- (( ConnectionProfile) i.next()).dispose();
+ for( Iterator<ConnectionProfile> stream = this.profiles(); stream.hasNext(); ) {
+ stream.next().dispose();
}
if( this.repositoryListener != null) {
this.dtpProfileManager.removeProfileListener( this.repositoryListener);
@@ -83,27 +83,29 @@ public class ConnectionProfileRepository {
}
+ @Override
public String toString() {
return this.profiles.toString();
}
// ********** profiles
- public Iterator profiles() {
+ public Iterator<ConnectionProfile> profiles() {
return this.getProfiles().iterator();
}
- public Iterator profileNames() {
- return new TransformationIterator( this.profiles()) {
- protected Object transform( Object next) {
- return (( ConnectionProfile)next).getName();
+ public Iterator<String> profileNames() {
+ return new TransformationIterator<ConnectionProfile, String>( this.profiles()) {
+ @Override
+ protected String transform( ConnectionProfile profile) {
+ return profile.getName();
}
};
}
public ConnectionProfile profileNamed( String name) {
- for( Iterator stream = this.profiles(); stream.hasNext(); ) {
- ConnectionProfile profile = ( ConnectionProfile) stream.next();
+ for( Iterator<ConnectionProfile> stream = this.profiles(); stream.hasNext(); ) {
+ ConnectionProfile profile = stream.next();
if( profile.getName().equals( name)) {
return profile;
}
@@ -111,7 +113,7 @@ public class ConnectionProfileRepository {
return NullConnectionProfile.instance();
}
- private Set getProfiles() {
+ private Set<ConnectionProfile> getProfiles() {
if( this.profiles == null) {
this.profiles = this.buildProfiles();
@@ -119,16 +121,16 @@ public class ConnectionProfileRepository {
return this.profiles;
}
- private Set buildProfiles() {
- IConnectionProfile[] profiles = this.dtpProfileManager.getProfiles();
- Set result = new HashSet( profiles.length);
- for( int i = profiles.length; i-- > 0; ) {
- result.add( ConnectionProfile.createProfile( this, profiles[i]));
+ private Set<ConnectionProfile> buildProfiles() {
+ IConnectionProfile[] dtpProfiles = this.dtpProfileManager.getProfiles();
+ Set<ConnectionProfile> result = new HashSet<ConnectionProfile>( dtpProfiles.length);
+ for (IConnectionProfile dtpProfile : dtpProfiles) {
+ result.add( ConnectionProfile.createProfile( this, dtpProfile));
}
return result;
}
- private void addProfile( IConnectionProfile dtpProfile) {
+ void addProfile( IConnectionProfile dtpProfile) {
if( !this.profileExists( dtpProfile)) {
ConnectionProfile newProfile = ConnectionProfile.createProfile( ConnectionProfileRepository.this, dtpProfile);
@@ -136,7 +138,7 @@ public class ConnectionProfileRepository {
}
}
- private void removeProfile( IConnectionProfile dtpProfile) {
+ void removeProfile( IConnectionProfile dtpProfile) {
this.profiles.remove( this.getProfile( dtpProfile));
}
@@ -146,10 +148,10 @@ public class ConnectionProfileRepository {
return ( this.getProfile( dtpProfile) == null) ? false : true;
}
- private ConnectionProfile getProfile( IConnectionProfile dtpProfile) {
+ ConnectionProfile getProfile( IConnectionProfile dtpProfile) {
- for( Iterator i = this.profiles(); i.hasNext(); ) {
- ConnectionProfile profile = ( ConnectionProfile)i.next();
+ for( Iterator<ConnectionProfile> stream = this.profiles(); stream.hasNext(); ) {
+ ConnectionProfile profile = stream.next();
if( profile.wraps( dtpProfile)) {
return profile;
}
@@ -169,11 +171,13 @@ public class ConnectionProfileRepository {
this.profileListener.removeProfileListener( listener);
}
+ @SuppressWarnings("unused")
private void addInternalProfileListener( IProfileListener listener) {
this.dtpProfileManager.addProfileListener( listener);
}
+ @SuppressWarnings("unused")
private void removeInternalProfileListener( IProfileListener listener) {
this.dtpProfileManager.removeProfileListener( listener);
@@ -185,6 +189,10 @@ public class ConnectionProfileRepository {
*/
private class LocalRepositoryListener implements IProfileListener {
+ LocalRepositoryListener() {
+ super();
+ }
+
public void profileAdded( IConnectionProfile connectionProfile) {
ConnectionProfileRepository.this.addProfile( connectionProfile);
}
@@ -203,7 +211,11 @@ public class ConnectionProfileRepository {
* This listener translates and forwards IProfileListener events to ProfileListener.
*/
private class LocalProfileListener implements IProfileListener {
- private Collection listeners = new ArrayList();
+ private Collection<ProfileListener> listeners = new ArrayList<ProfileListener>();
+
+ LocalProfileListener() {
+ super();
+ }
void addProfileListener( ProfileListener listener) {
this.listeners.add( listener);
@@ -217,22 +229,22 @@ public class ConnectionProfileRepository {
public void profileAdded( IConnectionProfile dtpProfile) {
ConnectionProfile profile = getProfile( dtpProfile);
- for( Iterator j = listeners.iterator(); j.hasNext(); ) {
- (( ProfileListener)j.next()).profileAdded( profile);
+ for (ProfileListener listener : this.listeners) {
+ listener.profileAdded( profile);
}
}
public void profileChanged( IConnectionProfile dtpProfile) {
ConnectionProfile profile = getProfile( dtpProfile);
- for( Iterator j = listeners.iterator(); j.hasNext(); ) {
- (( ProfileListener)j.next()).profileChanged( profile);
+ for (ProfileListener listener : this.listeners) {
+ listener.profileChanged( profile);
}
}
public void profileDeleted( IConnectionProfile dtpProfile) {
String profileName = dtpProfile.getName();
- for( Iterator j = listeners.iterator(); j.hasNext(); ) {
- (( ProfileListener)j.next()).profileDeleted( profileName);
+ for (ProfileListener listener : this.listeners) {
+ listener.profileDeleted( profileName);
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java
index f570999001..6af2adc285 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -52,21 +52,25 @@ public final class DTPConnectionProfileWrapper extends ConnectionProfile {
// ********** listeners **********
+ @Override
public void addProfileListener( ProfileListener listener) {
this.getProfileRepository().addProfileListener( listener);
}
+ @Override
public void removeProfileListener( ProfileListener listener) {
this.getProfileRepository().removeProfileListener( listener);
}
+ @Override
public void addConnectionListener( ConnectionListener listener) {
this.getConnection().addConnectionListener( listener);
}
+ @Override
public void removeConnectionListener( ConnectionListener listener) {
this.getConnection().removeConnectionListener( listener);
@@ -80,6 +84,7 @@ public final class DTPConnectionProfileWrapper extends ConnectionProfile {
/**
* Connect using this profile.
*/
+ @Override
public void connect() {
if( !this.dtpConnectionProfile.isConnected()) {
@@ -89,13 +94,12 @@ public final class DTPConnectionProfileWrapper extends ConnectionProfile {
IStatus[] statusChildren = status.getChildren();
throw new RuntimeException( statusChildren[ 0].getMessage(), statusChildren[ 0].getException());
}
- else {
- throw new RuntimeException( status.getMessage(), status.getException());
- }
+ throw new RuntimeException( status.getMessage(), status.getException());
}
}
}
+ @Override
public void disconnect() {
IStatus status = this.dtpConnectionProfile.disconnect();
@@ -104,71 +108,83 @@ public final class DTPConnectionProfileWrapper extends ConnectionProfile {
IStatus[] statusChildren = status.getChildren();
throw new RuntimeException( statusChildren[ 0].getMessage(), statusChildren[ 0].getException());
}
- else {
- throw new RuntimeException( status.getMessage(), status.getException());
- }
+ throw new RuntimeException( status.getMessage(), status.getException());
}
}
+ @Override
void databaseChanged( Database database, int eventType) {
this.getConnection().databaseChanged( database, eventType);
return;
}
+ @Override
void catalogChanged( Catalog catalog, Database database, int eventType) {
//TODO
// this.getConnection().catalogChanged( catalog, eventType);
return;
}
+ @Override
void schemaChanged( Schema schema, Database database, int eventType) {
this.getConnection().schemaChanged( schema, database, eventType);
}
+ @Override
void tableChanged( Table table, Schema schema, Database database, int eventType) {
this.getConnection().tableChanged( table, schema, database, eventType);
}
// ********** queries **********
+ @Override
public boolean isConnected() {
return this.getConnection().isConnected();
}
+ @Override
public boolean isNull() {
return false;
}
+ @Override
public String getName() {
return this.dtpConnectionProfile.getName();
}
+ @Override
public String getDatabaseName() {
return this.getProperties().getProperty( IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID);
}
+ @Override
public String getDatabaseProduct() {
return this.getProperties().getProperty( DATABASE_PRODUCT_PROPERTY);
}
+ @Override
public String getDatabaseVendor() {
return this.getProperties().getProperty( IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
}
+ @Override
public String getDatabaseVersion() {
return this.getProperties().getProperty( IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
}
+ @Override
public String getUserName() {
return this.getProperties().getProperty( IDBDriverDefinitionConstants.USERNAME_PROP_ID);
}
+ @Override
public String getInstanceId() {
return this.dtpConnectionProfile.getInstanceID();
}
+ @Override
public String getProviderId() {
return this.dtpConnectionProfile.getProviderId();
}
@@ -177,12 +193,14 @@ public final class DTPConnectionProfileWrapper extends ConnectionProfile {
return this.dtpConnectionProfile.getBaseProperties();
}
+ @Override
protected Connection buildConnection() {
Connection connection = Connection.createConnection( this.buildDtpManagedConnection( this.dtpConnectionProfile)); //$NON-NLS-1$
return connection;
}
+ @Override
protected Database buildDatabase() {
org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase;
@@ -190,11 +208,10 @@ public final class DTPConnectionProfileWrapper extends ConnectionProfile {
dtpDatabase = ProfileUtil.getDatabase( new DatabaseIdentifier( this.getName(), this.getDatabaseName()), false);
return Database.createDatabase( this, dtpDatabase);
}
- else {
- return NullDatabase.instance();
- }
+ return NullDatabase.instance();
}
+ @Override
boolean wraps( org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile) {
return this.dtpConnectionProfile == dtpProfile;
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java
index 3454754994..5440b35e3f 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java
@@ -1,17 +1,17 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
+
import org.eclipse.datatools.connectivity.ConnectEvent;
import org.eclipse.datatools.connectivity.IManagedConnectionListener;
@@ -38,35 +38,42 @@ public final class DTPConnectionWrapper extends Connection {
this.dtpConnection.addConnectionListener( this.connectionListener);
}
+ @Override
protected void dispose() {
this.dtpConnection.removeConnectionListener( this.connectionListener);
}
+ @Override
public String getName() {
return this.dtpConnection.getConnection().getConnectionProfile().getName();
}
+ @Override
public boolean isConnected() {
return this.dtpConnection.isConnected();
}
+ @Override
public String getFactoryId() {
return this.dtpConnection.getFactoryID();
}
+ @Override
void databaseChanged( Database database, int eventType) {
this.connectionListener.databaseChanged( database, eventType);
}
+ @Override
void schemaChanged( Schema schema, Database database, int eventType) {
this.connectionListener.schemaChanged( schema, database, eventType);
}
+ @Override
void tableChanged( Table table, Schema schema, Database database, int eventType) {
this.connectionListener.tableChanged( table, schema, database, eventType);
@@ -74,11 +81,13 @@ public final class DTPConnectionWrapper extends Connection {
// ********** listeners **********
+ @Override
public void addConnectionListener( ConnectionListener listener) {
// hook up the specified listener to our intermediate listeners
this.connectionListener.addConnectionListener( listener);
}
+ @Override
public void removeConnectionListener( ConnectionListener listener) {
this.connectionListener.removeConnectionListener( listener);
@@ -90,7 +99,11 @@ public final class DTPConnectionWrapper extends Connection {
* This listener translates and forwards IManagedConnectionListener events to ConnectionListeners.
*/
private class LocalConnectionListener implements IManagedConnectionListener {
- private Collection listeners = new Vector();
+ private Collection<ConnectionListener> listeners = new ArrayList<ConnectionListener>();
+
+ LocalConnectionListener() {
+ super();
+ }
void addConnectionListener( ConnectionListener listener) {
this.listeners.add( listener);
@@ -103,26 +116,26 @@ public final class DTPConnectionWrapper extends Connection {
// ********** behavior **********
public void aboutToClose( ConnectEvent event) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).aboutToClose( DTPConnectionWrapper.this);
+ for (ConnectionListener listener : this.listeners) {
+ listener.aboutToClose( DTPConnectionWrapper.this);
}
}
public void closed( ConnectEvent event) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).closed( DTPConnectionWrapper.this);
+ for (ConnectionListener listener : this.listeners) {
+ listener.closed( DTPConnectionWrapper.this);
}
}
public void modified( ConnectEvent event) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).modified( DTPConnectionWrapper.this);
+ for (ConnectionListener listener : this.listeners) {
+ listener.modified( DTPConnectionWrapper.this);
}
}
public boolean okToClose( ConnectEvent event) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- if( !(( ConnectionListener)i.next()).okToClose( DTPConnectionWrapper.this)) {
+ for (ConnectionListener listener : this.listeners) {
+ if( !listener.okToClose( DTPConnectionWrapper.this)) {
return false;
}
}
@@ -130,26 +143,26 @@ public final class DTPConnectionWrapper extends Connection {
}
public void opened( ConnectEvent event) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).opened( DTPConnectionWrapper.this);
+ for (ConnectionListener listener : this.listeners) {
+ listener.opened( DTPConnectionWrapper.this);
}
}
void databaseChanged( Database database, int eventType) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).databaseChanged( DTPConnectionWrapper.this, database);
+ for (ConnectionListener listener : this.listeners) {
+ listener.databaseChanged( DTPConnectionWrapper.this, database);
}
}
void schemaChanged( Schema schema, Database database, int eventType) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).schemaChanged( DTPConnectionWrapper.this, schema);
+ for (ConnectionListener listener : this.listeners) {
+ listener.schemaChanged( DTPConnectionWrapper.this, schema);
}
}
void tableChanged( Table table, Schema schema, Database database, int eventType) {
- for( Iterator i = listeners.iterator(); i.hasNext(); ) {
- (( ConnectionListener)i.next()).tableChanged( DTPConnectionWrapper.this, table);
+ for (ConnectionListener listener : this.listeners) {
+ listener.tableChanged( DTPConnectionWrapper.this, table);
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java
index aa3bd9f19f..c35b6b1366 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -12,9 +12,9 @@ package org.eclipse.jpt.db.internal;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
import org.eclipse.emf.common.util.EList;
@@ -24,12 +24,12 @@ import org.eclipse.emf.common.util.EList;
*/
public final class DTPDatabaseWrapper extends Database {
- final private ConnectionProfile profile;
- final private org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase;
+ final ConnectionProfile profile;
+ final org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase;
private ICatalogObjectListener databaseListener;
- private Set catalogs; // lazy-initialized
- private Set schemata; // lazy-initialized
+ private Set<Catalog> catalogs; // lazy-initialized
+ private Set<Schema> schemata; // lazy-initialized
DTPDatabaseWrapper( ConnectionProfile profile, org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase) {
super();
@@ -48,6 +48,7 @@ public final class DTPDatabaseWrapper extends Database {
}
}
+ @Override
protected boolean connectionIsOnline() {
return this.profile.isConnected();
}
@@ -63,6 +64,7 @@ public final class DTPDatabaseWrapper extends Database {
};
}
+ @Override
void refresh() {
this.disposeSchemata();
this.disposeCatalogs();
@@ -71,21 +73,25 @@ public final class DTPDatabaseWrapper extends Database {
this.catalogs = null;
}
+ @Override
void catalogChanged( Catalog catalog, int eventType) {
this.profile.catalogChanged( catalog, this, eventType);
return;
}
+ @Override
void schemaChanged( Schema schema, int eventType) {
this.profile.schemaChanged( schema, this, eventType);
return;
}
+ @Override
void tableChanged( Table table, Schema schema, int eventType) {
this.profile.tableChanged( table, schema, this, eventType);
return;
}
+ @Override
protected void dispose() {
this.removeCatalogObjectListener(( ICatalogObject) this.dtpDatabase, this.databaseListener);
@@ -95,32 +101,35 @@ public final class DTPDatabaseWrapper extends Database {
private void disposeSchemata() {
if( this.schemata != null) {
- for( Iterator i = this.schemata(); i.hasNext(); ) {
- (( Schema)i.next()).dispose();
+ for( Iterator<Schema> stream = this.schemata(); stream.hasNext(); ) {
+ stream.next().dispose();
}
}
}
private void disposeCatalogs() {
if( this.catalogs != null) {
- for( Iterator i = this.catalogs(); i.hasNext(); ) {
- (( Catalog)i.next()).dispose();
+ for( Iterator<Catalog> stream = this.catalogs(); stream.hasNext(); ) {
+ stream.next().dispose();
}
}
}
// ********** queries **********
+ @Override
public String getName() {
return this.dtpDatabase.getName();
}
+ @Override
public String getVendor() {
return this.dtpDatabase.getVendor();
}
+ @Override
public String getVersion() {
return this.dtpDatabase.getVersion();
@@ -129,23 +138,25 @@ public final class DTPDatabaseWrapper extends Database {
// ***** schemata
- synchronized Set getSchemata() {
+ @Override
+ synchronized Set<Schema> getSchemata() {
if( this.schemata == null) {
this.schemata = this.buildSchemata();
}
return this.schemata;
}
- private Set buildSchemata() {
- Set result;
+ @SuppressWarnings("unchecked")
+ private Set<Schema> buildSchemata() {
+ Set<Schema> result;
if( this.supportsCatalogs()) {
result = this.getSchemataForCatalogNamed( this.profile.getCatalogName());
}
else {
- EList dtpSchemata = this.dtpDatabase.getSchemas();
- result = new HashSet( dtpSchemata.size());
- for( Iterator i = dtpSchemata.iterator(); i.hasNext(); ) {
- result.add( this.wrap(( org.eclipse.datatools.modelbase.sql.schema.Schema)i.next()));
+ EList<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata = this.dtpDatabase.getSchemas();
+ result = new HashSet<Schema>( dtpSchemata.size());
+ for (org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema : dtpSchemata) {
+ result.add( this.wrap(dtpSchema));
}
}
return result;
@@ -153,58 +164,57 @@ public final class DTPDatabaseWrapper extends Database {
// ***** catalogs
+ @SuppressWarnings("unchecked")
+ @Override
public boolean supportsCatalogs() {
- EList schemata = this.dtpDatabase.getSchemas();
- return ( schemata == null || schemata.size() == 0);
+ EList<org.eclipse.datatools.modelbase.sql.schema.Schema> dtpSchemata = this.dtpDatabase.getSchemas();
+ return ( dtpSchemata == null || dtpSchemata.size() == 0);
}
+ @SuppressWarnings("unchecked")
@Override
public String getDefaultCatalogName() {
if( !this.supportsCatalogs()) { // this database doesn't support catalogs
return "";
}
- else {
- String userName = this.profile.getUserName();
- List dtpCatalogs = this.dtpDatabase.getCatalogs();
- for( Iterator i = dtpCatalogs.iterator(); i.hasNext(); ) {
- org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog = ( org.eclipse.datatools.modelbase.sql.schema.Catalog)i.next();
- if( dtpCatalog.getName().length() == 0) { // special catalog that contains all schemata
- return "";
- }
- else if( dtpCatalog.getName().equals( userName)) {
- return userName; // returns user name as default catalog
- }
+ String userName = this.profile.getUserName();
+ for (org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog : (EList<org.eclipse.datatools.modelbase.sql.schema.Catalog>) this.dtpDatabase.getCatalogs()) {
+ if( dtpCatalog.getName().length() == 0) { // special catalog that contains all schemata
+ return "";
+ }
+ else if( dtpCatalog.getName().equals( userName)) {
+ return userName; // returns user name as default catalog
}
- throw new NoSuchElementException();
}
+ throw new NoSuchElementException();
}
- synchronized Set getCatalogs() {
+ @Override
+ synchronized Set<Catalog> getCatalogs() {
if( this.catalogs == null) {
this.catalogs = this.buildCatalogs();
}
return this.catalogs;
}
- private Set buildCatalogs() {
+ @SuppressWarnings("unchecked")
+ private Set<Catalog> buildCatalogs() {
- EList dtpCatalogs = this.dtpDatabase.getCatalogs();
+ EList<org.eclipse.datatools.modelbase.sql.schema.Catalog> dtpCatalogs = this.dtpDatabase.getCatalogs();
if( dtpCatalogs == null) {
return Collections.emptySet();
}
- Set result = new HashSet( dtpCatalogs.size());
- for( Iterator i = dtpCatalogs.iterator(); i.hasNext(); ) {
- result.add( this.wrap(( org.eclipse.datatools.modelbase.sql.schema.Catalog)i.next()));
+ Set<Catalog> result = new HashSet<Catalog>( dtpCatalogs.size());
+ for (org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog : dtpCatalogs) {
+ result.add( this.wrap(dtpCatalog));
}
return result;
}
- //TODO case insensitive search
- //
- private Set getSchemataForCatalogNamed( String catalogName) {
+ private Set<Schema> getSchemataForCatalogNamed( String catalogName) {
Catalog catalog = this.catalogNamed( catalogName);
- return ( catalog != null) ? catalog.buildSchemata() : Collections.emptySet();
+ return ( catalog != null) ? catalog.buildSchemata() : Collections.<Schema>emptySet();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java
index c16a56cd56..eb42269309 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -73,23 +73,23 @@ public final class DTPTools {
/**
* Primitive => JDBC type mappings, keyed by Primitive type name (e.g. "CHARACTER_VARYING")
*/
- private static HashMap PRIMITIVE_TO_JDBC_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized
+ private static HashMap<String, PrimitiveToJDBCTypeMapping> PRIMITIVE_TO_JDBC_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized
private static final JDBCType DEFAULT_JDBC_TYPE = JDBCType.type(Types.VARCHAR); // TODO VARCHAR is the default?
private static PrimitiveToJDBCTypeMapping primitiveToJDBCTypeMapping(String primitiveTypeName) {
- return (PrimitiveToJDBCTypeMapping) primitiveToJDBCTypeMappings().get(primitiveTypeName);
+ return primitiveToJDBCTypeMappings().get(primitiveTypeName);
}
- private static synchronized HashMap primitiveToJDBCTypeMappings() {
+ private static synchronized HashMap<String, PrimitiveToJDBCTypeMapping> primitiveToJDBCTypeMappings() {
if (PRIMITIVE_TO_JDBC_TYPE_MAPPINGS == null) {
PRIMITIVE_TO_JDBC_TYPE_MAPPINGS = buildPrimitiveToJDBCTypeMappings();
}
return PRIMITIVE_TO_JDBC_TYPE_MAPPINGS;
}
- private static HashMap buildPrimitiveToJDBCTypeMappings() {
- HashMap mappings = new HashMap();
+ private static HashMap<String, PrimitiveToJDBCTypeMapping> buildPrimitiveToJDBCTypeMappings() {
+ HashMap<String, PrimitiveToJDBCTypeMapping> mappings = new HashMap<String, PrimitiveToJDBCTypeMapping>();
addPrimitiveToJDBCTypeMappingsTo(mappings);
return mappings;
}
@@ -100,7 +100,7 @@ public final class DTPTools {
* pretty much a straight one-to-one mapping based on similar names;
* TODO some JDBC types are missing: INTERVAL, XML_TYPE
*/
- private static void addPrimitiveToJDBCTypeMappingsTo(HashMap mappings) {
+ private static void addPrimitiveToJDBCTypeMappingsTo(HashMap<String, PrimitiveToJDBCTypeMapping> mappings) {
addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BIGINT_LITERAL, Types.BIGINT, mappings);
addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BINARY_LARGE_OBJECT_LITERAL, Types.BLOB, mappings);
addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BINARY_LITERAL, Types.BINARY, mappings);
@@ -127,7 +127,7 @@ public final class DTPTools {
addPrimitiveToJDBCTypeMappingTo(PrimitiveType.XML_TYPE_LITERAL, Types.OTHER, mappings); // ???
}
- private static void addPrimitiveToJDBCTypeMappingTo(PrimitiveType primitiveType, int jdbcTypeCode, HashMap mappings) {
+ private static void addPrimitiveToJDBCTypeMappingTo(PrimitiveType primitiveType, int jdbcTypeCode, HashMap<String, PrimitiveToJDBCTypeMapping> mappings) {
// check for duplicates
Object prev = mappings.put(primitiveType.getName(), buildPrimitiveToJDBCTypeMapping(primitiveType, jdbcTypeCode));
if (prev != null) {
@@ -186,6 +186,7 @@ public final class DTPTools {
return this.primitiveType.getValue() == primitiveTypeCode;
}
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
this.appendTo(sb);
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java
index 62ad0b4d0f..11e9808ec6 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -17,7 +17,7 @@ import org.eclipse.jpt.utility.internal.StringTools;
/**
* DataTools Wrapper base class.
*/
-public abstract class DTPWrapper implements Comparable {
+public abstract class DTPWrapper {
DTPWrapper() {
super();
@@ -45,6 +45,7 @@ public abstract class DTPWrapper implements Comparable {
public abstract String getName();
+ @Override
public String toString() {
return StringTools.buildToStringFor( this, this.getName());
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java
index b56d32dc2e..ab7f5656e9 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -12,13 +12,14 @@ package org.eclipse.jpt.db.internal;
import java.text.Collator;
import java.util.Iterator;
import java.util.Set;
+
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
* Database wrapper base class.
*/
-public abstract class Database extends DTPWrapper {
+public abstract class Database extends DTPWrapper implements Comparable<Database> {
private boolean caseSensitive = false; // TODO allow user to configure
@@ -72,8 +73,8 @@ public abstract class Database extends DTPWrapper {
// ********** Comparable implementation **********
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( Database)o).getName());
+ public int compareTo( Database database) {
+ return Collator.getInstance().compare( this.getName(), database.getName());
}
// ***** caseSensitive
@@ -88,7 +89,7 @@ public abstract class Database extends DTPWrapper {
// ***** catalogs
- abstract Set getCatalogs();
+ abstract Set<Catalog> getCatalogs();
/**
* Returns true if this database accepts catalogs.
@@ -100,7 +101,7 @@ public abstract class Database extends DTPWrapper {
*/
public abstract String getDefaultCatalogName();
- public Iterator catalogs() {
+ public Iterator<Catalog> catalogs() {
return this.getCatalogs().iterator();
}
@@ -108,10 +109,11 @@ public abstract class Database extends DTPWrapper {
return this.getCatalogs().size();
}
- public Iterator catalogNames() {
- return new TransformationIterator( this.catalogs()) {
- protected Object transform( Object next) {
- return (( Catalog) next).getName();
+ public Iterator<String> catalogNames() {
+ return new TransformationIterator<Catalog, String>( this.catalogs()) {
+ @Override
+ protected String transform( Catalog catalog) {
+ return catalog.getName();
}
};
}
@@ -125,8 +127,8 @@ public abstract class Database extends DTPWrapper {
}
private Catalog catalogNamedInternal( String name) {
- for ( Iterator stream = this.catalogs(); stream.hasNext(); ) {
- Catalog catalog = ( Catalog) stream.next();
+ for ( Iterator<Catalog> stream = this.catalogs(); stream.hasNext(); ) {
+ Catalog catalog = stream.next();
if ( catalog.getName().equals( name)) {
return catalog;
}
@@ -135,8 +137,8 @@ public abstract class Database extends DTPWrapper {
}
private Catalog catalogNamedIgnoreCase( String name) {
- for ( Iterator stream = this.catalogs(); stream.hasNext(); ) {
- Catalog catalog = ( Catalog) stream.next();
+ for ( Iterator<Catalog> stream = this.catalogs(); stream.hasNext(); ) {
+ Catalog catalog = stream.next();
if ( StringTools.stringsAreEqualIgnoreCase( catalog.getName(), name)) {
return catalog;
}
@@ -148,8 +150,8 @@ public abstract class Database extends DTPWrapper {
* return the catalog for the specified dtp catalog
*/
Catalog catalog( org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog) {
- for ( Iterator stream = this.catalogs(); stream.hasNext(); ) {
- Catalog catalog = ( Catalog) stream.next();
+ for ( Iterator<Catalog> stream = this.catalogs(); stream.hasNext(); ) {
+ Catalog catalog = stream.next();
if (catalog.wraps( dtpCatalog)) {
return catalog;
}
@@ -160,9 +162,9 @@ public abstract class Database extends DTPWrapper {
// ***** schemata
- abstract Set getSchemata();
+ abstract Set<Schema> getSchemata();
- public Iterator schemata() {
+ public Iterator<Schema> schemata() {
return this.getSchemata().iterator();
}
@@ -174,10 +176,11 @@ public abstract class Database extends DTPWrapper {
return this.getSchemata().contains( column);
}
- public Iterator schemaNames() {
- return new TransformationIterator( this.schemata()) {
- protected Object transform( Object next) {
- return (( Schema) next).getName();
+ public Iterator<String> schemaNames() {
+ return new TransformationIterator<Schema, String>( this.schemata()) {
+ @Override
+ protected String transform( Schema schema) {
+ return schema.getName();
}
};
}
@@ -191,8 +194,8 @@ public abstract class Database extends DTPWrapper {
}
private Schema schemaNamedInternal( String name) {
- for ( Iterator stream = this.schemata(); stream.hasNext(); ) {
- Schema schema = ( Schema) stream.next();
+ for ( Iterator<Schema> stream = this.schemata(); stream.hasNext(); ) {
+ Schema schema = stream.next();
if ( schema.getName().equals( name)) {
return schema;
}
@@ -201,8 +204,8 @@ public abstract class Database extends DTPWrapper {
}
private Schema schemaNamedIgnoreCase( String name) {
- for ( Iterator stream = this.schemata(); stream.hasNext(); ) {
- Schema schema = ( Schema) stream.next();
+ for ( Iterator<Schema> stream = this.schemata(); stream.hasNext(); ) {
+ Schema schema = stream.next();
if ( StringTools.stringsAreEqualIgnoreCase( schema.getName(), name)) {
return schema;
}
@@ -214,8 +217,8 @@ public abstract class Database extends DTPWrapper {
* return the schema for the specified dtp schema
*/
Schema schema( org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema) {
- for ( Iterator stream = this.schemata(); stream.hasNext(); ) {
- Schema schema = ( Schema) stream.next();
+ for ( Iterator<Schema> stream = this.schemata(); stream.hasNext(); ) {
+ Schema schema = stream.next();
if ( schema.wraps( dtpSchema)) {
return schema;
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java
index 8a6edb586b..a617bf4271 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -14,6 +14,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
import org.eclipse.jpt.utility.internal.StringTools;
@@ -23,7 +24,7 @@ import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
* Wrap a DTP ForeignKey
*/
-public final class ForeignKey extends DTPWrapper {
+public final class ForeignKey extends DTPWrapper implements Comparable<ForeignKey> {
private final Table baseTable;
private final org.eclipse.datatools.modelbase.sql.constraints.ForeignKey dtpForeignKey;
private ICatalogObjectListener foreignKeyListener;
@@ -52,6 +53,7 @@ public final class ForeignKey extends DTPWrapper {
}
}
+ @Override
protected boolean connectionIsOnline() {
return this.baseTable.connectionIsOnline();
}
@@ -67,6 +69,7 @@ public final class ForeignKey extends DTPWrapper {
};
}
+ @Override
protected void dispose() {
this.removeCatalogObjectListener(( ICatalogObject) this.dtpForeignKey, this.foreignKeyListener);
@@ -120,7 +123,7 @@ public final class ForeignKey extends DTPWrapper {
* the base table's primary key
*/
public Iterator<Column> nonPrimaryKeyBaseColumns() {
- return new FilteringIterator(this.baseColumns()) {
+ return new FilteringIterator<Column>(this.baseColumns()) {
@Override
protected boolean accept(Object o) {
return ! ForeignKey.this.getBaseTable().primaryKeyColumnsContains((Column) o);
@@ -132,10 +135,10 @@ public final class ForeignKey extends DTPWrapper {
* return the foreign key's "referenced" columns
*/
public Iterator<Column> referencedColumns() {
- return new TransformationIterator(this.columnPairs()) {
+ return new TransformationIterator<ColumnPair, Column>(this.columnPairs()) {
@Override
- protected Object transform(Object next) {
- return ((ColumnPair) next).getReferencedColumn();
+ protected Column transform(ColumnPair columnPair) {
+ return columnPair.getReferencedColumn();
}
};
}
@@ -165,7 +168,7 @@ public final class ForeignKey extends DTPWrapper {
}
ColumnPair columnPair = this.columnPairs().next();
- Column pkColumn = (Column) this.getReferencedTable().primaryKeyColumns().next();
+ Column pkColumn = this.getReferencedTable().primaryKeyColumns().next();
if (columnPair.getReferencedColumn() != pkColumn) {
return false;
}
@@ -183,6 +186,7 @@ public final class ForeignKey extends DTPWrapper {
return this.columnPairs;
}
+ @SuppressWarnings("unchecked")
private Set<ColumnPair> buildColumnPairs() {
List<org.eclipse.datatools.modelbase.sql.tables.Column> baseColumns = this.dtpForeignKey.getMembers();
int size = baseColumns.size();
@@ -285,8 +289,8 @@ public final class ForeignKey extends DTPWrapper {
// ********** Comparable implementation **********
- public int compareTo(Object o) {
- return Collator.getInstance().compare(this.getName(), ((ForeignKey) o).getName());
+ public int compareTo(ForeignKey foreignKey) {
+ return Collator.getInstance().compare(this.getName(), foreignKey.getName());
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java
index 77598ea51a..0d9f21777f 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java
@@ -39,6 +39,7 @@ public class JptDbPlugin extends Plugin {
/**
* This method is called upon plug-in activation
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
this.connectionProfileRepository = ConnectionProfileRepository.instance();
@@ -48,6 +49,7 @@ public class JptDbPlugin extends Plugin {
/**
* This method is called when the plug-in is stopped
*/
+ @Override
public void stop(BundleContext context) throws Exception {
this.connectionProfileRepository.disposeListeners();
this.connectionProfileRepository = null;
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java
index d71998ca88..f09563360a 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -34,38 +34,47 @@ public final class NullConnection extends Connection {
// ********** behavior **********
+ @Override
protected void dispose() {
// do nothing
}
+ @Override
public String getName() {
return ClassTools.shortClassNameForObject( this);
}
+ @Override
void databaseChanged( Database database, int eventType) {
// do nothing
}
+ @Override
void schemaChanged( Schema schema, Database database, int eventType) {
// do nothing
}
+ @Override
void tableChanged( Table table, Schema schema, Database database, int eventType) {
// do nothing
}
+ @Override
public boolean isConnected() {
return false;
}
+ @Override
public String getFactoryId() {
return "";
}
+ @Override
public void addConnectionListener( ConnectionListener listener) {
// do nothing
}
+ @Override
public void removeConnectionListener( ConnectionListener listener) {
// do nothing
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java
index 45c36d1652..3ad4906b45 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -34,102 +34,126 @@ public final class NullConnectionProfile extends ConnectionProfile {
// ********** behavior **********
+ @Override
protected Connection buildConnection() {
return NullConnection.instance();
}
+ @Override
protected Database buildDatabase() {
return NullDatabase.instance();
}
+ @Override
public void connect() {
// do nothing
}
+ @Override
public void disconnect() {
// do nothing
}
+ @Override
void databaseChanged( Database database, int eventType) {
// do nothing
}
+ @Override
void catalogChanged( Catalog catalog, Database database, int eventType) {
// do nothing
}
+ @Override
void schemaChanged( Schema schema, Database database, int eventType) {
// do nothing
}
+ @Override
void tableChanged( Table table, Schema schema, Database database, int eventType) {
// do nothing
}
// ********** queries **********
+ @Override
public Connection getConnection() {
return NullConnection.instance();
}
+ @Override
public Database getDatabase() {
return NullDatabase.instance();
}
+ @Override
public String getName() {
return ClassTools.shortClassNameForObject( this);
}
+ @Override
public String getDatabaseName() {
return "";
}
+ @Override
public String getDatabaseProduct() {
return "";
}
+ @Override
public String getDatabaseVendor() {
return "";
}
+ @Override
public String getDatabaseVersion() {
return "";
}
+ @Override
public String getUserName() {
return "";
}
+ @Override
public String getInstanceId() {
return "";
}
+ @Override
public String getProviderId() {
return "";
}
+ @Override
public boolean isConnected() {
return false;
}
+ @Override
boolean wraps( org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile) {
return false;
}
// ********** listeners **********
+ @Override
public void addProfileListener( ProfileListener listener) {
// do nothing
}
+ @Override
public void removeProfileListener( ProfileListener listener) {
// do nothing
}
+ @Override
public void addConnectionListener( ConnectionListener listener) {
// do nothing
}
+ @Override
public void removeConnectionListener( ConnectionListener listener) {
// do nothing
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java
index 96d145f019..fa316b82ef 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -36,40 +36,49 @@ public final class NullDatabase extends Database {
// ********** behavior **********
+ @Override
void catalogChanged( Catalog catalog, int eventType) {
// do nothing
}
+ @Override
void schemaChanged( Schema schema, int eventType) {
// do nothing
}
+ @Override
void tableChanged( Table table, Schema schema,int eventType) {
// do nothing
}
+ @Override
void refresh() {
// do nothing
}
+ @Override
protected void dispose() {
// do nothing
}
+ @Override
protected boolean connectionIsOnline() {
return false;
}
// ********** queries **********
+ @Override
public String getName() {
return ClassTools.shortClassNameForObject( this);
}
+ @Override
public String getVendor() {
return this.getName();
}
+ @Override
public String getVersion() {
return "";
}
@@ -87,14 +96,14 @@ public final class NullDatabase extends Database {
}
@Override
- Set getCatalogs() {
+ Set<Catalog> getCatalogs() {
return Collections.emptySet();
}
// ***** schemata
@Override
- Set getSchemata() {
+ Set<Schema> getSchemata() {
return Collections.emptySet();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java
index a83e5b0f02..677b38c031 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java
index 02921dee91..012f3df52d 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
import org.eclipse.jpt.utility.internal.StringTools;
@@ -22,13 +23,13 @@ import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
* Wrap a DTP Schema
*/
-public final class Schema extends DTPWrapper {
- private final Database database;
- private final org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema;
+public final class Schema extends DTPWrapper implements Comparable<Schema> {
+ final Database database;
+ final org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema;
private ICatalogObjectListener schemaListener;
- private Set tables; // lazy-initialized
- private Set sequences; // lazy-initialized
+ private Set<Table> tables; // lazy-initialized
+ private Set<Sequence> sequences; // lazy-initialized
// ********** constructors **********
@@ -49,6 +50,7 @@ public final class Schema extends DTPWrapper {
}
}
+ @Override
protected boolean connectionIsOnline() {
return this.database.connectionIsOnline();
}
@@ -64,7 +66,7 @@ public final class Schema extends DTPWrapper {
};
}
- private void refresh() {
+ void refresh() {
this.disposeTables();
this.disposeSequences();
@@ -84,6 +86,7 @@ public final class Schema extends DTPWrapper {
return new Sequence( this, sequence);
}
+ @Override
protected void dispose() {
this.removeCatalogObjectListener(( ICatalogObject) this.dtpSchema, this.schemaListener);
@@ -93,22 +96,23 @@ public final class Schema extends DTPWrapper {
private void disposeTables() {
if( this.tables != null) {
- for( Iterator i = this.tables(); i.hasNext(); ) {
- (( Table)i.next()).dispose();
+ for( Iterator<Table> stream = this.tables(); stream.hasNext(); ) {
+ stream.next().dispose();
}
}
}
private void disposeSequences() {
if( this.sequences != null) {
- for( Iterator i = this.sequences(); i.hasNext(); ) {
- (( Sequence)i.next()).dispose();
+ for( Iterator<Sequence> stream = this.sequences(); stream.hasNext(); ) {
+ stream.next().dispose();
}
}
}
// ********** queries **********
+ @Override
public String getName() {
return this.dtpSchema.getName();
}
@@ -124,23 +128,24 @@ public final class Schema extends DTPWrapper {
// ********** tables **********
- private synchronized Collection getTables() {
+ private synchronized Collection<Table> getTables() {
if( this.tables == null) {
this.tables = this.buildTables();
}
return this.tables;
}
- private Set buildTables() {
- Collection dtpTables = this.dtpSchema.getTables();
- Set result = new HashSet( dtpTables.size());
- for( Iterator i = dtpTables.iterator(); i.hasNext(); ) {
- result.add( this.wrap(( org.eclipse.datatools.modelbase.sql.tables.Table) i.next()));
+ @SuppressWarnings("unchecked")
+ private Set<Table> buildTables() {
+ Collection<org.eclipse.datatools.modelbase.sql.tables.Table> dtpTables = this.dtpSchema.getTables();
+ Set<Table> result = new HashSet<Table>( dtpTables.size());
+ for (org.eclipse.datatools.modelbase.sql.tables.Table dtpTable : dtpTables) {
+ result.add( this.wrap(dtpTable));
}
return result;
}
- public Iterator tables() {
+ public Iterator<Table> tables() {
return this.getTables().iterator();
}
@@ -153,9 +158,10 @@ public final class Schema extends DTPWrapper {
}
public Iterator<String> tableNames() {
- return new TransformationIterator( this.tables()) {
- protected Object transform( Object next) {
- return (( Table) next).getName();
+ return new TransformationIterator<Table, String>( this.tables()) {
+ @Override
+ protected String transform( Table table) {
+ return table.getName();
}
};
}
@@ -169,8 +175,8 @@ public final class Schema extends DTPWrapper {
}
private Table tableNamedInternal( String name) {
- for( Iterator i = this.tables(); i.hasNext(); ) {
- Table table = ( Table) i.next();
+ for( Iterator<Table> stream = this.tables(); stream.hasNext(); ) {
+ Table table = stream.next();
if( table.getName().equals( name)) {
return table;
}
@@ -179,8 +185,8 @@ public final class Schema extends DTPWrapper {
}
private Table tableNamedIgnoreCase( String name) {
- for( Iterator i = this.tables(); i.hasNext(); ) {
- Table table = ( Table) i.next();
+ for( Iterator<Table> stream = this.tables(); stream.hasNext(); ) {
+ Table table = stream.next();
if( StringTools.stringsAreEqualIgnoreCase( table.getName(), name)) {
return table;
}
@@ -195,8 +201,8 @@ public final class Schema extends DTPWrapper {
if( dtpTable.getSchema() != this.dtpSchema) {
return this.database.table( dtpTable);
}
- for( Iterator i = this.tables(); i.hasNext(); ) {
- Table table = ( Table) i.next();
+ for( Iterator<Table> stream = this.tables(); stream.hasNext(); ) {
+ Table table = stream.next();
if( table.wraps( dtpTable)) {
return table;
}
@@ -206,23 +212,24 @@ public final class Schema extends DTPWrapper {
// ***** sequences
- private synchronized Collection getSequences() {
+ private synchronized Collection<Sequence> getSequences() {
if( this.sequences == null) {
this.sequences = this.buildSequences();
}
return this.sequences;
}
- private Set buildSequences() {
- Collection dtpSequences = this.dtpSchema.getSequences();
- Set result = new HashSet( dtpSequences.size());
- for( Iterator i = dtpSequences.iterator(); i.hasNext(); ) {
- result.add( this.wrap(( org.eclipse.datatools.modelbase.sql.schema.Sequence) i.next()));
+ @SuppressWarnings("unchecked")
+ private Set<Sequence> buildSequences() {
+ Collection<org.eclipse.datatools.modelbase.sql.schema.Sequence> dtpSequences = this.dtpSchema.getSequences();
+ Set<Sequence> result = new HashSet<Sequence>( dtpSequences.size());
+ for (org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence : dtpSequences) {
+ result.add( this.wrap(dtpSequence));
}
return result;
}
- public Iterator sequences() {
+ public Iterator<Sequence> sequences() {
return this.getSequences().iterator();
}
@@ -234,10 +241,11 @@ public final class Schema extends DTPWrapper {
return this.getSequences().contains( column);
}
- public Iterator sequenceNames() {
- return new TransformationIterator(this.sequences()) {
- protected Object transform( Object next) {
- return (( Sequence)next).getName();
+ public Iterator<String> sequenceNames() {
+ return new TransformationIterator<Sequence, String>(this.sequences()) {
+ @Override
+ protected String transform( Sequence sequence) {
+ return sequence.getName();
}
};
}
@@ -251,8 +259,8 @@ public final class Schema extends DTPWrapper {
}
private Sequence sequenceNamedInternal( String name) {
- for( Iterator i = this.sequences(); i.hasNext(); ) {
- Sequence sequence = ( Sequence) i.next();
+ for( Iterator<Sequence> stream = this.sequences(); stream.hasNext(); ) {
+ Sequence sequence = stream.next();
if( sequence.getName().equals( name)) {
return sequence;
}
@@ -261,8 +269,8 @@ public final class Schema extends DTPWrapper {
}
private Sequence sequenceNamedIgnoreCase( String name) {
- for( Iterator i = this.sequences(); i.hasNext(); ) {
- Sequence sequence = ( Sequence) i.next();
+ for( Iterator<Sequence> stream = this.sequences(); stream.hasNext(); ) {
+ Sequence sequence = stream.next();
if( sequence.getName().equalsIgnoreCase( name)) {
return sequence;
}
@@ -270,14 +278,14 @@ public final class Schema extends DTPWrapper {
return null;
}
- boolean wraps( org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema) {
- return this.dtpSchema == dtpSchema;
+ boolean wraps( org.eclipse.datatools.modelbase.sql.schema.Schema schema) {
+ return this.dtpSchema == schema;
}
// ********** Comparable implementation **********
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( Schema)o).getName());
+ public int compareTo( Schema schema) {
+ return Collator.getInstance().compare( this.getName(), schema.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java
index c03520e1d7..7cb68a47e5 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java
@@ -1,22 +1,23 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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;
import java.text.Collator;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
/**
* Wrap a DTP Sequence
*/
-public final class Sequence extends DTPWrapper {
+public final class Sequence extends DTPWrapper implements Comparable<Sequence> {
private final Schema schema;
private final org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence;
private ICatalogObjectListener sequenceListener;
@@ -37,6 +38,7 @@ public final class Sequence extends DTPWrapper {
}
}
+ @Override
protected boolean connectionIsOnline() {
return this.schema.connectionIsOnline();
}
@@ -55,16 +57,18 @@ public final class Sequence extends DTPWrapper {
// ********** queries **********
+ @Override
protected void dispose() {
this.removeCatalogObjectListener(( ICatalogObject) this.dtpSequence, this.sequenceListener);
}
+ @Override
public String getName() {
return this.dtpSequence.getName();
}
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( Sequence)o).getName());
+ public int compareTo( Sequence sequence) {
+ return Collator.getInstance().compare( this.getName(), sequence.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java
index 34db8b149e..d06d2ebb51 100644
--- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java
+++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
- *
+ * 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
******************************************************************************/
@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject;
import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener;
import org.eclipse.datatools.modelbase.sql.constraints.PrimaryKey;
@@ -27,9 +28,9 @@ import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
* Wrap a DTP Table
*/
-public final class Table extends DTPWrapper {
- private final Schema schema;
- private final org.eclipse.datatools.modelbase.sql.tables.Table dtpTable;
+public final class Table extends DTPWrapper implements Comparable<Table> {
+ final Schema schema;
+ final org.eclipse.datatools.modelbase.sql.tables.Table dtpTable;
private ICatalogObjectListener tableListener;
private Set<Column> columns; // lazy-initialized
@@ -56,6 +57,7 @@ public final class Table extends DTPWrapper {
}
}
+ @Override
protected boolean connectionIsOnline() {
return this.schema.connectionIsOnline();
}
@@ -71,7 +73,7 @@ public final class Table extends DTPWrapper {
};
}
- private void refresh() {
+ void refresh() {
this.disposeColumns();
this.columns = null;
@@ -90,16 +92,16 @@ public final class Table extends DTPWrapper {
private void disposeColumns() {
if( this.columns != null) {
- for( Iterator i = this.columns(); i.hasNext(); ) {
- (( Column)i.next()).dispose();
+ for( Iterator<Column> stream = this.columns(); stream.hasNext(); ) {
+ stream.next().dispose();
}
}
}
private void disposeForeignKey() {
if( this.foreignKeys != null) {
- for( Iterator i = this.foreignKeys(); i.hasNext(); ) {
- (( ForeignKey)i.next()).dispose();
+ for( Iterator<ForeignKey> stream = this.foreignKeys(); stream.hasNext(); ) {
+ stream.next().dispose();
}
}
}
@@ -339,7 +341,7 @@ public final class Table extends DTPWrapper {
// ********** Comparable implementation **********
- public int compareTo( Object o) {
- return Collator.getInstance().compare( this.getName(), (( Table)o).getName());
+ public int compareTo( Table table) {
+ return Collator.getInstance().compare( this.getName(), table.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java
index 1211b4506a..4276feb345 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/IAttributeMappingUiProvider.java
@@ -1,8 +1,8 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
+ * 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
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal.java.details;
import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.jpt.core.internal.IAttributeMapping;
import org.eclipse.jpt.ui.internal.details.IJpaComposite;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
@@ -39,7 +40,7 @@ public interface IAttributeMappingUiProvider
* @param widgetFactory
* @return
*/
- IJpaComposite buildAttributeMappingComposite(
+ IJpaComposite<IAttributeMapping> buildAttributeMappingComposite(
Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory);
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java
index fa2c73f769..b249b9b1f9 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentAttributeDetailsPage.java
@@ -1,8 +1,8 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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.
+ * 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
@@ -40,13 +40,13 @@ public class JavaPersistentAttributeDetailsPage
gridData.grabExcessHorizontalSpace = true;
mappingCombo.getCombo().setLayoutData(gridData);
- PageBook mappingPageBook = buildMappingPageBook(composite);
+ PageBook book = buildMappingPageBook(composite);
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalSpan = 2;
- mappingPageBook.setLayoutData(gridData);
+ book.setLayoutData(gridData);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java
index 711c698b4f..36194e5b66 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java
@@ -47,13 +47,14 @@ public class XmlPersistentAttributeDetailsPage
private void buildPersistentTypeListener() {
this.persistentTypeListener = new AdapterImpl() {
+ @Override
public void notifyChanged(Notification notification) {
persistentTypeChanged(notification);
}
};
}
- private void persistentTypeChanged(Notification notification) {
+ void persistentTypeChanged(Notification notification) {
if (notification.getFeatureID(XmlPersistentType.class) ==
OrmPackage.XML_PERSISTENT_TYPE__SPECIFIED_ATTRIBUTE_MAPPINGS) {
Display.getDefault().asyncExec(
@@ -90,14 +91,14 @@ public class XmlPersistentAttributeDetailsPage
gridData.grabExcessHorizontalSpace = true;
mappingCombo.getCombo().setLayoutData(gridData);
- PageBook mappingPageBook = buildMappingPageBook(composite);
+ PageBook book = buildMappingPageBook(composite);
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalSpan = 2;
- mappingPageBook.setLayoutData(gridData);
+ book.setLayoutData(gridData);
}
@Override

Back to the top