Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.net4j.db/.settings/.api_filters11
-rw-r--r--plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java12
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBElement.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBElement.java)2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBNamedElement.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBNamedElement.java)2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java1
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/SchemaElementNotFoundException.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBDelta.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBPropertyDelta.java1
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/package-info.java1
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/dml/package-info.java1
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/package-info.java1
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java18
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java18
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBElement.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBElement.java)9
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java22
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java83
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndexField.java25
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBNamedElement.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBNamedElement.java)13
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java420
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchemaElement.java)11
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java123
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBDelta.java5
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java10
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexDelta.java18
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexFieldDelta.java10
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java13
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBTableDelta.java23
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchema.java396
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBElement.java24
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBField.java26
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndex.java27
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndexField.java24
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java33
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java40
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchemaElement.java23
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java32
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/package-info.java16
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/package-info.java1
40 files changed, 991 insertions, 515 deletions
diff --git a/plugins/org.eclipse.net4j.db/.settings/.api_filters b/plugins/org.eclipse.net4j.db/.settings/.api_filters
new file mode 100644
index 0000000000..1ee3edca0c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/.settings/.api_filters
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.net4j.db" version="2">
+ <resource path="src/org/eclipse/net4j/spi/db/DBSchema.java" type="org.eclipse.net4j.spi.db.DBSchema">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="DBSchema"/>
+ <message_argument value="DBSchema"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
index 4c19b6f625..421d332383 100644
--- a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Export-Package: org.eclipse.net4j.db;version="4.2.0",
org.eclipse.net4j.internal.db.ddl;version="4.2.0";x-internal:=true,
org.eclipse.net4j.internal.db.ddl.delta;version="4.2.0";x-internal:=true,
org.eclipse.net4j.internal.db.dml;version="4.2.0";x-internal:=true,
- org.eclipse.net4j.spi.db;version="4.2.0"
+ org.eclipse.net4j.spi.db;version="4.2.0",
+ org.eclipse.net4j.spi.db.ddl;version="4.2.0"
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: registered
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index be29db9291..2b40e97468 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -11,15 +11,15 @@
package org.eclipse.net4j.db;
import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBNamedElement;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.internal.db.DBDatabase;
import org.eclipse.net4j.internal.db.DBTransaction;
import org.eclipse.net4j.internal.db.DataSourceConnectionProvider;
import org.eclipse.net4j.internal.db.bundle.OM;
+import org.eclipse.net4j.internal.db.ddl.DBNamedElement;
import org.eclipse.net4j.spi.db.DBAdapter;
-import org.eclipse.net4j.spi.db.DBNamedElement;
-import org.eclipse.net4j.spi.db.DBSchema;
import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -174,7 +174,7 @@ public final class DBUtil
public static IDBSchema createSchema(String name)
{
- return new DBSchema(name);
+ return new org.eclipse.net4j.internal.db.ddl.DBSchema(name);
}
/**
@@ -182,7 +182,9 @@ public final class DBUtil
*/
public static IDBSchema readSchema(IDBAdapter adapter, Connection connection, String name)
{
- return adapter.readSchema(connection, name);
+ IDBSchema schema = new org.eclipse.net4j.internal.db.ddl.DBSchema(name);
+ readSchema(adapter, connection, schema);
+ return schema;
}
/**
@@ -198,7 +200,7 @@ public final class DBUtil
*/
public static IDBSchema copySchema(IDBSchema source)
{
- return new DBSchema(source);
+ return new org.eclipse.net4j.internal.db.ddl.DBSchema(source);
}
public static DataSource createDataSource(Map<Object, Object> properties)
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBElement.java
index b8f4df4473..6f28927923 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBElement.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.net4j.db;
+package org.eclipse.net4j.db.ddl;
import org.eclipse.net4j.util.event.INotifier;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBNamedElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBNamedElement.java
index 611577dfab..bd377721c8 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBNamedElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBNamedElement.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.net4j.db;
+package org.eclipse.net4j.db.ddl;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java
index bf75072b5e..ac45e373ee 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.net4j.db.ddl;
-import org.eclipse.net4j.db.IDBNamedElement;
import org.eclipse.net4j.util.container.IContainer;
import java.io.Serializable;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/SchemaElementNotFoundException.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/SchemaElementNotFoundException.java
index d807be831c..8a841d13c1 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/SchemaElementNotFoundException.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/SchemaElementNotFoundException.java
@@ -11,7 +11,7 @@
package org.eclipse.net4j.db.ddl;
import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.spi.db.DBSchemaElement;
+import org.eclipse.net4j.internal.db.ddl.DBSchemaElement;
/**
* @since 4.2
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBDelta.java
index 8a531f9d8d..578946ab91 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBDelta.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.net4j.db.ddl.delta;
-import org.eclipse.net4j.db.IDBNamedElement;
+import org.eclipse.net4j.db.ddl.IDBNamedElement;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.util.container.IContainer;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBPropertyDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBPropertyDelta.java
index 39d15aefd5..806adf5138 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBPropertyDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/delta/IDBPropertyDelta.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.net4j.db.ddl.delta;
-
/**
* @since 4.2
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/package-info.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/package-info.java
index 8ccfdc8fb5..c8715c655a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/package-info.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/package-info.java
@@ -13,3 +13,4 @@
* The Net4j DB framework concepts for the abstraction of the SQL data definition language.
*/
package org.eclipse.net4j.db.ddl;
+
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/dml/package-info.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/dml/package-info.java
index e283cd4a9f..c7cc4914ac 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/dml/package-info.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/dml/package-info.java
@@ -13,3 +13,4 @@
* The Net4j DB framework concepts for the abstraction of the SQL data manipulation language.
*/
package org.eclipse.net4j.db.dml;
+
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/package-info.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/package-info.java
index 6b214a00be..90f96f2b93 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/package-info.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/package-info.java
@@ -13,3 +13,4 @@
* The Net4j DB framework.
*/
package org.eclipse.net4j.db;
+
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
index eb61cc3dea..2f3541b593 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
@@ -21,7 +21,7 @@ import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
import org.eclipse.net4j.internal.db.ddl.delta.DBSchemaDelta;
import org.eclipse.net4j.spi.db.DBAdapter;
-import org.eclipse.net4j.spi.db.DBSchema;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.SetContainer;
import org.eclipse.net4j.util.event.Event;
@@ -43,7 +43,7 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
private int statementCacheCapacity = DEFAULT_STATEMENT_CACHE_CAPACITY;
- private DBSchema schema;
+ private IDBSchema schema;
private DBSchemaTransaction schemaTransaction;
@@ -55,15 +55,15 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
this.adapter = adapter;
this.connectionProvider = connectionProvider;
- schema = DBUtil.execute(connectionProvider, new RunnableWithConnection<DBSchema>()
+ schema = DBUtil.execute(connectionProvider, new RunnableWithConnection<IDBSchema>()
{
- public DBSchema run(Connection connection) throws SQLException
+ public IDBSchema run(Connection connection) throws SQLException
{
- return (DBSchema)adapter.readSchema(connection, schemaName);
+ return adapter.readSchema(connection, schemaName);
}
});
- schema.lock();
+ ((InternalDBSchema)schema).lock();
activate();
}
@@ -77,7 +77,7 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
return connectionProvider;
}
- public DBSchema getSchema()
+ public IDBSchema getSchema()
{
return schema;
}
@@ -118,7 +118,7 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
{
if (schemaTransaction != null)
{
- DBSchema workingCopy = schemaTransaction.getWorkingCopy();
+ IDBSchema workingCopy = schemaTransaction.getWorkingCopy();
updateRunnable.run(workingCopy);
if (commitRunnable != null)
@@ -155,7 +155,7 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
try
{
- DBSchema workingCopy = schemaTransaction.getWorkingCopy();
+ IDBSchema workingCopy = schemaTransaction.getWorkingCopy();
P parentCopy = workingCopy.findElement(parent);
T elementCopy = runnable.run(parentCopy, name);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java
index 823f8ede51..22b14e0b56 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java
@@ -19,7 +19,7 @@ import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor;
import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
import org.eclipse.net4j.internal.db.ddl.delta.DBSchemaDelta;
import org.eclipse.net4j.spi.db.DBAdapter;
-import org.eclipse.net4j.spi.db.DBSchema;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
import java.sql.Connection;
import java.sql.SQLException;
@@ -33,16 +33,16 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
private DBTransaction transaction;
- private DBSchema oldSchema;
+ private IDBSchema oldSchema;
- private DBSchema workingCopy;
+ private IDBSchema workingCopy;
public DBSchemaTransaction(DBDatabase database)
{
this.database = database;
oldSchema = database.getSchema();
- workingCopy = new DBSchema(oldSchema);
+ workingCopy = DBUtil.copySchema(oldSchema);
}
public DBDatabase getDatabase()
@@ -60,12 +60,12 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
transaction = getTransaction;
}
- public DBSchema getWorkingCopy()
+ public IDBSchema getWorkingCopy()
{
return workingCopy;
}
- public IDBSchemaDelta ensureSchema(IDBSchema schema, IDBDeltaVisitor.Filter.Policy policy)
+ public DBSchemaDelta ensureSchema(IDBSchema schema, IDBDeltaVisitor.Filter.Policy policy)
{
IDBSchema workingCopy = getWorkingCopy();
@@ -79,7 +79,7 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
return result;
}
- public IDBSchemaDelta ensureSchema(IDBSchema schema)
+ public DBSchemaDelta ensureSchema(IDBSchema schema)
{
return ensureSchema(schema, DEFAULT_ENSURE_SCHEMA_POLICY);
}
@@ -113,14 +113,14 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
try
{
- oldSchema.unlock();
+ ((InternalDBSchema)oldSchema).unlock();
DBAdapter adapter = database.getAdapter();
adapter.updateSchema(connection, oldSchema, delta);
}
finally
{
- oldSchema.lock();
+ ((InternalDBSchema)oldSchema).lock();
doClose(delta);
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBElement.java
index a9957f8c1e..1b8bd2b252 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBElement.java
@@ -8,20 +8,19 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.net4j.spi.db;
+package org.eclipse.net4j.internal.db.ddl;
-import org.eclipse.net4j.db.IDBElement;
+import org.eclipse.net4j.spi.db.ddl.InternalDBElement;
import org.eclipse.net4j.util.event.Notifier;
import java.io.Serializable;
import java.util.Properties;
/**
- * @author Eike Stepper
* @since 4.2
- * @noextend This class is not intended to be subclassed by clients.
+ * @author Eike Stepper
*/
-public abstract class DBElement extends Notifier implements IDBElement, Serializable
+public abstract class DBElement extends Notifier implements InternalDBElement, Serializable
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
index d82915ffa9..9fc5ef8cf4 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
@@ -11,11 +11,13 @@
package org.eclipse.net4j.internal.db.ddl;
import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
-import org.eclipse.net4j.spi.db.DBSchemaElement;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.spi.db.ddl.InternalDBField;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
+import org.eclipse.net4j.spi.db.ddl.InternalDBTable;
import java.io.IOException;
import java.io.Writer;
@@ -24,7 +26,7 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class DBField extends DBSchemaElement implements IDBField
+public class DBField extends DBSchemaElement implements InternalDBField
{
public static final int DEFAULT_BOOLEAN_PRECISION = 1;
@@ -51,7 +53,7 @@ public class DBField extends DBSchemaElement implements IDBField
private static final long serialVersionUID = 1L;
- private DBTable table;
+ private IDBTable table;
private DBType type;
@@ -64,11 +66,11 @@ public class DBField extends DBSchemaElement implements IDBField
private int position;
/**
- * Tracks the construction stack trace to provide better debug infos in DBTable.addIndex().
+ * Tracks the construction stack trace to provide better debug infos in IDBTable.addIndex().
*/
private transient Exception constructionStackTrace;
- public DBField(DBTable table, String name, DBType type, int precision, int scale, boolean notNull, int position)
+ public DBField(IDBTable table, String name, DBType type, int precision, int scale, boolean notNull, int position)
{
super(name);
this.table = table;
@@ -108,12 +110,12 @@ public class DBField extends DBSchemaElement implements IDBField
return table.getSchema();
}
- public DBTable getTable()
+ public IDBTable getTable()
{
return table;
}
- public DBTable getParent()
+ public IDBTable getParent()
{
return getTable();
}
@@ -211,7 +213,7 @@ public class DBField extends DBSchemaElement implements IDBField
public void remove()
{
- table.removeField(this);
+ ((InternalDBTable)table).removeField(this);
}
public String formatPrecision()
@@ -267,7 +269,7 @@ public class DBField extends DBSchemaElement implements IDBField
private void assertUnlocked()
{
- table.getSchema().assertUnlocked();
+ ((InternalDBSchema)table.getSchema()).assertUnlocked();
}
public static void trackConstruction(boolean on)
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java
index 2ea7b4160a..1c385c8faf 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java
@@ -14,36 +14,37 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBIndexField;
+import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
+import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.SchemaElementNotFoundException;
-import org.eclipse.net4j.spi.db.DBSchema;
-import org.eclipse.net4j.spi.db.DBSchemaElement;
+import org.eclipse.net4j.spi.db.ddl.InternalDBField;
+import org.eclipse.net4j.spi.db.ddl.InternalDBIndex;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
+import org.eclipse.net4j.spi.db.ddl.InternalDBTable;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* @author Eike Stepper
*/
-public class DBIndex extends DBSchemaElement implements IDBIndex
+public class DBIndex extends DBSchemaElement implements InternalDBIndex
{
- public static final IDBIndexField[] NO_INDEX_FIELDS = {};
-
private static final long serialVersionUID = 1L;
- private DBTable table;
+ private IDBTable table;
private Type type;
- private List<DBIndexField> indexFields = new ArrayList<DBIndexField>();
-
- public int position;
+ private List<IDBIndexField> indexFields = new ArrayList<IDBIndexField>();
- public DBIndex(DBTable table, String name, Type type, IDBField[] fields, int position)
+ public DBIndex(IDBTable table, String name, Type type, IDBField[] fields)
{
super(name);
this.table = table;
@@ -54,8 +55,6 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
IDBField field = fields[i];
addIndexField(field);
}
-
- this.position = position;
}
/**
@@ -70,17 +69,17 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
return SchemaElementType.INDEX;
}
- public DBSchema getSchema()
+ public IDBSchema getSchema()
{
return table.getSchema();
}
- public DBTable getTable()
+ public IDBTable getTable()
{
return table;
}
- public DBTable getParent()
+ public IDBTable getParent()
{
return getTable();
}
@@ -99,22 +98,18 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
@Deprecated
public int getPosition()
{
- return position;
- }
-
- public void setPosition(int position)
- {
- assertUnlocked();
- this.position = position;
+ IDBIndex[] indices = table.getIndices();
+ return Arrays.asList(indices).indexOf(this);
}
- public DBIndexField addIndexField(IDBField field)
+ public IDBIndexField addIndexField(IDBField field)
{
assertUnlocked();
if (type != Type.NON_UNIQUE && !field.isNotNull())
{
- throw new DBException("Index field is nullable: " + field, ((DBField)field).getConstructionStackTrace()); //$NON-NLS-1$
+ Exception constructionStackTrace = ((InternalDBField)field).getConstructionStackTrace();
+ throw new DBException("Index field is nullable: " + field, constructionStackTrace); //$NON-NLS-1$
}
if (field.getTable() != table)
@@ -129,7 +124,7 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
}
int position = indexFields.size();
- DBIndexField indexField = new DBIndexField(this, (DBField)field, position);
+ IDBIndexField indexField = new DBIndexField(this, field, position);
indexFields.add(indexField);
resetElements();
return indexField;
@@ -137,7 +132,7 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
public IDBIndexField addIndexField(String name) throws SchemaElementNotFoundException
{
- DBField field = table.getFieldSafe(name);
+ IDBField field = table.getFieldSafe(name);
return addIndexField(field);
}
@@ -146,12 +141,12 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
assertUnlocked();
boolean found = false;
- for (Iterator<DBIndexField> it = indexFields.iterator(); it.hasNext();)
+ for (Iterator<IDBIndexField> it = indexFields.iterator(); it.hasNext();)
{
- DBIndexField indexField = it.next();
+ IDBIndexField indexField = it.next();
if (found)
{
- indexField.setPosition(indexField.getPosition() - 1);
+ ((InternalDBField)indexField).setPosition(indexField.getPosition() - 1);
}
else if (indexField == indexFieldToRemove)
{
@@ -163,9 +158,9 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
resetElements();
}
- public DBIndexField getIndexFieldSafe(String name) throws SchemaElementNotFoundException
+ public IDBIndexField getIndexFieldSafe(String name) throws SchemaElementNotFoundException
{
- DBIndexField indexField = getIndexField(name);
+ IDBIndexField indexField = getIndexField(name);
if (indexField == null)
{
throw new SchemaElementNotFoundException(this, SchemaElementType.INDEX_FIELD, name);
@@ -174,26 +169,26 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
return indexField;
}
- public DBIndexField getIndexField(String name)
+ public IDBIndexField getIndexField(String name)
{
return findElement(getIndexFields(), name);
}
- public DBIndexField getIndexField(int position)
+ public IDBIndexField getIndexField(int position)
{
return indexFields.get(position);
}
- public DBField getFieldSafe(String name) throws SchemaElementNotFoundException
+ public IDBField getFieldSafe(String name) throws SchemaElementNotFoundException
{
- DBIndexField indexField = getIndexFieldSafe(name);
+ IDBIndexField indexField = getIndexFieldSafe(name);
return indexField.getField();
}
- public DBField getField(String name)
+ public IDBField getField(String name)
{
name = name(name);
- for (DBIndexField indexField : indexFields)
+ for (IDBIndexField indexField : indexFields)
{
if (indexField.getName() == name)
{
@@ -204,7 +199,7 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
return null;
}
- public DBField getField(int position)
+ public IDBField getField(int position)
{
return indexFields.get(position).getField();
}
@@ -214,14 +209,14 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
return indexFields.size();
}
- public DBIndexField[] getIndexFields()
+ public IDBIndexField[] getIndexFields()
{
- return indexFields.toArray(new DBIndexField[indexFields.size()]);
+ return indexFields.toArray(new IDBIndexField[indexFields.size()]);
}
- public DBField[] getFields()
+ public IDBField[] getFields()
{
- DBField[] fields = new DBField[indexFields.size()];
+ IDBField[] fields = new IDBField[indexFields.size()];
for (int i = 0; i < fields.length; i++)
{
fields[i] = getField(i);
@@ -237,7 +232,7 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
public void remove()
{
- table.removeIndex(this);
+ ((InternalDBTable)table).removeIndex(this);
}
@Override
@@ -261,6 +256,6 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
private void assertUnlocked()
{
- table.getSchema().assertUnlocked();
+ ((InternalDBSchema)table.getSchema()).assertUnlocked();
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndexField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndexField.java
index 9fac7e7eb3..f961eead99 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndexField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndexField.java
@@ -10,28 +10,31 @@
*/
package org.eclipse.net4j.internal.db.ddl;
-import org.eclipse.net4j.db.ddl.IDBIndexField;
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
-import org.eclipse.net4j.spi.db.DBSchemaElement;
+import org.eclipse.net4j.spi.db.ddl.InternalDBIndex;
+import org.eclipse.net4j.spi.db.ddl.InternalDBIndexField;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
import java.util.List;
/**
* @author Eike Stepper
*/
-public class DBIndexField extends DBSchemaElement implements IDBIndexField
+public class DBIndexField extends DBSchemaElement implements InternalDBIndexField
{
private static final long serialVersionUID = 1L;
- private DBIndex index;
+ private IDBIndex index;
- private DBField field;
+ private IDBField field;
private int position;
- public DBIndexField(DBIndex index, DBField field, int position)
+ public DBIndexField(IDBIndex index, IDBField field, int position)
{
super(field.getName());
this.index = index;
@@ -51,17 +54,17 @@ public class DBIndexField extends DBSchemaElement implements IDBIndexField
return SchemaElementType.INDEX_FIELD;
}
- public DBIndex getIndex()
+ public IDBIndex getIndex()
{
return index;
}
- public DBIndex getParent()
+ public IDBIndex getParent()
{
return getIndex();
}
- public DBField getField()
+ public IDBField getField()
{
return field;
}
@@ -89,7 +92,7 @@ public class DBIndexField extends DBSchemaElement implements IDBIndexField
public void remove()
{
- index.removeIndexField(this);
+ ((InternalDBIndex)index).removeIndexField(this);
}
@Override
@@ -106,6 +109,6 @@ public class DBIndexField extends DBSchemaElement implements IDBIndexField
private void assertUnlocked()
{
- index.getTable().getSchema().assertUnlocked();
+ ((InternalDBSchema)index.getTable().getSchema()).assertUnlocked();
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBNamedElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBNamedElement.java
index 80c52b94c1..d903aba5b8 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBNamedElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBNamedElement.java
@@ -8,23 +8,22 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.net4j.spi.db;
+package org.eclipse.net4j.internal.db.ddl;
-import org.eclipse.net4j.db.IDBNamedElement;
+import org.eclipse.net4j.db.ddl.IDBNamedElement;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
+import org.eclipse.net4j.spi.db.ddl.InternalDBNamedElement;
import org.eclipse.net4j.util.io.IORuntimeException;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.io.Writer;
/**
- * @author Eike Stepper
* @since 4.2
- * @noextend This class is not intended to be subclassed by clients.
+ * @author Eike Stepper
*/
-public abstract class DBNamedElement extends DBElement implements IDBNamedElement
+public abstract class DBNamedElement extends DBElement implements InternalDBNamedElement
{
private static final long serialVersionUID = 1L;
@@ -109,8 +108,6 @@ public abstract class DBNamedElement extends DBElement implements IDBNamedElemen
}
}
- public abstract void dump(Writer writer) throws IOException;
-
public static String name(String name)
{
return name.toUpperCase().intern();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java
new file mode 100644
index 0000000000..23b7d35797
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java
@@ -0,0 +1,420 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.db.ddl;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.db.IDBRowHandler;
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBIndexField;
+import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBSchemaElement;
+import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.db.ddl.SchemaElementNotFoundException;
+import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
+import org.eclipse.net4j.internal.db.ddl.delta.DBSchemaDelta;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
+
+import javax.sql.DataSource;
+
+import java.io.PrintStream;
+import java.sql.Connection;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBSchema extends DBSchemaElement implements InternalDBSchema
+{
+ private static final long serialVersionUID = 1L;
+
+ private static int indexCounter;
+
+ private Map<String, IDBTable> tables = new HashMap<String, IDBTable>();
+
+ private transient boolean locked;
+
+ public DBSchema(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public DBSchema(IDBSchema source)
+ {
+ super(source.getName());
+
+ for (IDBTable sourceTable : source.getTables())
+ {
+ IDBTable table = addTable(sourceTable.getName());
+
+ for (IDBField sourceField : sourceTable.getFields())
+ {
+ table.addField(sourceField.getName(), sourceField.getType(), sourceField.getPrecision(),
+ sourceField.getScale(), sourceField.isNotNull());
+ }
+
+ for (IDBIndex sourceIndex : sourceTable.getIndices())
+ {
+ IDBIndex index = table.addIndexEmpty(sourceIndex.getName(), sourceIndex.getType());
+ for (IDBField sourceField : sourceIndex.getFields())
+ {
+ IDBField field = table.getField(sourceField.getPosition());
+ index.addIndexField(field);
+ }
+ }
+ }
+ }
+
+ /**
+ * Constructor for deserialization.
+ *
+ * @since 4.2
+ */
+ protected DBSchema()
+ {
+ }
+
+ /**
+ * @since 4.2
+ */
+ public SchemaElementType getSchemaElementType()
+ {
+ return SchemaElementType.SCHEMA;
+ }
+
+ public IDBSchema getSchema()
+ {
+ return this;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public final IDBSchemaElement getParent()
+ {
+ return null;
+ }
+
+ public String getFullName()
+ {
+ return getName();
+ }
+
+ /**
+ * @since 4.2
+ */
+ @SuppressWarnings("unchecked")
+ public final <T extends IDBSchemaElement> T findElement(IDBSchemaElement prototype)
+ {
+ SchemaElementType schemaElementType = prototype.getSchemaElementType();
+ switch (schemaElementType)
+ {
+ case SCHEMA:
+ return (T)(prototype.equals(this) ? this : null);
+
+ case TABLE:
+ return (T)getElement(IDBTable.class, prototype.getName());
+
+ case FIELD:
+ {
+ IDBTable table = getElement(IDBTable.class, prototype.getParent().getName());
+ if (table == null)
+ {
+ return null;
+ }
+
+ return (T)table.getElement(IDBField.class, prototype.getName());
+ }
+
+ case INDEX:
+ {
+ IDBTable table = getElement(IDBTable.class, prototype.getParent().getName());
+ if (table == null)
+ {
+ return null;
+ }
+
+ return (T)table.getElement(IDBIndex.class, prototype.getName());
+ }
+
+ case INDEX_FIELD:
+ {
+ IDBTable table = getElement(IDBTable.class, prototype.getParent().getParent().getName());
+ if (table == null)
+ {
+ return null;
+ }
+
+ IDBIndex index = table.getElement(IDBIndex.class, prototype.getParent().getName());
+ if (index == null)
+ {
+ return null;
+ }
+
+ return (T)index.getElement(IDBIndexField.class, prototype.getName());
+ }
+
+ default:
+ throw new IllegalStateException("Illegal schema element type: " + schemaElementType);
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public IDBTable addTable(String name) throws DBException
+ {
+ assertUnlocked();
+ if (tables.containsKey(name))
+ {
+ throw new DBException("IDBTable exists: " + name); //$NON-NLS-1$
+ }
+
+ IDBTable table = new DBTable(this, name);
+ tables.put(table.getName(), table);
+ resetElements();
+ return table;
+ }
+
+ /**
+ * @since 4.0
+ */
+ public IDBTable removeTable(String name)
+ {
+ assertUnlocked();
+ name = name(name);
+ IDBTable table = tables.remove(name);
+ resetElements();
+ return table;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public final IDBTable getTableSafe(String name) throws SchemaElementNotFoundException
+ {
+ IDBTable table = getTable(name);
+ if (table == null)
+ {
+ throw new SchemaElementNotFoundException(this, SchemaElementType.TABLE, name);
+ }
+
+ return table;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public IDBTable getTable(String name)
+ {
+ name = name(name);
+ return tables.get(name);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public IDBTable[] getTables()
+ {
+ return tables.values().toArray(new IDBTable[tables.size()]);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public void remove()
+ {
+ assertUnlocked();
+ tables.clear();
+ }
+
+ public boolean isLocked()
+ {
+ return locked;
+ }
+
+ public boolean lock()
+ {
+ return locked = true;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public boolean unlock()
+ {
+ return locked = false;
+ }
+
+ public void assertUnlocked() throws DBException
+ {
+ if (locked)
+ {
+ throw new DBException("Schema locked: " + this); //$NON-NLS-1$
+ }
+ }
+
+ public Set<IDBTable> create(IDBAdapter dbAdapter, Connection connection) throws DBException
+ {
+ return dbAdapter.createTables(tables.values(), connection);
+ }
+
+ public Set<IDBTable> create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
+ {
+ return create(dbAdapter, DBUtil.createConnectionProvider(dataSource));
+ }
+
+ public Set<IDBTable> create(IDBAdapter dbAdapter, IDBConnectionProvider connectionProvider) throws DBException
+ {
+ Connection connection = null;
+
+ try
+ {
+ connection = connectionProvider.getConnection();
+ if (connection == null)
+ {
+ throw new DBException("No connection available from " + connectionProvider); //$NON-NLS-1$
+ }
+
+ return create(dbAdapter, connection);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ public void drop(IDBAdapter dbAdapter, Connection connection) throws DBException
+ {
+ dbAdapter.dropTables(tables.values(), connection);
+ }
+
+ public void drop(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
+ {
+ drop(dbAdapter, DBUtil.createConnectionProvider(dataSource));
+ }
+
+ public void drop(IDBAdapter dbAdapter, IDBConnectionProvider connectionProvider) throws DBException
+ {
+ Connection connection = null;
+
+ try
+ {
+ connection = connectionProvider.getConnection();
+ drop(dbAdapter, connection);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ public void export(Connection connection, PrintStream out) throws DBException
+ {
+ for (IDBTable table : getTables())
+ {
+ export(table, connection, out);
+ }
+ }
+
+ private void export(final IDBTable table, Connection connection, final PrintStream out)
+ {
+ if (DBUtil.select(connection, new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ if (row == 0)
+ {
+ String tableName = table.getName();
+ out.println(tableName);
+ for (int i = 0; i < tableName.length(); i++)
+ {
+ out.print("="); //$NON-NLS-1$
+ }
+
+ out.println();
+ }
+
+ out.println(Arrays.asList(values));
+ return true;
+ }
+ }, table.getFields()) > 0)
+
+ {
+ out.println();
+ }
+ }
+
+ public void export(DataSource dataSource, PrintStream out) throws DBException
+ {
+ export(DBUtil.createConnectionProvider(dataSource), out);
+ }
+
+ public void export(IDBConnectionProvider connectionProvider, PrintStream out) throws DBException
+ {
+ Connection connection = null;
+
+ try
+ {
+ connection = connectionProvider.getConnection();
+ export(connection, out);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ /**
+ * @since 4.2
+ */
+ public IDBSchemaDelta compare(IDBSchema oldSchema)
+ {
+ return new DBSchemaDelta(this, oldSchema);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public String createIndexName(IDBTable table, IDBIndex.Type type, IDBField[] fields, int position)
+ {
+ return "I" + System.currentTimeMillis() + "_" + ++indexCounter;
+ }
+
+ /**
+ * @since 4.2
+ */
+ @Override
+ protected void collectElements(List<IDBSchemaElement> elements)
+ {
+ elements.addAll(tables.values());
+ }
+
+ /**
+ * @since 4.2
+ */
+ @Override
+ protected void doAccept(IDBSchemaVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchemaElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java
index 56ad7399b2..ca8a67bc73 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchemaElement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java
@@ -8,11 +8,12 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.net4j.spi.db;
+package org.eclipse.net4j.internal.db.ddl;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor.StopRecursion;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchemaElement;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.collection.PositionProvider;
@@ -23,11 +24,10 @@ import java.util.Arrays;
import java.util.List;
/**
- * @author Eike Stepper
* @since 4.2
- * @noextend This class is not intended to be subclassed by clients.
+ * @author Eike Stepper
*/
-public abstract class DBSchemaElement extends DBNamedElement implements IDBSchemaElement
+public abstract class DBSchemaElement extends DBNamedElement implements InternalDBSchemaElement
{
private static final long serialVersionUID = 1L;
@@ -133,7 +133,6 @@ public abstract class DBSchemaElement extends DBNamedElement implements IDBSchem
protected abstract void doAccept(IDBSchemaVisitor visitor);
- @Override
public void dump(Writer writer) throws IOException
{
SchemaElementType schemaElementType = getSchemaElementType();
@@ -151,7 +150,7 @@ public abstract class DBSchemaElement extends DBNamedElement implements IDBSchem
for (IDBSchemaElement element : getElements())
{
- ((DBSchemaElement)element).dump(writer);
+ ((InternalDBSchemaElement)element).dump(writer);
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java
index 555bcd97bb..6adb743e1a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java
@@ -14,12 +14,13 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
-import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.SchemaElementNotFoundException;
-import org.eclipse.net4j.spi.db.DBSchema;
-import org.eclipse.net4j.spi.db.DBSchemaElement;
+import org.eclipse.net4j.spi.db.ddl.InternalDBField;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
+import org.eclipse.net4j.spi.db.ddl.InternalDBTable;
import java.util.ArrayList;
import java.util.Iterator;
@@ -28,21 +29,17 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class DBTable extends DBSchemaElement implements IDBTable
+public class DBTable extends DBSchemaElement implements InternalDBTable
{
- public static final IDBField[] NO_FIELDS = {};
-
- public static final IDBIndex[] NO_INDICES = {};
-
private static final long serialVersionUID = 1L;
- private DBSchema schema;
+ private IDBSchema schema;
- private List<DBField> fields = new ArrayList<DBField>();
+ private List<IDBField> fields = new ArrayList<IDBField>();
- private List<DBIndex> indices = new ArrayList<DBIndex>();
+ private List<IDBIndex> indices = new ArrayList<IDBIndex>();
- public DBTable(DBSchema schema, String name)
+ public DBTable(IDBSchema schema, String name)
{
super(name);
this.schema = schema;
@@ -60,42 +57,42 @@ public class DBTable extends DBSchemaElement implements IDBTable
return SchemaElementType.TABLE;
}
- public DBSchema getSchema()
+ public IDBSchema getSchema()
{
return schema;
}
- public DBSchema getParent()
+ public IDBSchema getParent()
{
return getSchema();
}
- public DBField addField(String name, DBType type)
+ public IDBField addField(String name, DBType type)
{
return addField(name, type, IDBField.DEFAULT, IDBField.DEFAULT, false);
}
- public DBField addField(String name, DBType type, boolean notNull)
+ public IDBField addField(String name, DBType type, boolean notNull)
{
return addField(name, type, IDBField.DEFAULT, IDBField.DEFAULT, notNull);
}
- public DBField addField(String name, DBType type, int precision)
+ public IDBField addField(String name, DBType type, int precision)
{
return addField(name, type, precision, IDBField.DEFAULT, false);
}
- public DBField addField(String name, DBType type, int precision, boolean notNull)
+ public IDBField addField(String name, DBType type, int precision, boolean notNull)
{
return addField(name, type, precision, IDBField.DEFAULT, notNull);
}
- public DBField addField(String name, DBType type, int precision, int scale)
+ public IDBField addField(String name, DBType type, int precision, int scale)
{
return addField(name, type, precision, scale, false);
}
- public DBField addField(String name, DBType type, int precision, int scale, boolean notNull)
+ public IDBField addField(String name, DBType type, int precision, int scale, boolean notNull)
{
assertUnlocked();
@@ -105,7 +102,7 @@ public class DBTable extends DBSchemaElement implements IDBTable
}
int position = fields.size();
- DBField field = new DBField(this, name, type, precision, scale, notNull, position);
+ IDBField field = new DBField(this, name, type, precision, scale, notNull, position);
fields.add(field);
resetElements();
return field;
@@ -116,12 +113,12 @@ public class DBTable extends DBSchemaElement implements IDBTable
assertUnlocked();
boolean found = false;
- for (Iterator<DBField> it = fields.iterator(); it.hasNext();)
+ for (Iterator<IDBField> it = fields.iterator(); it.hasNext();)
{
- DBField field = it.next();
+ IDBField field = it.next();
if (found)
{
- field.setPosition(field.getPosition() - 1);
+ ((InternalDBField)field).setPosition(field.getPosition() - 1);
}
else if (field == fieldToRemove)
{
@@ -133,9 +130,9 @@ public class DBTable extends DBSchemaElement implements IDBTable
resetElements();
}
- public DBField getFieldSafe(String name) throws SchemaElementNotFoundException
+ public IDBField getFieldSafe(String name) throws SchemaElementNotFoundException
{
- DBField field = getField(name);
+ IDBField field = getField(name);
if (field == null)
{
throw new SchemaElementNotFoundException(this, SchemaElementType.FIELD, name);
@@ -144,12 +141,12 @@ public class DBTable extends DBSchemaElement implements IDBTable
return field;
}
- public DBField getField(String name)
+ public IDBField getField(String name)
{
return findElement(getFields(), name);
}
- public DBField getField(int position)
+ public IDBField getField(int position)
{
return fields.get(position);
}
@@ -159,31 +156,31 @@ public class DBTable extends DBSchemaElement implements IDBTable
return fields.size();
}
- public DBField[] getFields()
+ public IDBField[] getFields()
{
- return fields.toArray(new DBField[fields.size()]);
+ return fields.toArray(new IDBField[fields.size()]);
}
- public DBField[] getFields(String... fieldNames) throws SchemaElementNotFoundException
+ public IDBField[] getFields(String... fieldNames) throws SchemaElementNotFoundException
{
- List<DBField> result = new ArrayList<DBField>();
+ List<IDBField> result = new ArrayList<IDBField>();
for (String fieldName : fieldNames)
{
- DBField field = getFieldSafe(fieldName);
+ IDBField field = getFieldSafe(fieldName);
result.add(field);
}
- return result.toArray(new DBField[result.size()]);
+ return result.toArray(new IDBField[result.size()]);
}
- public DBIndex addIndex(String name, IDBIndex.Type type, IDBField... fields)
+ public IDBIndex addIndex(String name, IDBIndex.Type type, IDBField... fields)
{
assertUnlocked();
- int position = indices.size();
if (name == null)
{
- name = schema.createIndexName(this, type, fields, position);
+ int position = indices.size();
+ name = ((InternalDBSchema)schema).createIndexName(this, type, fields, position);
}
if (getIndex(name) != null)
@@ -193,7 +190,7 @@ public class DBTable extends DBSchemaElement implements IDBTable
if (type == IDBIndex.Type.PRIMARY_KEY)
{
- for (DBIndex index : getIndices())
+ for (IDBIndex index : getIndices())
{
if (index.getType() == IDBIndex.Type.PRIMARY_KEY)
{
@@ -202,64 +199,50 @@ public class DBTable extends DBSchemaElement implements IDBTable
}
}
- DBIndex index = new DBIndex(this, name, type, fields, position);
+ IDBIndex index = new DBIndex(this, name, type, fields);
indices.add(index);
resetElements();
return index;
}
- public DBIndex addIndex(String name, IDBIndex.Type type, String... fieldNames)
+ public IDBIndex addIndex(String name, IDBIndex.Type type, String... fieldNames)
{
return addIndex(name, type, getFields(fieldNames));
}
- public DBIndex addIndexEmpty(String name, IDBIndex.Type type)
+ public IDBIndex addIndexEmpty(String name, IDBIndex.Type type)
{
return addIndex(name, type, NO_FIELDS);
}
- public DBIndex addIndex(IDBIndex.Type type, IDBField... fields)
+ public IDBIndex addIndex(IDBIndex.Type type, IDBField... fields)
{
return addIndex(null, type, fields);
}
- public DBIndex addIndex(IDBIndex.Type type, String... fieldNames)
+ public IDBIndex addIndex(IDBIndex.Type type, String... fieldNames)
{
- DBField[] fields = getFields(fieldNames);
+ IDBField[] fields = getFields(fieldNames);
return addIndex(type, fields);
}
- public DBIndex addIndexEmpty(IDBIndex.Type type)
+ public IDBIndex addIndexEmpty(IDBIndex.Type type)
{
return addIndex(type, NO_FIELDS);
}
- @SuppressWarnings("deprecation")
public void removeIndex(IDBIndex indexToRemove)
{
assertUnlocked();
-
- boolean found = false;
- for (Iterator<DBIndex> it = indices.iterator(); it.hasNext();)
+ if (indices.remove(indexToRemove))
{
- DBIndex index = it.next();
- if (found)
- {
- index.setPosition(index.getPosition() - 1);
- }
- else if (index == indexToRemove)
- {
- it.remove();
- found = true;
- }
+ resetElements();
}
-
- resetElements();
}
- public DBIndex getIndexSafe(String name) throws SchemaElementNotFoundException
+ public IDBIndex getIndexSafe(String name) throws SchemaElementNotFoundException
{
- DBIndex index = getIndex(name);
+ IDBIndex index = getIndex(name);
if (index == null)
{
throw new SchemaElementNotFoundException(this, SchemaElementType.INDEX, name);
@@ -268,12 +251,12 @@ public class DBTable extends DBSchemaElement implements IDBTable
return index;
}
- public DBIndex getIndex(String name)
+ public IDBIndex getIndex(String name)
{
return findElement(getIndices(), name);
}
- public DBIndex getIndex(int position)
+ public IDBIndex getIndex(int position)
{
return indices.get(position);
}
@@ -283,14 +266,14 @@ public class DBTable extends DBSchemaElement implements IDBTable
return indices.size();
}
- public DBIndex[] getIndices()
+ public IDBIndex[] getIndices()
{
- return indices.toArray(new DBIndex[indices.size()]);
+ return indices.toArray(new IDBIndex[indices.size()]);
}
- public DBIndex getPrimaryKeyIndex()
+ public IDBIndex getPrimaryKeyIndex()
{
- for (DBIndex index : indices)
+ for (IDBIndex index : indices)
{
if (index.getType() == IDBIndex.Type.PRIMARY_KEY)
{
@@ -347,6 +330,6 @@ public class DBTable extends DBSchemaElement implements IDBTable
private void assertUnlocked()
{
- schema.assertUnlocked();
+ ((InternalDBSchema)schema).assertUnlocked();
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBDelta.java
index facd440dd3..adfbd9f60c 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBDelta.java
@@ -14,8 +14,8 @@ import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.delta.IDBDelta;
import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor;
import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor.StopRecursion;
-import org.eclipse.net4j.spi.db.DBNamedElement;
-import org.eclipse.net4j.spi.db.DBSchemaElement;
+import org.eclipse.net4j.internal.db.ddl.DBNamedElement;
+import org.eclipse.net4j.internal.db.ddl.DBSchemaElement;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.collection.PositionProvider;
@@ -134,7 +134,6 @@ public abstract class DBDelta extends DBNamedElement implements IDBDelta
protected abstract void collectElements(List<IDBDelta> elements);
- @Override
public void dump(Writer writer) throws IOException
{
int level = getLevel();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java
index 685acdfdd1..da3976cbe2 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java
@@ -11,12 +11,12 @@
package org.eclipse.net4j.internal.db.ddl.delta;
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor;
import org.eclipse.net4j.db.ddl.delta.IDBFieldDelta;
import org.eclipse.net4j.db.ddl.delta.IDBPropertyDelta;
-import org.eclipse.net4j.internal.db.ddl.DBField;
-import org.eclipse.net4j.internal.db.ddl.DBTable;
import org.eclipse.net4j.util.ObjectUtil;
import java.text.MessageFormat;
@@ -33,7 +33,7 @@ public final class DBFieldDelta extends DBDeltaWithPosition implements IDBFieldD
super(parent, name, changeKind);
}
- public DBFieldDelta(DBDelta parent, DBField field, DBField oldField)
+ public DBFieldDelta(DBDelta parent, IDBField field, IDBField oldField)
{
this(parent, getName(field, oldField), getChangeKind(field, oldField));
@@ -95,9 +95,9 @@ public final class DBFieldDelta extends DBDeltaWithPosition implements IDBFieldD
return (DBTableDelta)super.getParent();
}
- public DBField getSchemaElement(IDBSchema schema)
+ public IDBField getSchemaElement(IDBSchema schema)
{
- DBTable table = getParent().getSchemaElement(schema);
+ IDBTable table = getParent().getSchemaElement(schema);
if (table == null)
{
return null;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexDelta.java
index bfe0ba64ce..98747291f1 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexDelta.java
@@ -13,14 +13,13 @@ package org.eclipse.net4j.internal.db.ddl.delta;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBIndexField;
import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.delta.IDBDelta;
import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor;
import org.eclipse.net4j.db.ddl.delta.IDBIndexDelta;
import org.eclipse.net4j.db.ddl.delta.IDBIndexFieldDelta;
import org.eclipse.net4j.db.ddl.delta.IDBPropertyDelta;
-import org.eclipse.net4j.internal.db.ddl.DBIndex;
-import org.eclipse.net4j.internal.db.ddl.DBIndexField;
-import org.eclipse.net4j.internal.db.ddl.DBTable;
+import org.eclipse.net4j.spi.db.ddl.InternalDBIndex;
import org.eclipse.net4j.util.ObjectUtil;
import java.text.MessageFormat;
@@ -44,7 +43,7 @@ public final class DBIndexDelta extends DBDeltaWithProperties implements IDBInde
super(parent, name, changeKind);
}
- public DBIndexDelta(DBDelta parent, DBIndex index, DBIndex oldIndex)
+ public DBIndexDelta(DBDelta parent, IDBIndex index, IDBIndex oldIndex)
{
this(parent, getName(index, oldIndex), getChangeKind(index, oldIndex));
@@ -56,14 +55,13 @@ public final class DBIndexDelta extends DBDeltaWithProperties implements IDBInde
oldType));
}
- IDBIndexField[] indexFields = index == null ? DBIndex.NO_INDEX_FIELDS : index.getIndexFields();
- IDBIndexField[] oldIndexFields = oldIndex == null ? DBIndex.NO_INDEX_FIELDS : oldIndex.getIndexFields();
+ IDBIndexField[] indexFields = index == null ? InternalDBIndex.NO_INDEX_FIELDS : index.getIndexFields();
+ IDBIndexField[] oldIndexFields = oldIndex == null ? InternalDBIndex.NO_INDEX_FIELDS : oldIndex.getIndexFields();
compare(indexFields, oldIndexFields, new SchemaElementComparator<IDBIndexField>()
{
public void compare(IDBIndexField indexField, IDBIndexField oldIndexField)
{
- DBIndexFieldDelta indexFieldDelta = new DBIndexFieldDelta(DBIndexDelta.this, (DBIndexField)indexField,
- (DBIndexField)oldIndexField);
+ DBIndexFieldDelta indexFieldDelta = new DBIndexFieldDelta(DBIndexDelta.this, indexField, oldIndexField);
if (!indexFieldDelta.isEmpty())
{
addIndexFieldDelta(indexFieldDelta);
@@ -125,9 +123,9 @@ public final class DBIndexDelta extends DBDeltaWithProperties implements IDBInde
return result;
}
- public DBIndex getSchemaElement(IDBSchema schema)
+ public IDBIndex getSchemaElement(IDBSchema schema)
{
- DBTable table = getParent().getSchemaElement(schema);
+ IDBTable table = getParent().getSchemaElement(schema);
if (table == null)
{
return null;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexFieldDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexFieldDelta.java
index e6f3ad509f..dc38578e97 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexFieldDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBIndexFieldDelta.java
@@ -10,12 +10,12 @@
*/
package org.eclipse.net4j.internal.db.ddl.delta;
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBIndexField;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor;
import org.eclipse.net4j.db.ddl.delta.IDBIndexFieldDelta;
import org.eclipse.net4j.db.ddl.delta.IDBPropertyDelta;
-import org.eclipse.net4j.internal.db.ddl.DBIndex;
-import org.eclipse.net4j.internal.db.ddl.DBIndexField;
import org.eclipse.net4j.util.ObjectUtil;
import java.text.MessageFormat;
@@ -32,7 +32,7 @@ public final class DBIndexFieldDelta extends DBDeltaWithPosition implements IDBI
super(parent, name, changeKind);
}
- public DBIndexFieldDelta(DBIndexDelta parent, DBIndexField indexField, DBIndexField oldIndexField)
+ public DBIndexFieldDelta(DBIndexDelta parent, IDBIndexField indexField, IDBIndexField oldIndexField)
{
this(parent, getName(indexField, oldIndexField), getChangeKind(indexField, oldIndexField));
@@ -63,9 +63,9 @@ public final class DBIndexFieldDelta extends DBDeltaWithPosition implements IDBI
return (DBIndexDelta)super.getParent();
}
- public DBIndexField getSchemaElement(IDBSchema schema)
+ public IDBIndexField getSchemaElement(IDBSchema schema)
{
- DBIndex index = getParent().getSchemaElement(schema);
+ IDBIndex index = getParent().getSchemaElement(schema);
if (index == null)
{
return null;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java
index 385d7436f4..06f00bb66e 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java
@@ -23,8 +23,7 @@ import org.eclipse.net4j.db.ddl.delta.IDBIndexDelta;
import org.eclipse.net4j.db.ddl.delta.IDBIndexFieldDelta;
import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
import org.eclipse.net4j.db.ddl.delta.IDBTableDelta;
-import org.eclipse.net4j.internal.db.ddl.DBTable;
-import org.eclipse.net4j.spi.db.DBSchema;
+import org.eclipse.net4j.spi.db.ddl.InternalDBSchema;
import java.text.MessageFormat;
import java.util.Arrays;
@@ -47,17 +46,17 @@ public final class DBSchemaDelta extends DBDelta implements IDBSchemaDelta
super(null, name, changeKind);
}
- public DBSchemaDelta(DBSchema schema, IDBSchema oldSchema)
+ public DBSchemaDelta(IDBSchema schema, IDBSchema oldSchema)
{
this(schema.getName(), oldSchema == null ? ChangeKind.ADD : ChangeKind.CHANGE);
IDBTable[] tables = schema.getTables();
- IDBTable[] oldTables = oldSchema == null ? DBSchema.NO_TABLES : oldSchema.getTables();
+ IDBTable[] oldTables = oldSchema == null ? InternalDBSchema.NO_TABLES : oldSchema.getTables();
compare(tables, oldTables, new SchemaElementComparator<IDBTable>()
{
public void compare(IDBTable table, IDBTable oldTable)
{
- DBTableDelta tableDelta = new DBTableDelta(DBSchemaDelta.this, (DBTable)table, (DBTable)oldTable);
+ DBTableDelta tableDelta = new DBTableDelta(DBSchemaDelta.this, table, oldTable);
if (!tableDelta.isEmpty())
{
addTableDelta(tableDelta);
@@ -106,9 +105,9 @@ public final class DBSchemaDelta extends DBDelta implements IDBSchemaDelta
resetElements();
}
- public DBSchema getSchemaElement(IDBSchema schema)
+ public IDBSchema getSchemaElement(IDBSchema schema)
{
- return (DBSchema)schema;
+ return schema;
}
public void applyTo(IDBSchema schema)
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBTableDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBTableDelta.java
index 596ecc5158..1792f68471 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBTableDelta.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBTableDelta.java
@@ -13,14 +13,13 @@ package org.eclipse.net4j.internal.db.ddl.delta;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.delta.IDBDelta;
import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor;
import org.eclipse.net4j.db.ddl.delta.IDBFieldDelta;
import org.eclipse.net4j.db.ddl.delta.IDBIndexDelta;
import org.eclipse.net4j.db.ddl.delta.IDBTableDelta;
-import org.eclipse.net4j.internal.db.ddl.DBField;
-import org.eclipse.net4j.internal.db.ddl.DBIndex;
-import org.eclipse.net4j.internal.db.ddl.DBTable;
+import org.eclipse.net4j.spi.db.ddl.InternalDBTable;
import java.text.MessageFormat;
import java.util.Arrays;
@@ -45,17 +44,17 @@ public final class DBTableDelta extends DBDelta implements IDBTableDelta
super(parent, name, changeKind);
}
- public DBTableDelta(DBSchemaDelta parent, DBTable table, DBTable oldTable)
+ public DBTableDelta(DBSchemaDelta parent, IDBTable table, IDBTable oldTable)
{
this(parent, getName(table, oldTable), getChangeKind(table, oldTable));
- IDBField[] fields = table == null ? DBTable.NO_FIELDS : table.getFields();
- IDBField[] oldFields = oldTable == null ? DBTable.NO_FIELDS : oldTable.getFields();
+ IDBField[] fields = table == null ? InternalDBTable.NO_FIELDS : table.getFields();
+ IDBField[] oldFields = oldTable == null ? InternalDBTable.NO_FIELDS : oldTable.getFields();
compare(fields, oldFields, new SchemaElementComparator<IDBField>()
{
public void compare(IDBField field, IDBField oldField)
{
- DBFieldDelta fieldDelta = new DBFieldDelta(DBTableDelta.this, (DBField)field, (DBField)oldField);
+ DBFieldDelta fieldDelta = new DBFieldDelta(DBTableDelta.this, field, oldField);
if (!fieldDelta.isEmpty())
{
addFieldDelta(fieldDelta);
@@ -63,13 +62,13 @@ public final class DBTableDelta extends DBDelta implements IDBTableDelta
}
});
- IDBIndex[] indices = table == null ? DBTable.NO_INDICES : table.getIndices();
- IDBIndex[] oldIndices = oldTable == null ? DBTable.NO_INDICES : oldTable.getIndices();
+ IDBIndex[] indices = table == null ? InternalDBTable.NO_INDICES : table.getIndices();
+ IDBIndex[] oldIndices = oldTable == null ? InternalDBTable.NO_INDICES : oldTable.getIndices();
compare(indices, oldIndices, new SchemaElementComparator<IDBIndex>()
{
public void compare(IDBIndex index, IDBIndex oldIndex)
{
- DBIndexDelta indexDelta = new DBIndexDelta(DBTableDelta.this, (DBIndex)index, (DBIndex)oldIndex);
+ DBIndexDelta indexDelta = new DBIndexDelta(DBTableDelta.this, index, oldIndex);
if (!indexDelta.isEmpty())
{
addIndexDelta(indexDelta);
@@ -153,9 +152,9 @@ public final class DBTableDelta extends DBDelta implements IDBTableDelta
return result;
}
- public DBTable getSchemaElement(IDBSchema schema)
+ public IDBTable getSchemaElement(IDBSchema schema)
{
- return (DBTable)schema.getTable(getName());
+ return schema.getTable(getName());
}
@Override
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
index 85e9b82144..d111d42838 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
@@ -138,9 +138,7 @@ public abstract class DBAdapter implements IDBAdapter
*/
public IDBSchema readSchema(Connection connection, String name)
{
- DBSchema schema = new DBSchema(name);
- readSchema(connection, schema);
- return schema;
+ return DBUtil.readSchema(this, connection, name);
}
/**
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchema.java
index 8afdead23e..d35d963cbf 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBSchema.java
@@ -14,51 +14,29 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.db.IDBRowHandler;
-import org.eclipse.net4j.db.ddl.IDBField;
-import org.eclipse.net4j.db.ddl.IDBIndex;
-import org.eclipse.net4j.db.ddl.IDBIndexField;
import org.eclipse.net4j.db.ddl.IDBSchema;
-import org.eclipse.net4j.db.ddl.IDBSchemaElement;
-import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.db.ddl.SchemaElementNotFoundException;
-import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
-import org.eclipse.net4j.internal.db.ddl.DBField;
-import org.eclipse.net4j.internal.db.ddl.DBIndex;
-import org.eclipse.net4j.internal.db.ddl.DBTable;
-import org.eclipse.net4j.internal.db.ddl.delta.DBSchemaDelta;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
import javax.sql.DataSource;
import java.io.PrintStream;
import java.sql.Connection;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ExecutorService;
/**
- * A useful base class for implementing custom {@link IDBSchema DB schemas}.
- *
* @author Eike Stepper
+ * @deprecated As of 4.2 call {@link DBUtil#createSchema(String)}, {@link DBUtil#createSchema(DataSource, String, boolean)},
+ * {@link DBUtil#readSchema(IDBAdapter, Connection, IDBSchema)}, {@link DBUtil#readSchema(IDBAdapter, Connection, String)}
+ * or {@link DBUtil#copySchema(IDBSchema)}.
*/
-public class DBSchema extends DBSchemaElement implements IDBSchema
+@Deprecated
+public class DBSchema extends org.eclipse.net4j.internal.db.ddl.DBSchema
{
- /**
- * @since 4.2
- */
- public static final IDBTable[] NO_TABLES = {};
-
private static final long serialVersionUID = 1L;
- private static int indexCounter;
-
- private Map<String, DBTable> tables = new HashMap<String, DBTable>();
-
- private transient boolean locked;
-
public DBSchema(String name)
{
super(name);
@@ -69,28 +47,7 @@ public class DBSchema extends DBSchemaElement implements IDBSchema
*/
public DBSchema(IDBSchema source)
{
- super(source.getName());
-
- for (IDBTable sourceTable : source.getTables())
- {
- DBTable table = (DBTable)addTable(sourceTable.getName());
-
- for (IDBField sourceField : sourceTable.getFields())
- {
- table.addField(sourceField.getName(), sourceField.getType(), sourceField.getPrecision(),
- sourceField.getScale(), sourceField.isNotNull());
- }
-
- for (IDBIndex sourceIndex : sourceTable.getIndices())
- {
- DBIndex index = table.addIndexEmpty(sourceIndex.getName(), sourceIndex.getType());
- for (IDBField sourceField : sourceIndex.getFields())
- {
- DBField field = table.getField(sourceField.getPosition());
- index.addIndexField(field);
- }
- }
- }
+ super(source);
}
/**
@@ -102,328 +59,195 @@ public class DBSchema extends DBSchemaElement implements IDBSchema
{
}
- /**
- * @since 4.2
- */
- public SchemaElementType getSchemaElementType()
- {
- return SchemaElementType.SCHEMA;
- }
-
+ @Override
public IDBSchema getSchema()
{
- return this;
- }
-
- /**
- * @since 4.2
- */
- public final IDBSchemaElement getParent()
- {
- return null;
+ return super.getSchema();
}
+ @Override
public String getFullName()
{
- return getName();
- }
-
- /**
- * @since 4.2
- */
- @SuppressWarnings("unchecked")
- public final <T extends IDBSchemaElement> T findElement(IDBSchemaElement prototype)
- {
- SchemaElementType schemaElementType = prototype.getSchemaElementType();
- switch (schemaElementType)
- {
- case SCHEMA:
- return (T)(prototype.equals(this) ? this : null);
-
- case TABLE:
- return (T)getElement(IDBTable.class, prototype.getName());
-
- case FIELD:
- {
- IDBTable table = getElement(IDBTable.class, prototype.getParent().getName());
- if (table == null)
- {
- return null;
- }
-
- return (T)table.getElement(IDBField.class, prototype.getName());
- }
-
- case INDEX:
- {
- IDBTable table = getElement(IDBTable.class, prototype.getParent().getName());
- if (table == null)
- {
- return null;
- }
-
- return (T)table.getElement(IDBIndex.class, prototype.getName());
- }
-
- case INDEX_FIELD:
- {
- IDBTable table = getElement(IDBTable.class, prototype.getParent().getParent().getName());
- if (table == null)
- {
- return null;
- }
-
- IDBIndex index = table.getElement(IDBIndex.class, prototype.getParent().getName());
- if (index == null)
- {
- return null;
- }
-
- return (T)index.getElement(IDBIndexField.class, prototype.getName());
- }
-
- default:
- throw new IllegalStateException("Illegal schema element type: " + schemaElementType);
- }
+ return super.getFullName();
}
- /**
- * @since 2.0
- */
+ @Override
public IDBTable addTable(String name) throws DBException
{
- assertUnlocked();
- if (tables.containsKey(name))
- {
- throw new DBException("DBTable exists: " + name); //$NON-NLS-1$
- }
-
- DBTable table = new DBTable(this, name);
- tables.put(table.getName(), table);
- resetElements();
- return table;
+ return super.addTable(name);
}
- /**
- * @since 4.0
- */
+ @Override
public IDBTable removeTable(String name)
{
- assertUnlocked();
- name = name(name);
- DBTable table = tables.remove(name);
- resetElements();
- return table;
- }
-
- /**
- * @since 4.2
- */
- public final IDBTable getTableSafe(String name) throws SchemaElementNotFoundException
- {
- IDBTable table = getTable(name);
- if (table == null)
- {
- throw new SchemaElementNotFoundException(this, SchemaElementType.TABLE, name);
- }
-
- return table;
+ return super.removeTable(name);
}
- /**
- * @since 2.0
- */
+ @Override
public IDBTable getTable(String name)
{
- name = name(name);
- return tables.get(name);
+ return super.getTable(name);
}
- /**
- * @since 2.0
- */
+ @Override
public IDBTable[] getTables()
{
- return tables.values().toArray(new DBTable[tables.size()]);
- }
-
- /**
- * @since 4.2
- */
- public void remove()
- {
- assertUnlocked();
- tables.clear();
+ return super.getTables();
}
+ @Override
public boolean isLocked()
{
- return locked;
+ return super.isLocked();
}
+ @Override
public boolean lock()
{
- return locked = true;
- }
-
- /**
- * @since 4.2
- */
- public boolean unlock()
- {
- return locked = false;
+ return super.lock();
}
+ @Override
public void assertUnlocked() throws DBException
{
- if (locked)
- {
- throw new DBException("Schema locked: " + this); //$NON-NLS-1$
- }
+ super.assertUnlocked();
}
+ @Override
public Set<IDBTable> create(IDBAdapter dbAdapter, Connection connection) throws DBException
{
- return dbAdapter.createTables(tables.values(), connection);
+ return super.create(dbAdapter, connection);
}
+ @Override
public Set<IDBTable> create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
{
- return create(dbAdapter, DBUtil.createConnectionProvider(dataSource));
+ return super.create(dbAdapter, dataSource);
}
+ @Override
public Set<IDBTable> create(IDBAdapter dbAdapter, IDBConnectionProvider connectionProvider) throws DBException
{
- Connection connection = null;
-
- try
- {
- connection = connectionProvider.getConnection();
- if (connection == null)
- {
- throw new DBException("No connection available from " + connectionProvider); //$NON-NLS-1$
- }
-
- return create(dbAdapter, connection);
- }
- finally
- {
- DBUtil.close(connection);
- }
+ return super.create(dbAdapter, connectionProvider);
}
+ @Override
public void drop(IDBAdapter dbAdapter, Connection connection) throws DBException
{
- dbAdapter.dropTables(tables.values(), connection);
+ super.drop(dbAdapter, connection);
}
+ @Override
public void drop(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
{
- drop(dbAdapter, DBUtil.createConnectionProvider(dataSource));
+ super.drop(dbAdapter, dataSource);
}
+ @Override
public void drop(IDBAdapter dbAdapter, IDBConnectionProvider connectionProvider) throws DBException
{
- Connection connection = null;
-
- try
- {
- connection = connectionProvider.getConnection();
- drop(dbAdapter, connection);
- }
- finally
- {
- DBUtil.close(connection);
- }
+ super.drop(dbAdapter, connectionProvider);
}
+ @Override
public void export(Connection connection, PrintStream out) throws DBException
{
- for (IDBTable table : getTables())
- {
- export(table, connection, out);
- }
+ super.export(connection, out);
}
- private void export(final IDBTable table, Connection connection, final PrintStream out)
+ @Override
+ public void export(DataSource dataSource, PrintStream out) throws DBException
{
- if (DBUtil.select(connection, new IDBRowHandler()
- {
- public boolean handle(int row, Object... values)
- {
- if (row == 0)
- {
- String tableName = table.getName();
- out.println(tableName);
- for (int i = 0; i < tableName.length(); i++)
- {
- out.print("="); //$NON-NLS-1$
- }
+ super.export(dataSource, out);
+ }
- out.println();
- }
+ @Override
+ public void export(IDBConnectionProvider connectionProvider, PrintStream out) throws DBException
+ {
+ super.export(connectionProvider, out);
+ }
- out.println(Arrays.asList(values));
- return true;
- }
- }, table.getFields()) > 0)
+ @Override
+ public String getName()
+ {
+ return super.getName();
+ }
- {
- out.println();
- }
+ @Override
+ public String toString()
+ {
+ return super.toString();
}
- public void export(DataSource dataSource, PrintStream out) throws DBException
+ @Override
+ public void addListener(IListener listener)
{
- export(DBUtil.createConnectionProvider(dataSource), out);
+ super.addListener(listener);
}
- public void export(IDBConnectionProvider connectionProvider, PrintStream out) throws DBException
+ @Override
+ public void removeListener(IListener listener)
{
- Connection connection = null;
+ super.removeListener(listener);
+ }
- try
- {
- connection = connectionProvider.getConnection();
- export(connection, out);
- }
- finally
- {
- DBUtil.close(connection);
- }
+ @Override
+ public boolean hasListeners()
+ {
+ return super.hasListeners();
}
- /**
- * @since 4.2
- */
- public IDBSchemaDelta compare(IDBSchema oldSchema)
+ @Override
+ public IListener[] getListeners()
{
- return new DBSchemaDelta(this, oldSchema);
+ return super.getListeners();
}
- /**
- * @since 4.2
- */
- public String createIndexName(IDBTable table, IDBIndex.Type type, IDBField[] fields, int position)
+ @Override
+ public void fireEvent()
{
- return "I" + System.currentTimeMillis() + "_" + ++indexCounter;
+ super.fireEvent();
}
- /**
- * @since 4.2
- */
@Override
- protected void collectElements(List<IDBSchemaElement> elements)
+ public void fireEvent(IEvent event)
{
- elements.addAll(tables.values());
+ super.fireEvent(event);
+ }
+
+ @Override
+ public void fireEvent(IEvent event, IListener[] listeners)
+ {
+ super.fireEvent(event, listeners);
+ }
+
+ @Override
+ protected void fireThrowable(Throwable throwable)
+ {
+ super.fireThrowable(throwable);
+ }
+
+ @Override
+ protected ExecutorService getNotificationService()
+ {
+ return super.getNotificationService();
+ }
+
+ @Override
+ protected void firstListenerAdded()
+ {
+ super.firstListenerAdded();
+ }
+
+ @Override
+ protected void lastListenerRemoved()
+ {
+ super.lastListenerRemoved();
}
- /**
- * @since 4.2
- */
@Override
- protected void doAccept(IDBSchemaVisitor visitor)
+ protected void finalize() throws Throwable
{
- visitor.visit(this);
+ super.finalize();
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBElement.java
new file mode 100644
index 0000000000..e823daccca
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBElement.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBElement;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBElement extends IDBElement
+{
+
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBField.java
new file mode 100644
index 0000000000..9a72c3f2b4
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBField.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBField;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBField extends IDBField, InternalDBSchemaElement
+{
+ public void setPosition(int position);
+
+ public Exception getConstructionStackTrace();
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndex.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndex.java
new file mode 100644
index 0000000000..062351b33e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndex.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBIndexField;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBIndex extends IDBIndex, InternalDBSchemaElement
+{
+ public static final IDBIndexField[] NO_INDEX_FIELDS = {};
+
+ public void removeIndexField(IDBIndexField indexFieldToRemove);
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndexField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndexField.java
new file mode 100644
index 0000000000..28bd2dfff5
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBIndexField.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBIndexField;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBIndexField extends IDBIndexField, InternalDBSchemaElement
+{
+ public void setPosition(int position);
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java
new file mode 100644
index 0000000000..23d7831471
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBNamedElement;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBNamedElement extends IDBNamedElement, InternalDBElement
+{
+ public void setName(String name);
+
+ public String dumpToString();
+
+ public void dump();
+
+ public void dump(Writer writer) throws IOException;
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java
new file mode 100644
index 0000000000..12720dabfc
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBSchema extends IDBSchema, InternalDBSchemaElement
+{
+ public static final IDBTable[] NO_TABLES = {};
+
+ public IDBTable addTable(String name);
+
+ public IDBTable removeTable(String name);
+
+ public String createIndexName(IDBTable table, IDBIndex.Type type, IDBField[] fields, int position);
+
+ public boolean lock();
+
+ public boolean unlock();
+
+ public void assertUnlocked() throws DBException;
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchemaElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchemaElement.java
new file mode 100644
index 0000000000..e560758d9f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchemaElement.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBSchemaElement;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBSchemaElement extends IDBSchemaElement, InternalDBNamedElement
+{
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java
new file mode 100644
index 0000000000..9456789f9b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBTable;
+
+/**
+ * @since 4.2
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalDBTable extends IDBTable, InternalDBSchemaElement
+{
+ public static final IDBField[] NO_FIELDS = {};
+
+ public static final IDBIndex[] NO_INDICES = {};
+
+ public void removeField(IDBField fieldToRemove);
+
+ public void removeIndex(IDBIndex indexToRemove);
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/package-info.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/package-info.java
new file mode 100644
index 0000000000..8062c84f43
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/package-info.java
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+
+/**
+ * Server service provider interfaces for the Net4j DB framework.
+ */
+package org.eclipse.net4j.spi.db.ddl;
+
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/package-info.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/package-info.java
index c17213eb58..6dee82cbca 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/package-info.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/package-info.java
@@ -13,3 +13,4 @@
* Server service provider interfaces and useful base implementations for the Net4j DB framework.
*/
package org.eclipse.net4j.spi.db;
+

Back to the top