summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-19 10:57:40 (EDT)
committerEike Stepper2007-08-19 10:57:40 (EDT)
commit1ed81906b6ff849f25d67524dfcb93aa5f86aafa (patch)
treeded3acbccde53021bd787b79f958f951069533b9
parent9a5843414dda3f911ffd1c5432f79482e3120ffb (diff)
downloadcdo-1ed81906b6ff849f25d67524dfcb93aa5f86aafa.zip
cdo-1ed81906b6ff849f25d67524dfcb93aa5f86aafa.tar.gz
cdo-1ed81906b6ff849f25d67524dfcb93aa5f86aafa.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBElement.java27
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBIndex.java8
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java6
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java43
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java14
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBIndex.java15
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java18
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java7
10 files changed, 107 insertions, 39 deletions
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/IDBElement.java
new file mode 100644
index 0000000..b0a40e3
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBElement.java
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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.db;
+
+import java.util.Properties;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IDBElement
+{
+ public IDBSchema getSchema();
+
+ public String getName();
+
+ public String getFullName();
+
+ public Properties getProperties();
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java
index c1cc896..1eae204 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java
@@ -13,14 +13,12 @@ package org.eclipse.net4j.db;
/**
* @author Eike Stepper
*/
-public interface IDBField
+public interface IDBField extends IDBElement
{
public static final int DEFAULT = -1;
public IDBTable getTable();
- public String getName();
-
public DBType getType();
public int getPrecision();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBIndex.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBIndex.java
index c9ed339..65a1d7c 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBIndex.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBIndex.java
@@ -13,11 +13,11 @@ package org.eclipse.net4j.db;
/**
* @author Eike Stepper
*/
-public interface IDBIndex
+public interface IDBIndex extends IDBElement
{
- public IDBTable geTable();
+ public IDBTable getTable();
- public Type geType();
+ public Type getType();
public IDBField getField(int index);
@@ -27,8 +27,6 @@ public interface IDBIndex
public int getPosition();
- public String getName();
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
index 23203dd..0dc8227 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
@@ -17,10 +17,8 @@ import java.sql.Connection;
/**
* @author Eike Stepper
*/
-public interface IDBSchema
+public interface IDBSchema extends IDBElement
{
- public String getName();
-
public IDBTable addTable(String name) throws DBException;
public IDBTable getTable(String name);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java
index 4d43132..a9f7d88 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java
@@ -15,12 +15,8 @@ import org.eclipse.net4j.internal.db.DBField;
/**
* @author Eike Stepper
*/
-public interface IDBTable
+public interface IDBTable extends IDBElement
{
- public IDBSchema getSchema();
-
- public String getName();
-
public IDBField addField(String name, DBType type);
public DBField addField(String name, DBType type, boolean notNull);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java
new file mode 100644
index 0000000..22af3c7
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBElement.java
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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;
+
+import org.eclipse.net4j.db.IDBElement;
+
+import java.util.Properties;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DBElement implements IDBElement
+{
+ private Properties properties;
+
+ public DBElement()
+ {
+ }
+
+ public Properties getProperties()
+ {
+ if (properties == null)
+ {
+ properties = new Properties();
+ }
+
+ return properties;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getFullName();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java
index de4a75e..d58b58d 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java
@@ -12,11 +12,12 @@ package org.eclipse.net4j.internal.db;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.IDBField;
+import org.eclipse.net4j.db.IDBSchema;
/**
* @author Eike Stepper
*/
-public class DBField implements IDBField
+public class DBField extends DBElement implements IDBField
{
private static final int DEFAULT_PRECISION = 255;
@@ -45,6 +46,11 @@ public class DBField implements IDBField
this.position = position;
}
+ public IDBSchema getSchema()
+ {
+ return table.getSchema();
+ }
+
public DBTable getTable()
{
return table;
@@ -85,12 +91,6 @@ public class DBField implements IDBField
return table.getName() + "." + name;
}
- @Override
- public String toString()
- {
- return getFullName();
- }
-
public String formatPrecision()
{
return "(" + getPrecision() + ")";
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBIndex.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBIndex.java
index 6a6b3cb..25a4187 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBIndex.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBIndex.java
@@ -12,11 +12,12 @@ package org.eclipse.net4j.internal.db;
import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.db.IDBIndex;
+import org.eclipse.net4j.db.IDBSchema;
/**
* @author Eike Stepper
*/
-public class DBIndex implements IDBIndex
+public class DBIndex extends DBElement implements IDBIndex
{
private DBTable table;
@@ -34,12 +35,17 @@ public class DBIndex implements IDBIndex
this.position = position;
}
- public DBTable geTable()
+ public IDBSchema getSchema()
+ {
+ return table.getSchema();
+ }
+
+ public DBTable getTable()
{
return table;
}
- public Type geType()
+ public Type getType()
{
return type;
}
@@ -69,8 +75,7 @@ public class DBIndex implements IDBIndex
return "idx_" + table.getName() + "_" + position;
}
- @Override
- public String toString()
+ public String getFullName()
{
return getName();
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
index e15a4fe..cb2e9a8 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
@@ -25,7 +25,7 @@ import java.util.Map;
/**
* @author Eike Stepper
*/
-public class DBSchema implements IDBSchema
+public class DBSchema extends DBElement implements IDBSchema
{
private String name;
@@ -38,6 +38,16 @@ public class DBSchema implements IDBSchema
this.name = name;
}
+ public String getFullName()
+ {
+ return name;
+ }
+
+ public IDBSchema getSchema()
+ {
+ return this;
+ }
+
public String getName()
{
return name;
@@ -100,12 +110,6 @@ public class DBSchema implements IDBSchema
dbAdapter.createTables(tables.values(), connection);
}
- @Override
- public String toString()
- {
- return name;
- }
-
void assertUnlocked() throws DBException
{
if (locked)
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
index c5887be..6f27cd6 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class DBTable implements IDBTable
+public class DBTable extends DBElement implements IDBTable
{
private DBSchema schema;
@@ -144,7 +144,7 @@ public class DBTable implements IDBTable
{
for (IDBIndex index : indices)
{
- if (index.geType() == IDBIndex.Type.PRIMARY_KEY)
+ if (index.getType() == IDBIndex.Type.PRIMARY_KEY)
{
return index;
}
@@ -199,8 +199,7 @@ public class DBTable implements IDBTable
}
}
- @Override
- public String toString()
+ public String getFullName()
{
return name;
}