Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

FODBSodaObjectSet.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  *  
00024  *  Modifications :
00025  *  2004 Creation P.Delrieu
00026  *  2004 Modified by Romain Beaugrand
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   /* (non-Javadoc)
00063    * @see org.odbms.ObjectSet#hasNext()
00064    */
00065   public boolean hasNext() {
00066     return (currentCursor < objArray.length);
00067   }
00068 
00069   /* (non-Javadoc)
00070    * @see org.odbms.ObjectSet#next()
00071    */
00072   public Object next() {
00073     return objArray[currentCursor++];
00074   }
00075 
00076   /* (non-Javadoc)
00077    * @see org.odbms.ObjectSet#reset()
00078    */
00079   public void reset() {
00080     currentCursor = 0;
00081   }
00082 
00083   /* (non-Javadoc)
00084    * @see org.odbms.ObjectSet#size()
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 }

Generated on Wed Dec 14 21:05:33 2005 for OpenMobileIS by  doxygen 1.4.4