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
00029 package org.openmobileis.database.fastobjectdb.db.query.soda;
00030
00031 import org.odbms.ObjectSet;
00032 import org.openmobileis.common.util.collection.Array;
00033 import org.openmobileis.database.fastobjectdb.db.FODBCollection;
00034 import org.openmobileis.database.fastobjectdb.db.exception.FODBException;
00035
00042 public class FODBSodaObjectSet implements ObjectSet {
00043 protected Object[] objArray;
00044 private int currentCursor = 0;
00045
00049 public FODBSodaObjectSet() {
00050 super();
00051 this.objArray = new Object[0];
00052 }
00053
00057 public FODBSodaObjectSet(Object[] array) {
00058 super();
00059 this.objArray = array;
00060 }
00061
00062
00063
00064
00065 public boolean hasNext() {
00066 return (currentCursor < objArray.length);
00067 }
00068
00069
00070
00071
00072 public Object next() {
00073 return objArray[currentCursor++];
00074 }
00075
00076
00077
00078
00079 public void reset() {
00080 currentCursor = 0;
00081 }
00082
00083
00084
00085
00086 public int size() {
00087 return objArray.length;
00088 }
00089
00090 protected void addCollectionPtrs(long[] ptrArray, FODBCollection collection) throws FODBException {
00091 Object[] retObj = new Object[ptrArray.length];
00092 int size = ptrArray.length;
00093 for (int i = 0; i < size; i++) {
00094 retObj[i] = collection.getElementAtPos(ptrArray[i]);
00095 }
00096 if (objArray.length > 0) {
00097 int newSize = objArray.length + ptrArray.length;
00098 Object[] newArray = new Object[newSize];
00099 System.arraycopy(objArray, 0, newArray, 0, objArray.length);
00100 System.arraycopy(retObj, 0, newArray, objArray.length, retObj.length);
00101 this.objArray = newArray;
00102 } else {
00103 this.objArray = retObj;
00104 }
00105 }
00106
00107 public Array getArrayFromSet() {
00108 return new Array(objArray);
00109 }
00110
00111 }