1 24 package org.objectweb.jalisto.se.impl.server.page; 25 26 import org.objectweb.jalisto.se.api.internal.JalistoObject; 27 import org.objectweb.jalisto.se.impl.InFileAddress; 28 29 public abstract class Page implements JalistoObject { 30 31 public Page(int size) { 32 storedDatas = new Object [size]; 33 } 34 35 public boolean isEmpty() { 36 for (short i = 0; i < storedDatas.length; i++) { 37 if (storedDatas[i] != null) { 38 return false; 39 } 40 } 41 return true; 42 } 43 44 public Object [] getAllDatas() { 45 return storedDatas; 46 } 47 48 public void setData(Object data) { 49 } 50 51 public Object getData() { 52 return storedDatas; 53 } 54 55 public void setDataAt(InFileAddress dataIfa, Object dataToInsert) { 56 storedDatas[dataIfa.getIndex()] = dataToInsert; 57 } 58 59 public void setDataAt(int index, Object dataToInsert) { 60 storedDatas[index] = dataToInsert; 61 } 62 63 public Object getDataAt(InFileAddress dataIfa) { 64 return storedDatas[dataIfa.getIndex()]; 65 } 66 67 public Object getDataAt(int index) { 68 return storedDatas[index]; 69 } 70 71 public void setIfa(InFileAddress ifa) { 72 this.ifa = ifa.getClone(); 73 } 74 75 public InFileAddress getIfa() { 76 return ifa; 77 } 78 79 public int getSize() { 80 return storedDatas.length; 81 } 82 83 public JalistoObject internalClone(Page clone) { 84 clone.setIfa(ifa.getClone()); 85 System.arraycopy(storedDatas, 0, clone.storedDatas, 0, storedDatas.length); 86 return clone; 87 } 88 89 public String toString() { 90 if (ifa != null) { 91 return pageName() + "@" + String.valueOf(ifa) + ":" + dataToString(); 92 } else { 93 return pageName() + ":" + dataToString(); 94 } 95 } 96 97 private String dataToString() { 98 StringBuffer sb = new StringBuffer (); 99 sb.append("["); 100 for (int i = 0; i < storedDatas.length; i++) { 101 if (storedDatas[i] == null) { 102 sb.append("null"); 103 } else { 104 sb.append(storedDatas[i]); 105 } 106 if (i != (storedDatas.length - 1)) { 107 sb.append(";"); 108 } 109 } 110 sb.append("]"); 111 return sb.toString(); 112 } 113 114 protected String pageName() { 115 return "P"; 116 } 117 118 119 protected Object [] storedDatas; 120 protected transient InFileAddress ifa; 121 122 123 static final long serialVersionUID = -7589377099514761459L; 124 125 126 public static final short CLASSPAGE_TYPE = 0; 127 public static final short INSTANCEPAGE_TYPE = 1; 128 public static final short OIDPAGE_TYPE = 2; 129 public static final short SYSTEMPAGE_TYPE = 3; 130 public static final short NODEPAGE_TYPE = 4; 131 public static final short LEAFPAGE_TYPE = 5; 132 } 133 | Popular Tags |