rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
final int len43 = len * 4 / 3; final byte[] outBuff = new byte[len43 + ((len % 3) > 0 ? 4 : 0) + (breakLines ? (len43 / MAX_LINE_LENGTH) : 0)]; int d = 0; int e = 0; final int len2 = len - 2; int lineLength = 0; for (; d < len2; d += 3, e += 4) { encode3to4(src, d + off, 3, outBuff, e); lineLength += 4; if (breakLines && lineLength == MAX_LINE_LENGTH) { outBuff[e + 4] = NEW_LINE; e++; lineLength = 0; } } if (d < len) { encode3to4(src, d + off, len - d, outBuff, e); e += 4; } return new String(outBuff, 0, e);
return encode(src, 0, src.length, true);
public static final String encode(final byte[] src, final int off, final int len, final boolean breakLines) { final int len43 = len * 4 / 3; final byte[] outBuff = new byte[len43 // Main 4:3 + ((len % 3) > 0 ? 4 : 0) // Account for padding + (breakLines ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines int d = 0; int e = 0; final int len2 = len - 2; int lineLength = 0; for (; d < len2; d += 3, e += 4) { encode3to4(src, d + off, 3, outBuff, e); lineLength += 4; if (breakLines && lineLength == MAX_LINE_LENGTH) { outBuff[e + 4] = NEW_LINE; e++; lineLength = 0; } } if (d < len) { // padding needed encode3to4(src, d + off, len - d, outBuff, e); e += 4; } return new String(outBuff, 0, e); }
Unsafe.die();
Unsafe.debug("total blocks"); Unsafe.debug(blockCount);
static final Address allocateBlock(int blockSize) { if (!initialized) { initialize(); } enter(); try { // Calculate the number of blocks needed final int reqBlockCount = (int)(blockAlign(blockSize, true) >>> BLOCK_SIZE_SHIFT); // Find a large enough series of blocks final long nr = findFreeBlocks(reqBlockCount); if (nr == -1L) { Unsafe.debug("ret null."); Unsafe.debug(blockSize); Unsafe.debug("allocated blocks"); Unsafe.debug(allocatedBlocks); Unsafe.die(); return null; } // Mark all blocks as in use for (long i = 0; i < reqBlockCount; i++) { setInUse(nr + i, true); } // Return the address of block "nr". allocatedBlocks += reqBlockCount; nextBlockNr = nr + reqBlockCount; return Unsafe.longToAddress(startPtr + (nr << BLOCK_SIZE_SHIFT)); } finally { exit(); } }
for (long i = 0; i < reqBlockCount; i++) {
for (int i = 0; i < reqBlockCount; i++) {
static final Address allocateBlock(int blockSize) { if (!initialized) { initialize(); } enter(); try { // Calculate the number of blocks needed final int reqBlockCount = (int)(blockAlign(blockSize, true) >>> BLOCK_SIZE_SHIFT); // Find a large enough series of blocks final long nr = findFreeBlocks(reqBlockCount); if (nr == -1L) { Unsafe.debug("ret null."); Unsafe.debug(blockSize); Unsafe.debug("allocated blocks"); Unsafe.debug(allocatedBlocks); Unsafe.die(); return null; } // Mark all blocks as in use for (long i = 0; i < reqBlockCount; i++) { setInUse(nr + i, true); } // Return the address of block "nr". allocatedBlocks += reqBlockCount; nextBlockNr = nr + reqBlockCount; return Unsafe.longToAddress(startPtr + (nr << BLOCK_SIZE_SHIFT)); } finally { exit(); } }
Unsafe.debug("clear"); Unsafe.debug(size);
private static void clear(Address ptr, long size) { Unsafe.debug("clear"); Unsafe.debug(size); while (size != 0) { final int part = (int)Math.min(size, 0x7fffffffL); Unsafe.debug(size); Unsafe.clear(ptr, part); ptr = Unsafe.add(ptr, part); size -= part; } }
Unsafe.debug(size);
private static void clear(Address ptr, long size) { Unsafe.debug("clear"); Unsafe.debug(size); while (size != 0) { final int part = (int)Math.min(size, 0x7fffffffL); Unsafe.debug(size); Unsafe.clear(ptr, part); ptr = Unsafe.add(ptr, part); size -= part; } }
Unsafe.debug("initialize.");
private final static void initialize() { Unsafe.debug("initialize."); startPtr = blockAlign(Unsafe.addressToLong(Unsafe.getMemoryStart()), true); endPtr = blockAlign(Unsafe.addressToLong(Unsafe.getMemoryEnd()), false); final long size = endPtr - startPtr; Unsafe.debug(size); blockCount = (size >>> BLOCK_SIZE_SHIFT); // Create a lock (4 bytes) and usage bitmap at the front of the memory region final long rawBitmapSize = (blockCount >>> 3); final long bitmapSize = blockAlign(4 + rawBitmapSize, true); lockPtr = Unsafe.longToAddress(startPtr); bitmapPtr = Unsafe.longToAddress(startPtr + 4); // Clear the lock & bitmap size clear(lockPtr, bitmapSize); // Now shift the startptr. startPtr += bitmapSize; blockCount -= bitmapSize >>> BLOCK_SIZE_SHIFT; allocatedBlocks = 0; // Mark as initialized initialized = true; Unsafe.debug("Block count "); Unsafe.debug(blockCount); //Unsafe.debug("end of initialize."); }
Unsafe.debug("Block count "); Unsafe.debug(blockCount);
private final static void initialize() { Unsafe.debug("initialize."); startPtr = blockAlign(Unsafe.addressToLong(Unsafe.getMemoryStart()), true); endPtr = blockAlign(Unsafe.addressToLong(Unsafe.getMemoryEnd()), false); final long size = endPtr - startPtr; Unsafe.debug(size); blockCount = (size >>> BLOCK_SIZE_SHIFT); // Create a lock (4 bytes) and usage bitmap at the front of the memory region final long rawBitmapSize = (blockCount >>> 3); final long bitmapSize = blockAlign(4 + rawBitmapSize, true); lockPtr = Unsafe.longToAddress(startPtr); bitmapPtr = Unsafe.longToAddress(startPtr + 4); // Clear the lock & bitmap size clear(lockPtr, bitmapSize); // Now shift the startptr. startPtr += bitmapSize; blockCount -= bitmapSize >>> BLOCK_SIZE_SHIFT; allocatedBlocks = 0; // Mark as initialized initialized = true; Unsafe.debug("Block count "); Unsafe.debug(blockCount); //Unsafe.debug("end of initialize."); }
final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31));
final long offset = blockNr >>> 3; final int mask = (1 << (blockNr & 7));
private static final boolean isInUse(long blockNr) { // 32-bits per int, so shift=5, mask=31 final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31)); final Address ptr = Unsafe.add(bitmapPtr, Unsafe.longToAddress(offset)); final int v = Unsafe.getInt(ptr); return ((v & mask) == mask); }
final int v = Unsafe.getInt(ptr);
final int v = Unsafe.getByte(ptr) & 0xFF;
private static final boolean isInUse(long blockNr) { // 32-bits per int, so shift=5, mask=31 final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31)); final Address ptr = Unsafe.add(bitmapPtr, Unsafe.longToAddress(offset)); final int v = Unsafe.getInt(ptr); return ((v & mask) == mask); }
final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31));
final long offset = blockNr >>> 3; final int mask = (1 << (blockNr & 7));
private static final void setInUse(long blockNr, boolean inUse) { // 32-bits per int, so shift=5, mask=31 final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31)); final Address ptr = Unsafe.add(bitmapPtr, Unsafe.longToAddress(offset)); int v = Unsafe.getInt(ptr); if (inUse) { v |= mask; } else { v &= ~mask; } Unsafe.setInt(ptr, v); }
int v = Unsafe.getInt(ptr);
int v = Unsafe.getByte(ptr);
private static final void setInUse(long blockNr, boolean inUse) { // 32-bits per int, so shift=5, mask=31 final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31)); final Address ptr = Unsafe.add(bitmapPtr, Unsafe.longToAddress(offset)); int v = Unsafe.getInt(ptr); if (inUse) { v |= mask; } else { v &= ~mask; } Unsafe.setInt(ptr, v); }
Unsafe.setInt(ptr, v);
Unsafe.setByte(ptr, (byte)v);
private static final void setInUse(long blockNr, boolean inUse) { // 32-bits per int, so shift=5, mask=31 final long offset = blockNr >>> 5; final int mask = (1 << (int) (blockNr & 31)); final Address ptr = Unsafe.add(bitmapPtr, Unsafe.longToAddress(offset)); int v = Unsafe.getInt(ptr); if (inUse) { v |= mask; } else { v &= ~mask; } Unsafe.setInt(ptr, v); }
if (blocking) throw new IllegalBlockingModeException();
public final SelectionKey register(Selector selin, int ops, Object att) throws ClosedChannelException { if (! isOpen()) throw new ClosedChannelException(); if ((ops & ~validOps()) != 0) throw new IllegalArgumentException(); SelectionKey key = null; AbstractSelector selector = (AbstractSelector) selin; synchronized (blockingLock()) { key = locate(selector); if (key != null && key.isValid()) { if (att != null) key.attach(att); } else { key = selector.register(this, ops, att); if (key != null) addSelectionKey(key); } } return key; }
return opened;
return ! closed;
public final boolean isOpen () { return opened; }
public abstract SelectionKey register (Selector sel, int ops, Object att) throws ClosedChannelException;
public final SelectionKey register(Selector sel, int ops) throws ClosedChannelException { return register(sel, ops, null); }
public abstract SelectionKey register (Selector sel, int ops, Object att) throws ClosedChannelException;
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) {
public Ext2FileSystem(Device device) throws FileSystemException{ if(device==null)
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
}
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); }
this.api=null;
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
long byteIndex;
blockCache = new BlockCache(50,(float)0.75); inodeCache = new INodeCache(50,(float)0.75); groupDescriptorLock = new Object(); superblockLock = new Object();
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
cache = new BlockCache(50, (float) 0.75);
setMode(RW); try{ api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); }catch(ApiNotFoundException e) { throw new FileSystemException("Device is not a partition!"); }
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data);
api.read(1024, data, 0, Superblock.SUPERBLOCK_LENGTH); superblock = new Superblock(data, this);
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data);
for(int i=0; i<groupCount; i++) { data=getBlock(superblock.getFirstDataBlock()+1); groupDescriptors[i] = new GroupDescriptor(data, this, i); } /* for(int i=0; i<groupCount; i++) { groupDescriptors[i]=new GroupDescriptor(i, this);
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
byteIndex += superblock.getBlockSize();
*/
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
} log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup());
} log.info( "Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: "+superblock.getBlocksCount()+"\n"+ " #blocks/group: "+superblock.getBlocksPerGroup()+"\n"+ " #block groups: "+groupCount+"\n"+ " block size: "+superblock.getBlockSize()+"\n"+ " #inodes: "+superblock.getINodesCount()+"\n"+ " #inodes/group: "+superblock.getINodesPerGroup());
public Ext2FileSystem(Device device) throws FileSystemException { if (device == null) { throw new FileSystemException("null device!"); } this.device = device; try { this.api = (FSBlockDeviceAPI) device.getAPI(FSBlockDeviceAPI.class); } catch (ApiNotFoundException ex) { throw new FileSystemException("Device is not a partition", ex); } closed = false; byte data[]; //points to the byte where the fs metadata parsing has reached long byteIndex; cache = new BlockCache(50, (float) 0.75); try { data = new byte[Superblock.SUPERBLOCK_LENGTH]; //skip the first 1024 bytes (bootsector) and read the superblock byteIndex = 1024; api.read(byteIndex, data, 0, Superblock.SUPERBLOCK_LENGTH); byteIndex += Superblock.SUPERBLOCK_LENGTH; superblock = new Superblock(data); //read the group descriptors groupCount = (int) Math.ceil((double) superblock.getBlocksCount() / (double) superblock.getBlocksPerGroup()); groupDescriptors = new GroupDescriptor[groupCount]; for (int i = 0; i < groupCount; i++) { data = new byte[GroupDescriptor.GROUPDESCRIPTOR_LENGTH]; api.read(byteIndex + i * GroupDescriptor.GROUPDESCRIPTOR_LENGTH, data, 0, GroupDescriptor.GROUPDESCRIPTOR_LENGTH); groupDescriptors[i] = new GroupDescriptor(data); } byteIndex += superblock.getBlockSize(); /* * //go through each block group //XXX byteIndex = ... //read the block bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, * (int)superblock.getBlockSize()); FSBitmap blockBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode bitmap //XXX what if it doesn't fit? data = new byte[(int)superblock.getBlockSize()]; api.read( byteIndex, data, 0, (int)superblock.getBlockSize()); FSBitmap * inodeBitmap = new FSBitmap(data); byteIndex += superblock.getBlockSize(); * * //read the inode table //XXX what if it doesn't fit? Inode inodeTable[] = new Inode[ (int)superblock.getInodesCount() ]; */ } catch (FileSystemException e) { throw e; } catch (Exception e) { throw new FileSystemException(e); } log.debug("Ext2fs filesystem constructed sucessfully"); log.debug( " superblock: #blocks: " + superblock.getBlocksCount() + "\n" + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n" + " #block groups: " + groupCount + "\n" + " block size: " + superblock.getBlockSize() + "\n" + " #inodes: " + superblock.getINodesCount() + "\n" + " #inodes/group: " + superblock.getINodesPerGroup()); }
closed = true; throw new IOException("Yet unimplemented");
public void close() throws IOException { flush(); closed = true; //XXX throw new IOException("Yet unimplemented"); }
throw new IOException("Yet unimplemented");
log.info("Filesystem flushed");
public void flush() throws IOException { //XXX throw new IOException("Yet unimplemented"); }
Integer key = new Integer((int) nr); if (cache.containsKey(key)) result = (Block) cache.get(key); else { byte[] data = new byte[blockSize]; api.read(nr * blockSize, data, 0, blockSize); result = new Block(data); cache.put(key, result);
Integer key=new Integer((int)(nr)); synchronized(blockCache) { if(blockCache.containsKey(key)) result=(Block)blockCache.get(key); else{ byte[] data = new byte[blockSize]; timedRead(nr, data); result=new Block(this, nr, data); blockCache.put(key, result); }
public byte[] getBlock(long nr) throws IOException { int blockSize = superblock.getBlockSize(); Block result; Integer key = new Integer((int) nr); //check if the block has already been retrieved if (cache.containsKey(key)) result = (Block) cache.get(key); else { byte[] data = new byte[blockSize]; api.read(nr * blockSize, data, 0, blockSize); result = new Block(data); cache.put(key, result); } return result.getData(); }
public INode getINode(int iNodeNr) throws IOException, FileSystemException { if (iNodeNr < 1) throw new IOException("INode number must be greater than 0"); int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); long iNodeTableBlock = groupDescriptors[group].getInodeTable(); INodeTable iNodeTable = new INodeTable(this, (int) iNodeTableBlock); return new INode(this, iNodeTable.getInodeData(index));
public INode getINode(int iNodeNr) throws IOException, FileSystemException{ if((iNodeNr<1)||(iNodeNr>superblock.getINodesCount())) throw new FileSystemException("INode number ("+iNodeNr+") out of range (0-"+superblock.getINodesCount()+")"); Integer key=new Integer((int)iNodeNr); synchronized(inodeCache) { if(inodeCache.containsKey(key)) return (INode)inodeCache.get(key); else{ int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); long iNodeTableBlock = groupDescriptors[group].getInodeTable(); INodeTable iNodeTable = new INodeTable(this, (int)iNodeTableBlock); INode result = new INode(this, new INodeDescriptor(iNodeTable, iNodeNr, group, index), iNodeTable.getInodeData(index)); inodeCache.put(key, result); return result; } }
public INode getINode(int iNodeNr) throws IOException, FileSystemException { if (iNodeNr < 1) throw new IOException("INode number must be greater than 0"); int group = (int) ((iNodeNr - 1) / superblock.getINodesPerGroup()); int index = (int) ((iNodeNr - 1) % superblock.getINodesPerGroup()); //get the part of the inode table that contains the inode long iNodeTableBlock = groupDescriptors[group].getInodeTable(); //the first block of the inode table INodeTable iNodeTable = new INodeTable(this, (int) iNodeTableBlock); return new INode(this, iNodeTable.getInodeData(index)); }
log.debug("Ext2FileSystem.getRootEntry()"); try { if (!closed) { return new Ext2Entry(getINode(Ext2Constants.EXT2_ROOT_INO), "/", Ext2Constants.EXT2_FT_DIR);
try{ if(!closed) { return new Ext2Entry( getINode(Ext2Constants.EXT2_ROOT_INO), "/", Ext2Constants.EXT2_FT_DIR, this );
public FSEntry getRootEntry() throws IOException { log.debug("Ext2FileSystem.getRootEntry()"); try { if (!closed) { return new Ext2Entry(getINode(Ext2Constants.EXT2_ROOT_INO), "/", Ext2Constants.EXT2_FT_DIR); } } catch (FileSystemException e) { throw new IOException(e); } return null; }
cacheListeners = new Vector();
public BlockCache(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor, true); }
log.setLevel(Level.DEBUG);
log.setLevel(Level.INFO);
public Superblock() { data = new byte[SUPERBLOCK_LENGTH]; log.setLevel(Level.DEBUG); }
log.setLevel(Level.DEBUG);
log.setLevel(Level.INFO);
public GroupDescriptor() { data = new byte[GROUPDESCRIPTOR_LENGTH]; log.setLevel(Level.DEBUG); }
log.setLevel(Level.DEBUG);
log.setLevel(Level.INFO);
public INode(Ext2FileSystem fs, INodeDescriptor desc) { this.fs = fs; this.desc = desc; this.data = new byte[INODE_LENGTH]; log.setLevel(Level.DEBUG); }
protected void update() throws IOException{
protected synchronized void update() throws IOException{
protected void update() throws IOException{ try{ if(dirty) { log.debug(" ** updating inode **"); desc.getINodeTable().writeInodeData( desc.getIndex(), data ); dirty=false; } }catch(FileSystemException fs) { throw new IOException(fs); } }
public void flush() { if (!dirty)
public void flush() throws IOException{ if(!dirty)
public void flush() { if (!dirty) return; //XXX... log.error("BLOCK FLUSHED FROM CACHE"); }
log.error("BLOCK FLUSHED FROM CACHE");
fs.writeBlock(blockNr, data, true); log.debug("BLOCK FLUSHED FROM CACHE");
public void flush() { if (!dirty) return; //XXX... log.error("BLOCK FLUSHED FROM CACHE"); }
public boolean containsKey(Integer key) {
private boolean containsKey(Integer key) {
public boolean containsKey(Integer key) { boolean result = super.containsKey(key); if(result) log.debug("CACHE HIT, size:"+size()); else log.debug("CACHE MISS"); return result; }
public Block(byte[] data) { this.data = data;
public Block(Ext2FileSystem fs, long blockNr, byte[] data) { this.data=data; this.fs=fs; this.blockNr=blockNr; log.setLevel(Level.DEBUG);
public Block(byte[] data) { this.data = data; }
public Ext2Entry(INode iNode, String name, int type) {
public Ext2Entry(INode iNode, String name, int type, Ext2FileSystem fs) {
public Ext2Entry(INode iNode, String name, int type) { this.iNode = iNode; this.name = name; this.type = type; this.valid = true; log.debug("Ext2Entry(iNode, name): name="+name+ (isDirectory()?" is a directory ":"")+ (isFile()?" is a file ":"")); }
this.fs = fs; log.setLevel(Level.INFO);
public Ext2Entry(INode iNode, String name, int type) { this.iNode = iNode; this.name = name; this.type = type; this.valid = true; log.debug("Ext2Entry(iNode, name): name="+name+ (isDirectory()?" is a directory ":"")+ (isFile()?" is a file ":"")); }
public RenderContext(AffineTransform xform)
public RenderContext(AffineTransform xform, Shape aoi, RenderingHints hints)
public RenderContext(AffineTransform xform) { this(xform, null, null); }
this(xform, null, null);
this.xform = xform; this.aoi = aoi; this.hints = hints;
public RenderContext(AffineTransform xform) { this(xform, null, null); }
throw new InternalError("Not implemented yet");
reset(); return pattern.getRE().substituteAll(input, replacement, position);
public String replaceAll(String replacement) { throw new InternalError("Not implemented yet"); }
throw new InternalError("Not implemented yet");
reset(); return pattern.getRE().substitute(input, replacement, position);
public String replaceFirst(String replacement) { throw new InternalError("Not implemented yet"); }
Action action = new AbstractAction(){ public void actionPerformed(ActionEvent e) { } }; action.putValue(Action.NAME, item.getLabel()); ((JPopupMenu)jComponent).add(action);
item.addNotify(); jComponent.add(((SwingMenuItemPeer)item.getPeer()).jComponent);
public void addItem(MenuItem item) { Action action = new AbstractAction(){ public void actionPerformed(ActionEvent e) { //todo implement it } }; action.putValue(Action.NAME, item.getLabel()); ((JPopupMenu)jComponent).add(action); }
public void setArc(Rectangle2D r, double start, double extent, int type) { setArc(r.getX(), r.getY(), r.getWidth(), r.getHeight(), start, extent, type); }
public abstract void setArc(double x, double y, double w, double h, double start, double extent, int type);
public void setArc(Rectangle2D r, double start, double extent, int type) { setArc(r.getX(), r.getY(), r.getWidth(), r.getHeight(), start, extent, type); }
log.info("PLLInfo:" + fbinfo.getPllInfo());
log.debug("PLLInfo:" + fbinfo.getPllInfo());
final RadeonSurface open(RadeonConfiguration config) throws ResourceNotFreeException { // Get the best matching config config = fbinfo.getBestConfiguration(config); log.info("BestConfig:" + config); // Calculate new configuration final DisplayMode mode = config.getDisplayMode(); final int width = mode.getWidth(); final int height = mode.getHeight(); final int pixels = width * height; final int bitsPerPixel = config.getBitsPerPixel(); final int bytesPerLine = config.getBytesPerLine(); final int bytesPerScreen = bytesPerLine * height; log.info("PLLInfo:" + fbinfo.getPllInfo()); currentState.calcForConfiguration(config, vgaIO, fbinfo); // Disable video interrupts vgaIO.disableIRQ(); // Allocate the screen memory final MemoryResource screen = claimDeviceMemory(bytesPerScreen, 4 * 1024); //final MemoryResource screen = deviceRam; log.info("Screen at 0x" + NumberUtils.hex(screen.getOffset()) + ", size 0x" + NumberUtils.hex(screen.getSize())); //if (true) { throw new ResourceNotFreeException("TEST"); } // Save the current state oldVgaState.saveFromVGA(vgaIO); log.info("oldState:" + oldVgaState); // Turn off the screen final DpmsState dpmsState = getDpms(); setDpms(DpmsState.OFF); try { // Set the new configuration currentState.restoreToVGA(vgaIO); log.info("NewState: " + currentState); vgaIO.setReg32(CRTC_OFFSET, (int) screen.getOffset()); if (fbinfo.hasCRTC2) { vgaIO.setReg32(CRTC2_OFFSET, (int) screen.getOffset()); } // Set the 8-bit palette setPalette(1.0f); // Create the graphics helper & clear the screen final BitmapGraphics bitmapGraphics; switch (bitsPerPixel) { case 8: bitmapGraphics = BitmapGraphics.create8bppInstance(screen, width, height, bytesPerLine, 0); screen.setByte(0, (byte) 0, pixels); break; case 16: bitmapGraphics = BitmapGraphics.create16bppInstance(screen, width, height, bytesPerLine, 0); screen.setShort(0, (byte) 0, pixels); break; case 24: bitmapGraphics = BitmapGraphics.create24bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt24(0, 0, pixels); break; case 32: bitmapGraphics = BitmapGraphics.create32bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt(0, 0, pixels); break; default: throw new IllegalArgumentException("Invalid bits per pixel " + bitsPerPixel); } return new RadeonSurface(this, config, bitmapGraphics, screen); } finally { // Turn the screen back on setDpms(dpmsState); } }
log.info("Screen at 0x" + NumberUtils.hex(screen.getOffset())
log.debug("Screen at 0x" + NumberUtils.hex(screen.getOffset())
final RadeonSurface open(RadeonConfiguration config) throws ResourceNotFreeException { // Get the best matching config config = fbinfo.getBestConfiguration(config); log.info("BestConfig:" + config); // Calculate new configuration final DisplayMode mode = config.getDisplayMode(); final int width = mode.getWidth(); final int height = mode.getHeight(); final int pixels = width * height; final int bitsPerPixel = config.getBitsPerPixel(); final int bytesPerLine = config.getBytesPerLine(); final int bytesPerScreen = bytesPerLine * height; log.info("PLLInfo:" + fbinfo.getPllInfo()); currentState.calcForConfiguration(config, vgaIO, fbinfo); // Disable video interrupts vgaIO.disableIRQ(); // Allocate the screen memory final MemoryResource screen = claimDeviceMemory(bytesPerScreen, 4 * 1024); //final MemoryResource screen = deviceRam; log.info("Screen at 0x" + NumberUtils.hex(screen.getOffset()) + ", size 0x" + NumberUtils.hex(screen.getSize())); //if (true) { throw new ResourceNotFreeException("TEST"); } // Save the current state oldVgaState.saveFromVGA(vgaIO); log.info("oldState:" + oldVgaState); // Turn off the screen final DpmsState dpmsState = getDpms(); setDpms(DpmsState.OFF); try { // Set the new configuration currentState.restoreToVGA(vgaIO); log.info("NewState: " + currentState); vgaIO.setReg32(CRTC_OFFSET, (int) screen.getOffset()); if (fbinfo.hasCRTC2) { vgaIO.setReg32(CRTC2_OFFSET, (int) screen.getOffset()); } // Set the 8-bit palette setPalette(1.0f); // Create the graphics helper & clear the screen final BitmapGraphics bitmapGraphics; switch (bitsPerPixel) { case 8: bitmapGraphics = BitmapGraphics.create8bppInstance(screen, width, height, bytesPerLine, 0); screen.setByte(0, (byte) 0, pixels); break; case 16: bitmapGraphics = BitmapGraphics.create16bppInstance(screen, width, height, bytesPerLine, 0); screen.setShort(0, (byte) 0, pixels); break; case 24: bitmapGraphics = BitmapGraphics.create24bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt24(0, 0, pixels); break; case 32: bitmapGraphics = BitmapGraphics.create32bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt(0, 0, pixels); break; default: throw new IllegalArgumentException("Invalid bits per pixel " + bitsPerPixel); } return new RadeonSurface(this, config, bitmapGraphics, screen); } finally { // Turn the screen back on setDpms(dpmsState); } }
log.info("oldState:" + oldVgaState);
log.debug("oldState:" + oldVgaState);
final RadeonSurface open(RadeonConfiguration config) throws ResourceNotFreeException { // Get the best matching config config = fbinfo.getBestConfiguration(config); log.info("BestConfig:" + config); // Calculate new configuration final DisplayMode mode = config.getDisplayMode(); final int width = mode.getWidth(); final int height = mode.getHeight(); final int pixels = width * height; final int bitsPerPixel = config.getBitsPerPixel(); final int bytesPerLine = config.getBytesPerLine(); final int bytesPerScreen = bytesPerLine * height; log.info("PLLInfo:" + fbinfo.getPllInfo()); currentState.calcForConfiguration(config, vgaIO, fbinfo); // Disable video interrupts vgaIO.disableIRQ(); // Allocate the screen memory final MemoryResource screen = claimDeviceMemory(bytesPerScreen, 4 * 1024); //final MemoryResource screen = deviceRam; log.info("Screen at 0x" + NumberUtils.hex(screen.getOffset()) + ", size 0x" + NumberUtils.hex(screen.getSize())); //if (true) { throw new ResourceNotFreeException("TEST"); } // Save the current state oldVgaState.saveFromVGA(vgaIO); log.info("oldState:" + oldVgaState); // Turn off the screen final DpmsState dpmsState = getDpms(); setDpms(DpmsState.OFF); try { // Set the new configuration currentState.restoreToVGA(vgaIO); log.info("NewState: " + currentState); vgaIO.setReg32(CRTC_OFFSET, (int) screen.getOffset()); if (fbinfo.hasCRTC2) { vgaIO.setReg32(CRTC2_OFFSET, (int) screen.getOffset()); } // Set the 8-bit palette setPalette(1.0f); // Create the graphics helper & clear the screen final BitmapGraphics bitmapGraphics; switch (bitsPerPixel) { case 8: bitmapGraphics = BitmapGraphics.create8bppInstance(screen, width, height, bytesPerLine, 0); screen.setByte(0, (byte) 0, pixels); break; case 16: bitmapGraphics = BitmapGraphics.create16bppInstance(screen, width, height, bytesPerLine, 0); screen.setShort(0, (byte) 0, pixels); break; case 24: bitmapGraphics = BitmapGraphics.create24bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt24(0, 0, pixels); break; case 32: bitmapGraphics = BitmapGraphics.create32bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt(0, 0, pixels); break; default: throw new IllegalArgumentException("Invalid bits per pixel " + bitsPerPixel); } return new RadeonSurface(this, config, bitmapGraphics, screen); } finally { // Turn the screen back on setDpms(dpmsState); } }
log.info("NewState: " + currentState);
log.debug("NewState: " + currentState);
final RadeonSurface open(RadeonConfiguration config) throws ResourceNotFreeException { // Get the best matching config config = fbinfo.getBestConfiguration(config); log.info("BestConfig:" + config); // Calculate new configuration final DisplayMode mode = config.getDisplayMode(); final int width = mode.getWidth(); final int height = mode.getHeight(); final int pixels = width * height; final int bitsPerPixel = config.getBitsPerPixel(); final int bytesPerLine = config.getBytesPerLine(); final int bytesPerScreen = bytesPerLine * height; log.info("PLLInfo:" + fbinfo.getPllInfo()); currentState.calcForConfiguration(config, vgaIO, fbinfo); // Disable video interrupts vgaIO.disableIRQ(); // Allocate the screen memory final MemoryResource screen = claimDeviceMemory(bytesPerScreen, 4 * 1024); //final MemoryResource screen = deviceRam; log.info("Screen at 0x" + NumberUtils.hex(screen.getOffset()) + ", size 0x" + NumberUtils.hex(screen.getSize())); //if (true) { throw new ResourceNotFreeException("TEST"); } // Save the current state oldVgaState.saveFromVGA(vgaIO); log.info("oldState:" + oldVgaState); // Turn off the screen final DpmsState dpmsState = getDpms(); setDpms(DpmsState.OFF); try { // Set the new configuration currentState.restoreToVGA(vgaIO); log.info("NewState: " + currentState); vgaIO.setReg32(CRTC_OFFSET, (int) screen.getOffset()); if (fbinfo.hasCRTC2) { vgaIO.setReg32(CRTC2_OFFSET, (int) screen.getOffset()); } // Set the 8-bit palette setPalette(1.0f); // Create the graphics helper & clear the screen final BitmapGraphics bitmapGraphics; switch (bitsPerPixel) { case 8: bitmapGraphics = BitmapGraphics.create8bppInstance(screen, width, height, bytesPerLine, 0); screen.setByte(0, (byte) 0, pixels); break; case 16: bitmapGraphics = BitmapGraphics.create16bppInstance(screen, width, height, bytesPerLine, 0); screen.setShort(0, (byte) 0, pixels); break; case 24: bitmapGraphics = BitmapGraphics.create24bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt24(0, 0, pixels); break; case 32: bitmapGraphics = BitmapGraphics.create32bppInstance(screen, width, height, bytesPerLine, 0); screen.setInt(0, 0, pixels); break; default: throw new IllegalArgumentException("Invalid bits per pixel " + bitsPerPixel); } return new RadeonSurface(this, config, bitmapGraphics, screen); } finally { // Turn the screen back on setDpms(dpmsState); } }
log.info("Set LVDS_GEN_CTRL to 0x" + NumberUtils.hex(lvds_gen_cntl));
log.debug("Set LVDS_GEN_CTRL to 0x" + NumberUtils.hex(lvds_gen_cntl));
final void setDpms(DpmsState state) { int crtc_ext_cntl = vgaIO.getReg32(CRTC_EXT_CNTL); int lvds_gen_cntl = vgaIO.getReg32(LVDS_GEN_CNTL);// log.info("Get LVDS_GEN_CTRL 0x" + NumberUtils.hex(lvds_gen_cntl)); crtc_ext_cntl &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); lvds_gen_cntl &= ~(LVDS_DISPLAY_DIS | LVDS_ON); if (state.isDisplay()) { lvds_gen_cntl |= (LVDS_BLON | LVDS_ON); } else { crtc_ext_cntl |= CRTC_DISPLAY_DIS; lvds_gen_cntl |= LVDS_DISPLAY_DIS; } if (!state.isHsync()) { crtc_ext_cntl |= CRTC_HSYNC_DIS; } if (!state.isVsync()) { crtc_ext_cntl |= CRTC_VSYNC_DIS; } if (fbinfo.getDviDispType() == MonitorType.LCD) { vgaIO.setReg32(LVDS_GEN_CNTL, lvds_gen_cntl); log.info("Set LVDS_GEN_CTRL to 0x" + NumberUtils.hex(lvds_gen_cntl)); } else { vgaIO.setReg32(CRTC_EXT_CNTL, crtc_ext_cntl); log.info("Set CRTC_EXT_CNTL to 0x" + NumberUtils.hex(crtc_ext_cntl)); } }
log.info("Set CRTC_EXT_CNTL to 0x" + NumberUtils.hex(crtc_ext_cntl));
log.debug("Set CRTC_EXT_CNTL to 0x" + NumberUtils.hex(crtc_ext_cntl));
final void setDpms(DpmsState state) { int crtc_ext_cntl = vgaIO.getReg32(CRTC_EXT_CNTL); int lvds_gen_cntl = vgaIO.getReg32(LVDS_GEN_CNTL);// log.info("Get LVDS_GEN_CTRL 0x" + NumberUtils.hex(lvds_gen_cntl)); crtc_ext_cntl &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); lvds_gen_cntl &= ~(LVDS_DISPLAY_DIS | LVDS_ON); if (state.isDisplay()) { lvds_gen_cntl |= (LVDS_BLON | LVDS_ON); } else { crtc_ext_cntl |= CRTC_DISPLAY_DIS; lvds_gen_cntl |= LVDS_DISPLAY_DIS; } if (!state.isHsync()) { crtc_ext_cntl |= CRTC_HSYNC_DIS; } if (!state.isVsync()) { crtc_ext_cntl |= CRTC_VSYNC_DIS; } if (fbinfo.getDviDispType() == MonitorType.LCD) { vgaIO.setReg32(LVDS_GEN_CNTL, lvds_gen_cntl); log.info("Set LVDS_GEN_CTRL to 0x" + NumberUtils.hex(lvds_gen_cntl)); } else { vgaIO.setReg32(CRTC_EXT_CNTL, crtc_ext_cntl); log.info("Set CRTC_EXT_CNTL to 0x" + NumberUtils.hex(crtc_ext_cntl)); } }
public ObjectAlreadyActive(String why)
public ObjectAlreadyActive()
public ObjectAlreadyActive(String why) { super(why); }
super(why);
public ObjectAlreadyActive(String why) { super(why); }
private UnicodeBlock(char start, char end, String name)
private UnicodeBlock(int start, int end, String name, String canonicalName)
private UnicodeBlock(char start, char end, String name) { super(name); this.start = start; this.end = end; }
this.canonicalName = canonicalName;
private UnicodeBlock(char start, char end, String name) { super(name); this.start = start; this.end = end; }
if (ch == '\uFEFF') return SPECIALS; int low = 0; int hi = sets.length - 1; while (low <= hi) { int mid = (low + hi) >> 1; UnicodeBlock b = sets[mid]; if (ch < b.start) hi = mid - 1; else if (ch > b.end) low = mid + 1; else return b; } return null;
return of((int) ch);
public static UnicodeBlock of(char ch) { // Special case, since SPECIALS contains two ranges. if (ch == '\uFEFF') return SPECIALS; // Simple binary search for the correct block. int low = 0; int hi = sets.length - 1; while (low <= hi) { int mid = (low + hi) >> 1; UnicodeBlock b = sets[mid]; if (ch < b.start) hi = mid - 1; else if (ch > b.end) low = mid + 1; else return b; } return null; }
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0);
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, name, null, 0);
public Object getParameter(String name) throws DOMException { name = name.toLowerCase(); if ("cdata-sections".equals(name)) { return cdataSections ? Boolean.TRUE : Boolean.FALSE; } else if ("comments".equals(name)) { return comments ? Boolean.TRUE : Boolean.FALSE; } else if ("element-content-whitespace".equals(name)) { return elementContentWhitespace ? Boolean.TRUE : Boolean.FALSE; } else if ("entities".equals(name)) { return entities ? Boolean.TRUE : Boolean.FALSE; } else if ("error-handler".equals(name)) { return errorHandler; } else if ("namespace-declarations".equals(name)) { return namespaceDeclarations ? Boolean.TRUE : Boolean.FALSE; } else if ("split-cdata-sections".equals(name)) { return comments ? Boolean.TRUE : Boolean.FALSE; } else if ("canonical-form".equals(name) || "check-character-normalization".equals(name) || "datatype-normalization".equals(name) || "normalize-characters".equals(name) || "validate".equals(name) || "validate-if-schema".equals(name)) { return Boolean.FALSE; } else if ("namespaces".equals(name) || "well-formed".equals(name)) { return Boolean.TRUE; } else if ("infoset".equals(name)) { return (entities == false && cdataSections == false && namespaceDeclarations == true && comments == true) ? Boolean.TRUE : Boolean.FALSE; } throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0); }
throw new DomEx(DomEx.TYPE_MISMATCH_ERR,
throw new DomDOMException(DOMException.TYPE_MISMATCH_ERR,
public void setParameter(String name, Object value) throws DOMException { name = name.toLowerCase(); if ("cdata-sections".equals(name)) { cdataSections = "true".equals(value.toString()); } else if ("comments".equals(name)) { comments = "true".equals(value.toString()); } else if ("element-content-whitespace".equals(name)) { elementContentWhitespace = "true".equals(value.toString()); } else if ("entities".equals(name)) { entities = "true".equals(value.toString()); } else if ("error-handler".equals(name)) { try { errorHandler = (DOMErrorHandler) value; } catch (ClassCastException e) { throw new DomEx(DomEx.TYPE_MISMATCH_ERR, value.getClass().getName(), null, 0); } } else if ("namespace-declarations".equals(name)) { namespaceDeclarations = "true".equals(value.toString()); } else if ("split-cdata-sections".equals(name)) { comments = "true".equals(value.toString()); } else if ("infoset".equals(name)) { if ("true".equals(value.toString())) { entities = false; cdataSections = false; namespaceDeclarations = true; elementContentWhitespace = true; comments = true; } } else if (("canonical-form".equals(name) || "check-character-normalization".equals(name) || "datatype-normalization".equals(name) || "normalize-characters".equals(name) || "validate".equals(name) || "validate-if-schema".equals(name)) && "false".equals(value.toString())) { // NOOP } else if (("namespaces".equals(name) || "well-formed".equals(name)) && "true".equals(value.toString())) { // NOOP } else { throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0); } }
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0);
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, name, null, 0);
public void setParameter(String name, Object value) throws DOMException { name = name.toLowerCase(); if ("cdata-sections".equals(name)) { cdataSections = "true".equals(value.toString()); } else if ("comments".equals(name)) { comments = "true".equals(value.toString()); } else if ("element-content-whitespace".equals(name)) { elementContentWhitespace = "true".equals(value.toString()); } else if ("entities".equals(name)) { entities = "true".equals(value.toString()); } else if ("error-handler".equals(name)) { try { errorHandler = (DOMErrorHandler) value; } catch (ClassCastException e) { throw new DomEx(DomEx.TYPE_MISMATCH_ERR, value.getClass().getName(), null, 0); } } else if ("namespace-declarations".equals(name)) { namespaceDeclarations = "true".equals(value.toString()); } else if ("split-cdata-sections".equals(name)) { comments = "true".equals(value.toString()); } else if ("infoset".equals(name)) { if ("true".equals(value.toString())) { entities = false; cdataSections = false; namespaceDeclarations = true; elementContentWhitespace = true; comments = true; } } else if (("canonical-form".equals(name) || "check-character-normalization".equals(name) || "datatype-normalization".equals(name) || "normalize-characters".equals(name) || "validate".equals(name) || "validate-if-schema".equals(name)) && "false".equals(value.toString())) { // NOOP } else if (("namespaces".equals(name) || "well-formed".equals(name)) && "true".equals(value.toString())) { // NOOP } else { throw new DomEx(DomEx.NOT_SUPPORTED_ERR, name, null, 0); } }
public _NamingContextExtStub(Delegate delegate)
public _NamingContextExtStub()
public _NamingContextExtStub(Delegate delegate) { super(delegate); }
super(delegate);
super();
public _NamingContextExtStub(Delegate delegate) { super(delegate); }
if (editorComponent instanceof JTextField) { ((JTextField)editorComponent).setText(value.toString()); delegate = new EditorDelegate(); ((JTextField)editorComponent).addActionListener(delegate); } else if (editorComponent instanceof JCheckBox) { ((JCheckBox)editorComponent).setText(value.toString()); delegate = new EditorDelegate(); ((JCheckBox)editorComponent).addActionListener(delegate); } else if (editorComponent instanceof JComboBox) { ((JComboBox)editorComponent).setSelectedItem(value.toString()); delegate = new EditorDelegate(); ((JComboBox)editorComponent).addActionListener(delegate); }
delegate.setValue(value);
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { if (editorComponent instanceof JTextField) { ((JTextField)editorComponent).setText(value.toString()); delegate = new EditorDelegate(); ((JTextField)editorComponent).addActionListener(delegate); } else if (editorComponent instanceof JCheckBox) { ((JCheckBox)editorComponent).setText(value.toString()); delegate = new EditorDelegate(); ((JCheckBox)editorComponent).addActionListener(delegate); } else if (editorComponent instanceof JComboBox) { ((JComboBox)editorComponent).setSelectedItem(value.toString()); delegate = new EditorDelegate(); ((JComboBox)editorComponent).addActionListener(delegate); } return editorComponent; } // getTreeCellEditorComponent()
String name, String baseUri, String publicId, String systemId, String replacementText)
EntityDeclaration decl, String name)
protected EntityReferenceImpl(Location location, //EntityDeclaration decl, String name, String baseUri, String publicId, String systemId, String replacementText) { super(location); //this.decl = decl; this.name = name; this.baseUri = baseUri; this.publicId = publicId; this.systemId = systemId; this.replacementText = replacementText; }
this.decl = decl;
protected EntityReferenceImpl(Location location, //EntityDeclaration decl, String name, String baseUri, String publicId, String systemId, String replacementText) { super(location); //this.decl = decl; this.name = name; this.baseUri = baseUri; this.publicId = publicId; this.systemId = systemId; this.replacementText = replacementText; }
this.baseUri = baseUri; this.publicId = publicId; this.systemId = systemId; this.replacementText = replacementText;
protected EntityReferenceImpl(Location location, //EntityDeclaration decl, String name, String baseUri, String publicId, String systemId, String replacementText) { super(location); //this.decl = decl; this.name = name; this.baseUri = baseUri; this.publicId = publicId; this.systemId = systemId; this.replacementText = replacementText; }
api = (BlockDeviceAPI) device.getAPI(BlockDeviceAPI.class);
api = device.getAPI(BlockDeviceAPI.class);
public AbstractFileSystem(Device device, boolean readOnly) throws FileSystemException { if (device == null) throw new IllegalArgumentException("null device!"); this.device = device; try { api = (BlockDeviceAPI) device.getAPI(BlockDeviceAPI.class); } catch (ApiNotFoundException e) { throw new FileSystemException("Device is not a partition!", e); } this.closed = false; this.readOnly = readOnly; }
log.debug("<<< BEGIN flush >>>");
public void flush() throws IOException { log.debug("<<< BEGIN flush >>>"); flushFiles(); flushDirectories(); log.debug("<<< END flush >>>"); }
log.debug("<<< END flush >>>");
public void flush() throws IOException { log.debug("<<< BEGIN flush >>>"); flushFiles(); flushDirectories(); log.debug("<<< END flush >>>"); }
int idx = i * 2;
int idx = i << 1;
public synchronized void write(BlockDeviceAPI device, long offset) throws IOException { byte[] data = new byte[nrSectors * sectorSize]; for (int i = 0; i < entries.length; i++) { long v = entries[i]; switch (bitSize) { case 12 : { int idx = (int) (i * 1.5); if ((i % 2) == 0) { data[idx] = (byte) (v & 0xFF); data[idx + 1] = (byte) ((v >> 8) & 0x0F); } else { data[idx] |= (byte) ((v & 0x0F) << 4); data[idx + 1] = (byte) ((v >> 4) & 0xFF); } } break; case 16 : { int idx = i * 2; data[idx] = (byte) (v & 0xFF); data[idx + 1] = (byte) ((v >> 8) & 0xFF); } break; case 32 : { int idx = i * 4; data[idx] = (byte) (v & 0xFF); data[idx + 1] = (byte) ((v >> 8) & 0xFF); data[idx + 2] = (byte) ((v >> 16) & 0xFF); data[idx + 3] = (byte) ((v >> 24) & 0xFF); } break; } } device.write(offset, data, 0, data.length); this.dirty = false; }
int idx = i * 4;
int idx = i << 2;
public synchronized void write(BlockDeviceAPI device, long offset) throws IOException { byte[] data = new byte[nrSectors * sectorSize]; for (int i = 0; i < entries.length; i++) { long v = entries[i]; switch (bitSize) { case 12 : { int idx = (int) (i * 1.5); if ((i % 2) == 0) { data[idx] = (byte) (v & 0xFF); data[idx + 1] = (byte) ((v >> 8) & 0x0F); } else { data[idx] |= (byte) ((v & 0x0F) << 4); data[idx + 1] = (byte) ((v >> 4) & 0xFF); } } break; case 16 : { int idx = i * 2; data[idx] = (byte) (v & 0xFF); data[idx + 1] = (byte) ((v >> 8) & 0xFF); } break; case 32 : { int idx = i * 4; data[idx] = (byte) (v & 0xFF); data[idx + 1] = (byte) ((v >> 8) & 0xFF); data[idx + 2] = (byte) ((v >> 16) & 0xFF); data[idx + 3] = (byte) ((v >> 24) & 0xFF); } break; } } device.write(offset, data, 0, data.length); this.dirty = false; }
log.debug("<<< BEGIN getRootEntry >>>");
public FSEntry getRootEntry() throws IOException { log.debug("<<< BEGIN getRootEntry >>>"); if(isClosed()) throw new IOException("FileSystem is closed"); if(rootEntry == null) { rootEntry = createRootEntry(); } log.debug("<<< END getRootEntry >>>"); return rootEntry; }
log.debug("<<< END getRootEntry >>>");
public FSEntry getRootEntry() throws IOException { log.debug("<<< BEGIN getRootEntry >>>"); if(isClosed()) throw new IOException("FileSystem is closed"); if(rootEntry == null) { rootEntry = createRootEntry(); } log.debug("<<< END getRootEntry >>>"); return rootEntry; }
g.fill(gp);
public void render(Graphics2D g, String text, int x, int y) { try { final GeneralPath gp = new GeneralPath(); gp.moveTo(x, y); final TTFGlyphTable glyphTable = fontData.getGlyphTable(); final TTFCMapTable cmapTable = fontData.getCMapTable(); final TTFHorizontalHeaderTable hheadTable = fontData.getHorizontalHeaderTable(); final TTFHorizontalMetricsTable hmTable = fontData.getHorizontalMetricsTable(); if (!(cmapTable.getNrEncodingTables() > 0)) { throw new RuntimeException("No Encoding is found!"); } final TTFCMapTable.EncodingTable encTable = cmapTable.getEncodingTable(0); if (encTable.getTableFormat() == null) { throw new RuntimeException("The table is NUll!!"); } final double ascent = hheadTable.getAscent(); final AffineTransform tx = new AffineTransform(); final double scale = fontSize / ascent; tx.translate(x, y + fontSize); tx.scale(scale, -scale); tx.translate(0, ascent); for (int i = 0; i < text.length(); i++) { // get the index for the needed glyph final int index = encTable.getTableFormat().getGlyphIndex(text.charAt(i)); Shape shape = glyphTable.getGlyph(index).getShape(); if(text.charAt(i) != ' ') gp.append(shape.getPathIterator(tx), false); tx.translate(hmTable.getAdvanceWidth(index), 0); } g.draw(gp); g.fill(gp); } catch (IOException ex) { log.error("Error drawing text", ex); } }
public LongSeqHolder(int[] initial_value)
public LongSeqHolder()
public LongSeqHolder(int[] initial_value) { value = initial_value; typecode.setLength(value.length); }
value = initial_value; typecode.setLength(value.length);
public LongSeqHolder(int[] initial_value) { value = initial_value; typecode.setLength(value.length); }
public ServantAlreadyActive(String why)
public ServantAlreadyActive()
public ServantAlreadyActive(String why) { super(why); }
super(why);
public ServantAlreadyActive(String why) { super(why); }
JRootPane createRootPane()
public JRootPane createRootPane()
JRootPane createRootPane() { return new JRootPane(); }
Component getGlassPane()
public Component getGlassPane()
Component getGlassPane() { return getRootPane().getGlassPane(); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
JLayeredPane getLayeredPane() { return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
JRootPane getRootPane() { if (rootPane == null) setRootPane(createRootPane()); return rootPane; }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
void setGlassPane(Component glassPane) { getRootPane().setGlassPane(glassPane); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
void setLayeredPane(JLayeredPane layeredPane) { getRootPane().setLayeredPane(layeredPane); }
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
void setRootPane(JRootPane root) { if (rootPane != null) remove(rootPane); rootPane = root; add(rootPane, BorderLayout.CENTER); }
mid = (low + hi) >> 1;
mid = (low + hi) >>> 1;
int binarySearch(int[] a, int key, int maxIndex) { int low = 0; int hi = maxIndex - 1; int mid = 0; while (low <= hi) { mid = (low + hi) >> 1; final int d = a[mid]; if (d == key) return mid; else if (d > key) hi = mid - 1; else // This gets the insertion point right on the last loop. low = ++mid; } return -mid - 1; }
for (int i = 0; i < positionMarks.length; i++)
for (int i = 0; i < numMarks; i++)
private void dumpMarks() { System.err.print("positionMarks: "); for (int i = 0; i < positionMarks.length; i++) System.err.print(positionMarks[i] + ", "); System.err.println(); }
if (p.index > start || p.index <= end) p.index = start; else if (p.index > end)
if (p.index > startIndex || p.index <= endIndex) p.index = startIndex; else if (p.index > endIndex)
private void setPositionsInRange(int start, int end, boolean toStart) { // We slump together all the GapContentPositions to point to // one mark. So this is implemented as follows: // 1. Remove all the marks in the specified range. // 2. Insert one new mark at the correct location. // 3. Adjust all affected GapContentPosition instances to point to // this new mark. synchronized (this) { int startIndex = binarySearch(positionMarks, start, numMarks); if (startIndex < 0) // Translate to insertion index, if not found. startIndex = - startIndex - 1; int endIndex = binarySearch(positionMarks, end, numMarks); if (endIndex < 0) // Translate to insertion index - 1, if not found. endIndex = - endIndex - 2; // Update the marks. // We have inclusive interval bounds, but let one element over for // filling in the new value. int removed = endIndex - startIndex; if (removed <= 0) return; System.arraycopy(positionMarks, endIndex + 1, positionMarks, startIndex + 1, positionMarks.length - endIndex - 1); numMarks -= removed; if (toStart) { positionMarks[startIndex] = start; } else { positionMarks[startIndex] = end; } // Update all affected GapContentPositions to point to the new index // and all GapContentPositions that come after the interval to // have their index moved by -removed. Set positionSet = positions.keySet(); for (Iterator i = positionSet.iterator(); i.hasNext();) { GapContentPosition p = (GapContentPosition) i.next(); if (p.index > start || p.index <= end) p.index = start; else if (p.index > end) p.index -= removed; } } }
private short[] getCursor(HardwareCursor cursor) {
private byte[] getCursor(HardwareCursor cursor) {
private short[] getCursor(HardwareCursor cursor) { final HardwareCursorImage img = cursor.getImage(32, 32); if (img == null) { return null; } short[] res = (short[]) cursorCache.get(img); if (res == null) { res = new short[1024]; final int[] argb = img.getImage(); for (int i = 0; i < 1024; i++) { final int v = argb[i]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF) >> 3; final int g = ((v >> 8) & 0xFF) >> 3; final int b = (v & 0xFF) >> 3; res[i] = (short) ((r << 10) | (g << 5) | b); if (a != 0) { res[i] |= 0x8000; } } cursorCache.put(img, res); } return res; }
short[] res = (short[]) cursorCache.get(img);
final int w = img.getWidth(); final int h = img.getHeight(); horzOffset = 64 - w; vertOffset = 64 - h; byte[] res = (byte[]) cursorCache.get(img);
private short[] getCursor(HardwareCursor cursor) { final HardwareCursorImage img = cursor.getImage(32, 32); if (img == null) { return null; } short[] res = (short[]) cursorCache.get(img); if (res == null) { res = new short[1024]; final int[] argb = img.getImage(); for (int i = 0; i < 1024; i++) { final int v = argb[i]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF) >> 3; final int g = ((v >> 8) & 0xFF) >> 3; final int b = (v & 0xFF) >> 3; res[i] = (short) ((r << 10) | (g << 5) | b); if (a != 0) { res[i] |= 0x8000; } } cursorCache.put(img, res); } return res; }
res = new short[1024];
res = new byte[1024];
private short[] getCursor(HardwareCursor cursor) { final HardwareCursorImage img = cursor.getImage(32, 32); if (img == null) { return null; } short[] res = (short[]) cursorCache.get(img); if (res == null) { res = new short[1024]; final int[] argb = img.getImage(); for (int i = 0; i < 1024; i++) { final int v = argb[i]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF) >> 3; final int g = ((v >> 8) & 0xFF) >> 3; final int b = (v & 0xFF) >> 3; res[i] = (short) ((r << 10) | (g << 5) | b); if (a != 0) { res[i] |= 0x8000; } } cursorCache.put(img, res); } return res; }
for (int i = 0; i < 1024; i++) { final int v = argb[i]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF) >> 3; final int g = ((v >> 8) & 0xFF) >> 3; final int b = (v & 0xFF) >> 3;
for (int row = 0; row < h; row++) { final int imgOfs = row * w; final int resOfs = row * 16; for (int x = 0; x < w; x++) { final int resRowIdx = resOfs + (((64 - w) + x) >> 3); final int resRowBit = 1 << (7 - (((64 - w) + x) & 7));
private short[] getCursor(HardwareCursor cursor) { final HardwareCursorImage img = cursor.getImage(32, 32); if (img == null) { return null; } short[] res = (short[]) cursorCache.get(img); if (res == null) { res = new short[1024]; final int[] argb = img.getImage(); for (int i = 0; i < 1024; i++) { final int v = argb[i]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF) >> 3; final int g = ((v >> 8) & 0xFF) >> 3; final int b = (v & 0xFF) >> 3; res[i] = (short) ((r << 10) | (g << 5) | b); if (a != 0) { res[i] |= 0x8000; } } cursorCache.put(img, res); } return res; }
res[i] = (short) ((r << 10) | (g << 5) | b); if (a != 0) { res[i] |= 0x8000;
final int v = argb[imgOfs + x]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF); final int g = ((v >> 8) & 0xFF); final int b = (v & 0xFF); if (a != 0) { if (((r + g + b) / 3) >= 128) { } else { res[resRowIdx+8] |= resRowBit; } } else { res[resRowIdx] |= resRowBit; }
private short[] getCursor(HardwareCursor cursor) { final HardwareCursorImage img = cursor.getImage(32, 32); if (img == null) { return null; } short[] res = (short[]) cursorCache.get(img); if (res == null) { res = new short[1024]; final int[] argb = img.getImage(); for (int i = 0; i < 1024; i++) { final int v = argb[i]; final int a = (v >>> 24) & 0xFF; final int r = ((v >> 16) & 0xFF) >> 3; final int g = ((v >> 8) & 0xFF) >> 3; final int b = (v & 0xFF) >> 3; res[i] = (short) ((r << 10) | (g << 5) | b); if (a != 0) { res[i] |= 0x8000; } } cursorCache.put(img, res); } return res; }
final short[] cur = getCursor(cursor);
final byte[] cur = getCursor(cursor);
public void setCursorImage(HardwareCursor cursor) { // Background color io.setReg32(CUR_CLR0, 0xffffff); // Foreground color io.setReg32(CUR_CLR1, 0); // Set shape final short[] cur = getCursor(cursor); if (cur != null) { cursorMem.setShorts(cur, 0, 0, 1024); } }
cursorMem.setShorts(cur, 0, 0, 1024);
io.setReg32(CUR_HORZ_VERT_OFF, vertOffset + (horzOffset << 16)); cursorMem.setBytes(cur, 0, 0, 1024);
public void setCursorImage(HardwareCursor cursor) { // Background color io.setReg32(CUR_CLR0, 0xffffff); // Foreground color io.setReg32(CUR_CLR1, 0); // Set shape final short[] cur = getCursor(cursor); if (cur != null) { cursorMem.setShorts(cur, 0, 0, 1024); } }
| (xorigin << 16) | yorigin );
| ((xorigin + horzOffset) << 16) | (yorigin + vertOffset));
public void setCursorPosition(int x, int y) { // if upper-left corner of cursor is outside of // screen, we have to use special registers to clip it int xorigin = 0; int yorigin = 0; if( x < 0 ) { xorigin = -x; } if( y < 0 ) { yorigin = -y; } //Radeon_WaitForFifo( ai, 3 ); io.setReg32(CUR_HORZ_VERT_OFF, CUR_LOCK | (xorigin << 16) | yorigin ); io.setReg32(CUR_HORZ_VERT_POSN, CUR_LOCK | (((xorigin != 0) ? 0 : x) << 16) | ((yorigin != 0) ? 0 : y) ); io.setReg32(CUR_OFFSET, (int)cursorMem.getOffset() + xorigin + yorigin * 16 ); }
calculateThumbLocation();
calculateGeometry();
public void paint(Graphics g, JComponent c) { // FIXME: Move this to propertyChangeEvent handler, when we get those. leftToRightCache = slider.getComponentOrientation() != ComponentOrientation.RIGHT_TO_LEFT; // FIXME: This next line is only here because the above line is here. calculateThumbLocation(); if (slider.getPaintTrack()) paintTrack(g); if (slider.getPaintTicks()) paintTicks(g); if (slider.getPaintLabels()) paintLabels(g); //FIXME: Paint focus. paintThumb(g); }
awtComponent.update(g);
protected void paintComponent(Graphics g) { super.paintComponent(g); awtComponent.update(g); }
public AbstractAction(String name) { this(name, null); }
public AbstractAction() { this(""); }
public AbstractAction(String name) { this(name, null); // TODO: default icon?? } // AbstractAction()
public void setContentAreaFilled(boolean b) { }
public void setContentAreaFilled(boolean b) { boolean old = content_area_filled; content_area_filled = b; if (b != old) { firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b); revalidate(); repaint(); } }
public void setContentAreaFilled(boolean b) { //Sets whether the button should paint the content area or leave it transparent. }