public static INode head; static { head = new INode(8); }
public INode head; // remove static public List() { head = new INode(8); }
public static INode head = new INode(8); // create instance during class initialization
private synchronized void internalClose() throws IOException { INode inode = new INode(FileType.FILE, blocks.toArray(new Block[blocks .size()])); store.storeINode(path, inode); }
private synchronized void internalClose() throws IOException { INode inode = new INode(FileType.FILE, blocks.toArray(new Block[blocks .size()])); store.storeINode(path, inode); }
private synchronized void internalClose() throws IOException { INode inode = new INode(FileType.FILE, blocks.toArray(new Block[blocks .size()])); store.storeINode(path, inode); }
public static void main (String[] args) { new List(); INode a = new INode(8); int data = a.getValue(); System.out.println(data); System.out.println(head.getValue());
public static void main (String[] args) { INode a = new INode(8); int data = a.getValue(); System.out.println(data); List l = new List(); // create new List instance System.out.println(l.head.getValue()); // get the head from List instance }
public static INode deserialize(InputStream in) throws IOException { if (in == null) { return null; } DataInputStream dataIn = new DataInputStream(in); FileType fileType = INode.FILE_TYPES[dataIn.readByte()]; switch (fileType) { case DIRECTORY: in.close(); return INode.DIRECTORY_INODE; case FILE: int numBlocks = dataIn.readInt(); Block[] blocks = new Block[numBlocks]; for (int i = 0; i < numBlocks; i++) { long id = dataIn.readLong(); long length = dataIn.readLong(); blocks[i] = new Block(id, length); } in.close(); return new INode(fileType, blocks); default: throw new IllegalArgumentException("Cannot deserialize inode."); } }
public static INode deserialize(InputStream in) throws IOException { if (in == null) { return null; } DataInputStream dataIn = new DataInputStream(in); FileType fileType = INode.FILE_TYPES[dataIn.readByte()]; switch (fileType) { case DIRECTORY: in.close(); return INode.DIRECTORY_INODE; case FILE: int numBlocks = dataIn.readInt(); Block[] blocks = new Block[numBlocks]; for (int i = 0; i < numBlocks; i++) { long id = dataIn.readLong(); long length = dataIn.readLong(); blocks[i] = new Block(id, length); } in.close(); return new INode(fileType, blocks); default: throw new IllegalArgumentException("Cannot deserialize inode."); } }
public static INode deserialize(InputStream in) throws IOException { if (in == null) { return null; } DataInputStream dataIn = new DataInputStream(in); FileType fileType = INode.FILE_TYPES[dataIn.readByte()]; switch (fileType) { case DIRECTORY: in.close(); return INode.DIRECTORY_INODE; case FILE: int numBlocks = dataIn.readInt(); Block[] blocks = new Block[numBlocks]; for (int i = 0; i < numBlocks; i++) { long id = dataIn.readLong(); long length = dataIn.readLong(); blocks[i] = new Block(id, length); } in.close(); return new INode(fileType, blocks); default: throw new IllegalArgumentException("Cannot deserialize inode."); } }
public void testSerializeFileWithSingleBlock() throws IOException { Block[] blocks = { new Block(849282477840258181L, 128L) }; INode inode = new INode(FileType.FILE, blocks); assertEquals("Length", 1L + 4 + 16, inode.getSerializedLength()); InputStream in = inode.serialize(); INode deserialized = INode.deserialize(in); assertEquals("FileType", inode.getFileType(), deserialized.getFileType()); Block[] deserializedBlocks = deserialized.getBlocks(); assertEquals("Length", 1, deserializedBlocks.length); assertEquals("Id", blocks[0].getId(), deserializedBlocks[0].getId()); assertEquals("Length", blocks[0].getLength(), deserializedBlocks[0] .getLength()); }