public StructuralSummaryNode next() throws IOException, DBException // for Iterator { // read record from file // transform into ssNode int CID; int qNameLen; String qName; byte[] qNameSeq; int parentCID; StructuralSummaryNode currentNode = new StructuralSummaryNode(); int nextPage; // needed in case that data is written in more than one page while (true) { // if(unTakenNodes!=0 &&XBufferChannel.position()+2*Settings.sizeOfInt<=Settings.pageSize) // agar dorost bkhunim har bar position sare yek record mi iste: if (unTakenNodes != 0 && xBufferChannel.position() < freeOffset) { // bayd daghigh tar chek bshe. // stroage format in ssIndex: cid(int),qlen(int),qSeq(byte array),parentCId(int) CID = xBufferChannel.getInt(); logManager.LogManager.log(1, "CID: " + CID); qNameLen = xBufferChannel.getInt(); int reqSpace = qNameLen + Settings.sizeOfInt; int capacity = Settings.pageSize - xBufferChannel.position(); if (reqSpace <= capacity) { qNameSeq = new byte[qNameLen]; xBufferChannel.get(qNameSeq, 0, qNameLen); qName = new String(qNameSeq); parentCID = xBufferChannel.getInt(); currentNode.setCID(CID); currentNode.setParentCID(parentCID); currentNode.setQName(qName); unTakenNodes--; return currentNode; // return breaks loop! } } else { // if(unTakenNodes==0)//in k ghalate baz :( // { return null; } // else //if(XBufferChannel.position()+2*Settings.sizeOfInt>Settings.pageSize) // { //goTOnextPAge; xBufferChannel.position(Settings.nextPagePos); nextPage = xBufferChannel.getInt(); bufMngr.unpinBuffer(xBufferChannel); if (nextPage > 0) { loadSSPage(nextPage); // prepares XBufferChannel and loads page into it. // System.out.println("loaded:"+nextPage); } else return null; workingPage = nextPage; xBufferChannel.position( Settings.dataStartPos); // instead of calling open(somehow opens nextpage) // } } } // end while }