/** * DOCUMENT ME! * * @param channel * @param order DOCUMENT ME! * * * @throws IOException */ public static FileSystemNode readNode(int id, Node parent, FileChannel channel, ByteOrder order) throws IOException { ScrollingBuffer buffer = new ScrollingBuffer(channel, order); return readNode(id, parent, buffer); }
@Override public void close() { if(buffer != null) { buffer.close(); } buffer = null; }
static FileSystemNode readNode(int id, Node parent, ScrollingBuffer buf) throws IOException { // offset int offset = buf.getInt(); // envelope Envelope env = buf.getEnvelope(); // shapes in this node int numShapesId = buf.getInt(); int[] ids = null; if(numShapesId > 0) { ids = new int[numShapesId]; buf.getIntArray(ids); } else { ids = ZERO; } int numSubNodes = buf.getInt(); // let's create the new node FileSystemNode node = new FileSystemNode(env, buf, (int) buf.getPosition(), offset); node.setShapesId(ids); node.setNumSubNodes(numSubNodes); return node; }
static FileSystemNode readNode(int id, Node parent, ScrollingBuffer buf) throws IOException { // offset int offset = buf.getInt(); double x1; double y1; double x2; double y2; // envelope x1 = buf.getDouble(); y1 = buf.getDouble(); x2 = buf.getDouble(); y2 = buf.getDouble(); Envelope env = new Envelope(x1, x2, y1, y2); // shapes in this node int numShapesId = buf.getInt(); int[] ids = new int[numShapesId]; buf.getIntArray(ids); int numSubNodes = buf.getInt(); // let's create the new node FileSystemNode node = new FileSystemNode(env, id, parent, buf, (int) buf.getPosition(), offset); node.setShapesId(ids); node.setNumSubNodes(numSubNodes); return node; }
public Node copy() throws IOException { FileSystemNode copy = new FileSystemNode(getBounds(), id, getParent(), buffer, subNodeStartByte, subNodesLength ); copy.numShapesId=numShapesId; copy.shapesId=new int [numShapesId]; System.arraycopy(shapesId, 0, copy.shapesId, 0, numShapesId); copy.numSubNodes=numSubNodes; return copy; } /**
public Node copy() throws IOException { FileSystemNode copy = new FileSystemNode(getBounds(), buffer, subNodeStartByte, subNodesLength); copy.numShapesId = numShapesId; copy.shapesId = new int[numShapesId]; System.arraycopy(shapesId, 0, copy.shapesId, 0, numShapesId); copy.numSubNodes = numSubNodes; return copy; }
public int getInt() throws IOException { if(!useMemoryMapping && buffer.remaining() < 4) { refillBuffer(4); } return buffer.getInt(); }
/** * Jumps the buffer to the specified position in the file * @param newPosition * @throws IOException */ public void goTo(long newPosition) throws IOException { // if the new position is already in the buffer, just move the buffer position // otherwise we have to reload it if(newPosition >= bufferStart && newPosition <= bufferStart + buffer.limit()) { buffer.position((int) (newPosition - bufferStart)); } else { readBuffer(newPosition); } }
static FileSystemNode readNode(int id, Node parent, ScrollingBuffer buf) throws IOException { // offset int offset = buf.getInt(); // envelope Envelope env = buf.getEnvelope(); // shapes in this node int numShapesId = buf.getInt(); int[] ids = null; if(numShapesId > 0) { ids = new int[numShapesId]; buf.getIntArray(ids); } else { ids = ZERO; } int numSubNodes = buf.getInt(); // let's create the new node FileSystemNode node = new FileSystemNode(env, buf, (int) buf.getPosition(), offset); node.setShapesId(ids); node.setNumSubNodes(numSubNodes); return node; }
/** * DOCUMENT ME! * * @param channel * @param order * DOCUMENT ME! * * * @throws IOException */ public static FileSystemNode readNode(int id, Node parent, FileChannel channel, ByteOrder order, boolean useMemoryMapping) throws IOException { ScrollingBuffer buffer = new ScrollingBuffer(channel, order, useMemoryMapping); return readNode(id, parent, buffer); }
public Node copy() throws IOException { FileSystemNode copy = new FileSystemNode(getBounds(), buffer, subNodeStartByte, subNodesLength); copy.numShapesId = numShapesId; copy.shapesId = new int[numShapesId]; System.arraycopy(shapesId, 0, copy.shapesId, 0, numShapesId); copy.numSubNodes = numSubNodes; return copy; }
public int getInt() throws IOException { if(!useMemoryMapping && buffer.remaining() < 4) { refillBuffer(4); } return buffer.getInt(); }
/** * Jumps the buffer to the specified position in the file * * @param newPosition * @throws IOException */ public void goTo(long newPosition) throws IOException { // if the new position is already in the buffer, just move the // buffer position // otherwise we have to reload it if (useMemoryMapping || newPosition >= bufferStart && newPosition <= bufferStart + buffer.limit()) { buffer.position((int) (newPosition - bufferStart)); } else { readBuffer(newPosition); } }
@Override public void close() { if(buffer != null) { buffer.close(); } buffer = null; }
/** * DOCUMENT ME! * * @param channel * @param order * DOCUMENT ME! * * * @throws IOException */ public static FileSystemNode readNode(int id, Node parent, FileChannel channel, ByteOrder order, boolean useMemoryMapping) throws IOException { ScrollingBuffer buffer = new ScrollingBuffer(channel, order, useMemoryMapping); return readNode(id, parent, buffer); }
public int getInt() throws IOException { if(buffer.remaining() < 4) refillBuffer(4); return buffer.getInt(); }
/** * Jumps the buffer to the specified position in the file * * @param newPosition * @throws IOException */ public void goTo(long newPosition) throws IOException { // if the new position is already in the buffer, just move the // buffer position // otherwise we have to reload it if (useMemoryMapping || newPosition >= bufferStart && newPosition <= bufferStart + buffer.limit()) { buffer.position((int) (newPosition - bufferStart)); } else { readBuffer(newPosition); } }
public double getDouble() throws IOException { if(buffer.remaining() < 8) refillBuffer(8); return buffer.getDouble(); }
public void getIntArray(int[] array) throws IOException { int size = array.length * 4; if(buffer.remaining() < size) refillBuffer(size); // read the array using a view IntBuffer intView = buffer.asIntBuffer(); intView.limit(array.length); intView.get(array); // don't forget to update the original buffer position, since the view is independent buffer.position(buffer.position() + size); }
public void getIntArray(int[] array) throws IOException { int size = array.length * 4; if (buffer.remaining() < size) refillBuffer(size); // read the array using a view IntBuffer intView = buffer.asIntBuffer(); intView.limit(array.length); intView.get(array); // don't forget to update the original buffer position, since the // view is independent buffer.position(buffer.position() + size); }