1 24 package org.objectweb.jalisto.se.impl; 25 26 import org.objectweb.jalisto.se.api.internal.SessionInternal; 27 import org.objectweb.jalisto.se.api.Extent; 28 29 import java.util.*; 30 31 public class ExtentImpl implements Extent { 32 33 34 public ExtentImpl(Object clid, SessionInternal session) { 35 this.session = session; 36 this.clid = clid; 37 this.floids = new TreeSet(); 38 this.currentOidPageAddress = ""; 39 } 40 41 public void cleanFloids() { 42 floids.clear(); 43 } 44 45 public boolean isEmpty() { 46 return floids.isEmpty(); 47 } 48 49 public int size() { 50 return floids.size(); 51 } 52 53 public boolean contains(Object object) { 54 return floids.contains(object); 55 } 56 57 public Iterator iterator() { 58 return floids.iterator(); 59 } 60 61 public Collection collection() { 62 ArrayList list = new ArrayList(floids); 63 return list; 64 } 65 66 public Extent readFully() { 67 session.checkValidity("readFully", true); 68 addFloids(session.getFloidsFromClid(session.getSessionId(), clid)); 69 return this; 70 } 71 72 public Extent readNextFloids(int number) { 73 session.checkValidity("readNextFloids", true); 74 if (session.isRemoteSession()) { 75 throw new UnsupportedOperationException (); 76 } 77 addFloids(session.getOidTable().getFloidsFromClid(session.getSessionId(), clid, this, number)); 78 return this; 79 } 80 81 public LogicalOid getLastFloid() { 82 return lastFloid; 83 } 84 85 public String getStartingAddress() { 86 return currentOidPageAddress; 87 } 88 89 public void setStartingAddress(String startingAddress) { 90 this.currentOidPageAddress = startingAddress; 91 } 92 93 public void addFloids(Collection newFloids) { 94 floids.addAll(newFloids); 95 if (!floids.isEmpty()) { 96 lastFloid = (LogicalOid) floids.last(); 97 } 98 } 99 100 public String toString() { 101 return floids.toString(); 102 } 103 104 protected Object clid; 105 protected SessionInternal session; 106 protected TreeSet floids; 107 protected String currentOidPageAddress; 108 protected LogicalOid lastFloid; 109 } 110 | Popular Tags |