1 7 8 package java.nio; 9 10 11 45 46 public abstract class MappedByteBuffer 47 extends ByteBuffer 48 { 49 50 55 volatile boolean isAMappedBuffer; 59 MappedByteBuffer(int mark, int pos, int lim, int cap, boolean mapped) 63 { 64 super(mark, pos, lim, cap); 65 isAMappedBuffer = mapped; 66 } 67 68 MappedByteBuffer(int mark, int pos, int lim, int cap) { super(mark, pos, lim, cap); 70 isAMappedBuffer = false; 71 } 72 73 private void checkMapped() { 74 if (!isAMappedBuffer) 75 throw new UnsupportedOperationException (); 77 } 78 79 97 public final boolean isLoaded() { 98 checkMapped(); 99 if ((address == 0) || (capacity() == 0)) 100 return true; 101 return isLoaded0(((DirectByteBuffer )this).address(), capacity()); 102 } 103 104 114 public final MappedByteBuffer load() { 115 checkMapped(); 116 if ((address == 0) || (capacity() == 0)) 117 return this; 118 load0(((DirectByteBuffer )this).address(), capacity(), Bits.pageSize()); 119 return this; 120 } 121 122 140 public final MappedByteBuffer force() { 141 checkMapped(); 142 if ((address == 0) || (capacity() == 0)) 143 return this; 144 force0(((DirectByteBuffer )this).address(), capacity()); 145 return this; 146 } 147 148 private native boolean isLoaded0(long address, long length); 149 private native int load0(long address, long length, int pageSize); 150 private native void force0(long address, long length); 151 152 } 153 | Popular Tags |