Quantum version 2.4.1
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / sql / SQLResultSetCollection.java
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResultSetCollection.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResultSetCollection.java
new file mode 100644 (file)
index 0000000..09aa993
--- /dev/null
@@ -0,0 +1,56 @@
+package com.quantum.sql;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * @author BC
+ */
+public class SQLResultSetCollection {
+
+       private static final SQLResultSetCollection instance = new SQLResultSetCollection();
+       
+       private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+       
+       private List results = Collections.synchronizedList(new ArrayList());
+       
+       private SQLResultSetCollection() {
+       }
+       public static SQLResultSetCollection getInstance() {
+               return SQLResultSetCollection.instance;
+       }
+       
+       public void addPropertyChangeListener(PropertyChangeListener arg0) {
+               this.propertyChangeSupport.addPropertyChangeListener(arg0);
+       }
+       public void removePropertyChangeListener(PropertyChangeListener arg0) {
+               this.propertyChangeSupport.removePropertyChangeListener(arg0);
+       }
+       
+       public void addSQLResultSet(SQLResultSetResults resultSet) {
+               this.results.add(resultSet);
+               this.propertyChangeSupport.firePropertyChange("resultSets", null, resultSet);
+       }
+
+       public void removeSQLResultSet(SQLResultSetResults resultSet) {
+               if (this.results.remove(resultSet)) {
+                       this.propertyChangeSupport.firePropertyChange("resultSets", resultSet, null);
+               }
+       }
+       
+       public void removeAllSQLResultSet() {
+               if (this.results.size() > 0) {
+                       this.results.clear();
+               }
+               this.propertyChangeSupport.firePropertyChange("resultSets", null, null);
+       }
+       
+       public SQLResultSetResults[] getResultSets() {
+               return (SQLResultSetResults[]) this.results.toArray(
+                               new SQLResultSetResults[this.results.size()]);
+       }
+}