initial quantum version
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / model / EntityFactory.java
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityFactory.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityFactory.java
new file mode 100644 (file)
index 0000000..de48c0f
--- /dev/null
@@ -0,0 +1,36 @@
+package com.quantum.model;
+
+
+/**
+ * 
+ * 
+ * @author BC
+ */
+public class EntityFactory {
+    
+    private static EntityFactory instance = new EntityFactory();
+    
+    private EntityFactory() {
+    }
+    
+    public static EntityFactory getInstance() {
+        return EntityFactory.instance;
+    }
+    
+    public Entity create(Bookmark bookmark, String schema, String name, String type) {
+        if (type != null) {
+            type = type.toUpperCase().trim();
+        }
+        
+        if (Entity.TABLE_TYPE.equals(type)) {
+            return new TableImpl(bookmark, schema, name);
+        } else if (Entity.VIEW_TYPE.equals(type)) {
+            return new ViewImpl(bookmark, schema, name);
+        } else if (Entity.SEQUENCE_TYPE.equals(type)) {
+            return new SequenceImpl(bookmark, schema, name);
+        } else {
+            return null;
+//            throw new IllegalArgumentException("Unknown type: " + type);
+        }
+    }
+}