00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.openmobileis.database.fastobjectdb.db;
00029
00030 import java.util.Hashtable;
00031
00032 import org.openmobileis.common.util.collection.Array;
00033
00041 public final class CollectionManager {
00042 protected Array collections;
00043
00047 public CollectionManager() {
00048 super();
00049 collections = new Array();
00050 }
00051
00052 public void addCollection(FODBCollection collection) {
00053 collections.add(collection);
00054 }
00055
00056 public void removeCollection(String collectionName) {
00057 int size = collections.size();
00058 FODBCollection collection = null;
00059 for (int i=0; i<size; i++) {
00060 collection = (FODBCollection)collections.get(i);
00061 if (collection.getName().equals(collectionName)) {
00062 collections.remove(i);
00063 break;
00064 }
00065 }
00066 }
00067
00068 public FODBCollection getCollectionByName(String name) {
00069 FODBCollection col = null;
00070 for (int i=0; i<collections.size(); i++) {
00071 col = (FODBCollection) collections.get(i);
00072 if (col.getName().equals(name)) {
00073 return col;
00074 }
00075 }
00076 return null;
00077 }
00078
00079 public FODBCollection getCollectionByType(Class type) {
00080 FODBCollection col = null;
00081 for (int i=0; i<collections.size(); i++) {
00082 col = (FODBCollection) collections.get(i);
00083 if (col.getCollectionObjectClass().equals(type)) {
00084 return col;
00085 }
00086 }
00087 return null;
00088 }
00089
00090 public Hashtable getCollectionList() {
00091 FODBCollection col = null;
00092 Hashtable list = new Hashtable(collections.size());
00093 for (int i=0; i<collections.size(); i++) {
00094 col = (FODBCollection) collections.get(i);
00095 list.put(col.getName(), col);
00096 }
00097 return list;
00098 }
00099
00100 public Array getCollectionArray() {
00101 return (Array) collections.clone();
00102 }
00103
00104 }