From: <ga...@us...> - 2009-03-13 20:07:34
|
Revision: 5098 http://jnode.svn.sourceforge.net/jnode/?rev=5098&view=rev Author: galatnm Date: 2009-03-13 20:07:21 +0000 (Fri, 13 Mar 2009) Log Message: ----------- Fix checkstyle. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentKey.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus; import org.jnode.fs.hfsplus.extent.ExtentDescriptor; @@ -42,14 +42,16 @@ * @param offset */ public HFSPlusForkData(final byte[] src, final int offset) { - byte[] data = new byte[FORK_DATA_LENGTH]; + byte[] data = new byte[FORK_DATA_LENGTH]; System.arraycopy(src, offset, data, 0, FORK_DATA_LENGTH); totalSize = BigEndian.getInt64(data, 0); clumpSize = BigEndian.getInt32(data, 8); totalBlock = BigEndian.getInt32(data, 12); extents = new ExtentDescriptor[8]; for (int i = 0; i < 8; i++) { - extents[i] = new ExtentDescriptor(data, EXTENT_OFFSET + (i * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH)); + extents[i] = + new ExtentDescriptor(data, EXTENT_OFFSET + + (i * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH)); } } @@ -62,24 +64,23 @@ * @param totalBock */ public HFSPlusForkData(long totalSize, int clumpSize, int totalBlock) { - this.totalSize = totalSize; - this.clumpSize = clumpSize; - this.totalBlock = totalBlock; - this.extents = new ExtentDescriptor[8]; - } - + this.totalSize = totalSize; + this.clumpSize = clumpSize; + this.totalBlock = totalBlock; + this.extents = new ExtentDescriptor[8]; + } + public byte[] getBytes() { - byte[] data = new byte[FORK_DATA_LENGTH]; - BigEndian.setInt64(data, 0, totalSize); - BigEndian.setInt32(data, 8, clumpSize); - BigEndian.setInt32(data, 12, totalBlock); + byte[] data = new byte[FORK_DATA_LENGTH]; + BigEndian.setInt64(data, 0, totalSize); + BigEndian.setInt32(data, 8, clumpSize); + BigEndian.setInt32(data, 12, totalBlock); return data; } - - - + /* * (non-Javadoc) + * * @see java.lang.Object#toString() */ public final String toString() { @@ -93,32 +94,32 @@ return s.toString(); } - public long getTotalSize() { - return totalSize; - } + public long getTotalSize() { + return totalSize; + } - public int getClumpSize() { - return clumpSize; - } + public int getClumpSize() { + return clumpSize; + } - public int getTotalBlocks() { - return totalBlock; - } - - public ExtentDescriptor getExtent(int index){ - return extents[index]; - } - - /** + public int getTotalBlocks() { + return totalBlock; + } + + public ExtentDescriptor getExtent(int index) { + return extents[index]; + } + + /** * * @param index * @param desc */ public final void addDescriptor(int index, ExtentDescriptor desc) { - extents[index] = desc; + extents[index] = desc; } - public ExtentDescriptor[] getExtents(){ + public ExtentDescriptor[] getExtents() { return extents; } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -23,50 +23,50 @@ import org.jnode.util.BigEndian; public class JournalInfoBlock { - /** Flag indicate that the journal is located in the volume itself. */ - public static final int IN_FS_MASK = 0x00000001; - /** - * Flag indicate that the journal located in an other device. This flag is - * not currently supported. - */ - public static final int ION_OTHER_DEVICE_MASK = 0x00000002; - /** Flag indicate that the journal header is invalid and must be initialize. */ - public static final int NEED_INITIALIZATION = 0x00000004; - /** One-bits flag. See constants */ - private int flag; - /** Device where the journal is located if it is not in the volume itself. */ - private int deviceSignature; - /** journal start position on the volume */ - private long offset; - /** Size of the journal included header and buffer. */ - private long size; + /** Flag indicate that the journal is located in the volume itself. */ + public static final int IN_FS_MASK = 0x00000001; + /** + * Flag indicate that the journal located in an other device. This flag is + * not currently supported. + */ + public static final int ION_OTHER_DEVICE_MASK = 0x00000002; + /** Flag indicate that the journal header is invalid and must be initialize. */ + public static final int NEED_INITIALIZATION = 0x00000004; + /** One-bits flag. See constants */ + private int flag; + /** Device where the journal is located if it is not in the volume itself. */ + private int deviceSignature; + /** journal start position on the volume */ + private long offset; + /** Size of the journal included header and buffer. */ + private long size; - public JournalInfoBlock(final byte[] src) { - byte[] data = new byte[180]; - System.arraycopy(src, 0, data, 0, 180); - flag = BigEndian.getInt32(data, 0); - deviceSignature = BigEndian.getInt32(data, 4); - offset = BigEndian.getInt64(data, 36); - size = BigEndian.getInt64(data, 44); - } + public JournalInfoBlock(final byte[] src) { + byte[] data = new byte[180]; + System.arraycopy(src, 0, data, 0, 180); + flag = BigEndian.getInt32(data, 0); + deviceSignature = BigEndian.getInt32(data, 4); + offset = BigEndian.getInt64(data, 36); + size = BigEndian.getInt64(data, 44); + } - public final String toString() { - return "Journal : " + offset + "::" + size; - } + public final String toString() { + return "Journal : " + offset + "::" + size; + } - public int getFlag() { - return flag; - } + public int getFlag() { + return flag; + } - public int getDeviceSignature() { - return deviceSignature; - } + public int getDeviceSignature() { + return deviceSignature; + } - public long getOffset() { - return offset; - } + public long getOffset() { + return offset; + } - public long getSize() { - return size; - } + public long getSize() { + return size; + } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus; import static org.jnode.fs.hfsplus.HfsPlusConstants.HFSPLUS_SUPER_MAGIC; @@ -58,11 +58,10 @@ * Create the volume header and load information for the file system passed * as parameter. * - * @param fs - * The file system contains HFS+ partition. + * @param fs The file system contains HFS+ partition. * - * @throws FileSystemException - * If magic number (0X482B) is incorrect or not available. + * @throws FileSystemException If magic number (0X482B) is incorrect or not + * available. */ public Superblock(final HfsPlusFileSystem fs, boolean create) throws FileSystemException { super(fs); @@ -77,7 +76,8 @@ data = new byte[SUPERBLOCK_LENGTH]; System.arraycopy(b.array(), 0, data, 0, SUPERBLOCK_LENGTH); if (getMagic() != HFSPLUS_SUPER_MAGIC) { - throw new FileSystemException("Not hfs+ volume header (" + getMagic() + ": bad magic)"); + throw new FileSystemException("Not hfs+ volume header (" + getMagic() + + ": bad magic)"); } } } catch (IOException e) { @@ -92,7 +92,8 @@ * * @throws ApiNotFoundException */ - public void create(HFSPlusParams params) throws IOException, ApiNotFoundException, FileSystemException { + public void create(HFSPlusParams params) + throws IOException, ApiNotFoundException, FileSystemException { int burnedBlocksBeforeVH = 0; int burnedBlocksAfterAltVH = 0; /* @@ -133,11 +134,13 @@ long allocationClumpSize = getClumpSize(params.getBlockCount()); long bitmapBlocks = allocationClumpSize / blockSize; long blockUsed = 2 + burnedBlocksBeforeVH + burnedBlocksAfterAltVH + bitmapBlocks; - + int startBlock = 1 + burnedBlocksBeforeVH; int blockCount = (int) bitmapBlocks; - - HFSPlusForkData forkdata = new HFSPlusForkData(allocationClumpSize, (int)allocationClumpSize,(int) bitmapBlocks); + + HFSPlusForkData forkdata = + new HFSPlusForkData(allocationClumpSize, (int) allocationClumpSize, + (int) bitmapBlocks); ExtentDescriptor desc = new ExtentDescriptor(startBlock, blockCount); forkdata.addDescriptor(0, desc); System.arraycopy(forkdata.getBytes(), 0, data, 112, HFSPlusForkData.FORK_DATA_LENGTH); @@ -154,14 +157,20 @@ nextBlock = desc.getStartBlock() + desc.getBlockCount(); } // Extent B-Tree initialization - forkdata = new HFSPlusForkData(params.getExtentClumpSize(),params.getExtentClumpSize(),(params.getExtentClumpSize() / blockSize)); + forkdata = + new HFSPlusForkData(params.getExtentClumpSize(), params.getExtentClumpSize(), + (params.getExtentClumpSize() / blockSize)); desc = new ExtentDescriptor(nextBlock, forkdata.getTotalBlocks()); forkdata.addDescriptor(0, desc); System.arraycopy(forkdata.getBytes(), 0, data, 192, HFSPlusForkData.FORK_DATA_LENGTH); blockUsed += forkdata.getTotalBlocks(); // Catalog B-Tree initialization - forkdata = new HFSPlusForkData(params.getCatalogClumpSize(),params.getCatalogClumpSize(),(params.getCatalogClumpSize() / blockSize)); - startBlock = this.getExtentsFile().getExtent(0).getStartBlock() + this.getExtentsFile().getExtent(0).getBlockCount(); + forkdata = + new HFSPlusForkData(params.getCatalogClumpSize(), params.getCatalogClumpSize(), + (params.getCatalogClumpSize() / blockSize)); + startBlock = + this.getExtentsFile().getExtent(0).getStartBlock() + + this.getExtentsFile().getExtent(0).getBlockCount(); blockCount = forkdata.getTotalBlocks(); desc = new ExtentDescriptor(startBlock, blockCount); forkdata.addDescriptor(0, desc); @@ -169,15 +178,14 @@ blockUsed += forkdata.getTotalBlocks(); this.setFreeBlocks(this.getFreeBlocks() - (int) blockUsed); - this.setNextAllocation((int) blockUsed - 1 - burnedBlocksAfterAltVH + 10 - * (this.getCatalogFile().getClumpSize() / this.getBlockSize())); + this.setNextAllocation((int) blockUsed - 1 - burnedBlocksAfterAltVH + 10 * + (this.getCatalogFile().getClumpSize() / this.getBlockSize())); } /** * Calculate the number of blocks needed for bitmap. * - * @param totalBlocks - * Total of blocks found in the device. + * @param totalBlocks Total of blocks found in the device. * * @return long - Number of blocks. * @@ -399,16 +407,15 @@ * @return */ public final String getAttributesAsString() { - return ((isAttribute(HFSPLUS_VOL_UNMNT_BIT)) ? " kHFSVolumeUnmountedBit" : "") - + ((isAttribute(HFSPLUS_VOL_INCNSTNT_BIT)) ? " kHFSBootVolumeInconsistentBit" : "") - + ((isAttribute(HFSPLUS_VOL_JOURNALED_BIT)) ? " kHFSVolumeJournaledBit" : ""); + return ((isAttribute(HFSPLUS_VOL_UNMNT_BIT)) ? " kHFSVolumeUnmountedBit" : "") + + ((isAttribute(HFSPLUS_VOL_INCNSTNT_BIT)) ? " kHFSBootVolumeInconsistentBit" : "") + + ((isAttribute(HFSPLUS_VOL_JOURNALED_BIT)) ? " kHFSVolumeJournaledBit" : ""); } /** * Check if the corresponding attribute corresponding is set. * - * @param maskBit - * Bit position of the attribute. See constants. + * @param maskBit Bit position of the attribute. See constants. * * @return true if attribute is set. */ @@ -429,16 +436,17 @@ StringBuffer buffer = new StringBuffer(); buffer.append("Magic: 0x").append(NumberUtils.hex(getMagic(), 4)).append("\n"); buffer.append("Version: ").append(getVersion()).append("\n").append("\n"); - buffer.append("Attributes: ").append(getAttributesAsString()).append(" (").append(getAttributes()).append(")") - .append("\n").append("\n"); - buffer.append("Create date: ").append(HFSUtils.printDate(getCreateDate(), "EEE MMM d HH:mm:ss yyyy")).append( - "\n"); - buffer.append("Modify date: ").append(HFSUtils.printDate(getModifyDate(), "EEE MMM d HH:mm:ss yyyy")).append( - "\n"); - buffer.append("Backup date: ").append(HFSUtils.printDate(getBackupDate(), "EEE MMM d HH:mm:ss yyyy")).append( - "\n"); - buffer.append("Checked date: ").append(HFSUtils.printDate(getCheckedDate(), "EEE MMM d HH:mm:ss yyyy")).append( - "\n").append("\n"); + buffer.append("Attributes: ").append(getAttributesAsString()).append(" (").append( + getAttributes()).append(")").append("\n").append("\n"); + buffer.append("Create date: ").append( + HFSUtils.printDate(getCreateDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); + buffer.append("Modify date: ").append( + HFSUtils.printDate(getModifyDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); + buffer.append("Backup date: ").append( + HFSUtils.printDate(getBackupDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n"); + buffer.append("Checked date: ").append( + HFSUtils.printDate(getCheckedDate(), "EEE MMM d HH:mm:ss yyyy")).append("\n") + .append("\n"); buffer.append("File count: ").append(getFileCount()).append("\n"); buffer.append("Folder count: ").append(getFolderCount()).append("\n").append("\n"); buffer.append("Block size: ").append(getBlockSize()).append("\n"); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus.catalog; import java.io.IOException; @@ -60,7 +60,7 @@ /** * Create Catalog based on meta-data that exist on the file system. - * + * * @param fs HFS+ file system that contains catalog informations. * @throws IOException */ @@ -71,8 +71,9 @@ ExtentDescriptor firstExtent = sb.getCatalogFile().getExtent(0); catalogHeaderNodeOffset = firstExtent.getStartBlock() * sb.getBlockSize(); if (firstExtent.getStartBlock() != 0 && firstExtent.getBlockCount() != 0) { - buffer = ByteBuffer.allocate(NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH - + BTHeaderRecord.BT_HEADER_RECORD_LENGTH); + buffer = + ByteBuffer.allocate(NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH + + BTHeaderRecord.BT_HEADER_RECORD_LENGTH); fs.getApi().read(catalogHeaderNodeOffset, buffer); buffer.rewind(); byte[] data = ByteBufferUtils.toArray(buffer); @@ -84,7 +85,7 @@ /** * Create new Catalog - * + * * @param params */ public Catalog(HFSPlusParams params) { @@ -111,10 +112,10 @@ bthr.setClumpSize(params.getCatalogClumpSize()); // TODO initialize attributes, max key length and key comparaison type. bufferLength += BTHeaderRecord.BT_HEADER_RECORD_LENGTH; - // Create root node + // Create root node int rootNodePosition = bthr.getRootNode() * nodeSize; bufferLength += (rootNodePosition - bufferLength); - //Create node descriptor + // Create node descriptor NodeDescriptor nd = new NodeDescriptor(); nd.setKind(HfsPlusConstants.BT_LEAF_NODE); nd.setHeight(1); @@ -136,8 +137,9 @@ // Second record (thread) offset = offset + ck.getKeyLength() + CatalogFolder.CATALOG_FOLDER_SIZE; CatalogKey tck = new CatalogKey(CatalogNodeId.HFSPLUS_ROOT_CNID, name); - CatalogThread ct = new CatalogThread(HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, - CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); + CatalogThread ct = + new CatalogThread(HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, + CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); record = new LeafRecord(tck, ct.getBytes()); rootNode.addNodeRecord(1, record, offset); buffer = ByteBuffer.allocate(bufferLength + bthr.getNodeSize()); @@ -153,13 +155,13 @@ * @return * @throws IOException */ - public final LeafRecord getRecord(final CatalogNodeId parentID) - throws IOException { + public final LeafRecord getRecord(final CatalogNodeId parentID) throws IOException { int currentOffset = 0; LeafRecord lr = null; int nodeSize = getBTHeaderRecord().getNodeSize(); ByteBuffer nodeData = ByteBuffer.allocate(nodeSize); - fs.getApi().read(catalogHeaderNodeOffset + (getBTHeaderRecord().getRootNode() * nodeSize), nodeData); + fs.getApi().read(catalogHeaderNodeOffset + (getBTHeaderRecord().getRootNode() * nodeSize), + nodeData); nodeData.rewind(); byte[] data = ByteBufferUtils.toArray(nodeData); CatalogNode node = new CatalogNode(data, nodeSize); @@ -180,22 +182,22 @@ } /** - * Find leaf records corresponding to parentID. The search begin at the root node of the tree. - * + * Find leaf records corresponding to parentID. The search begin at the root + * node of the tree. + * * @param parentID Parent node id * @return Array of LeafRecord * @throws IOException */ - public final LeafRecord[] getRecords(final CatalogNodeId parentID) - throws IOException { + public final LeafRecord[] getRecords(final CatalogNodeId parentID) throws IOException { return getRecords(parentID, getBTHeaderRecord().getRootNode()); } /** - * Find leaf records corresponding to parentID. The search begin at the node correspding - * to the index passed as parameter. - * - * @param parentID Parent node id + * Find leaf records corresponding to parentID. The search begin at the node + * correspding to the index passed as parameter. + * + * @param parentID Parent node id * @param nodeNumber Index of node where the search begin. * @return Array of LeafRecord * @throws IOException Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus.catalog; import org.jnode.fs.hfsplus.HFSUnicodeString; @@ -26,19 +26,19 @@ import org.jnode.util.BigEndian; public class CatalogKey extends AbstractKey { - - public static final int MINIMUM_KEY_LENGTH = 6; - public static final int MAXIMUM_KEY_LENGTH = 516; - /** - * Catalog node id of the folder that contains file or folder represented by - * the record. For thread records, contains the catalog node id of the file - * or folder itself. - */ - private CatalogNodeId parentId; - /** Name of the file or folder, empty for thread records. */ - private HFSUnicodeString nodeName; + public static final int MINIMUM_KEY_LENGTH = 6; + public static final int MAXIMUM_KEY_LENGTH = 516; /** + * Catalog node id of the folder that contains file or folder represented by + * the record. For thread records, contains the catalog node id of the file + * or folder itself. + */ + private CatalogNodeId parentId; + /** Name of the file or folder, empty for thread records. */ + private HFSUnicodeString nodeName; + + /** * Create catalog key from existing data. * * @param src @@ -60,7 +60,8 @@ } /** - * Create new catalog key based on parent CNID and the name of the file or folder. + * Create new catalog key based on parent CNID and the name of the file or + * folder. * * @param parentID Parent catalog node identifier. * @param name Name of the file or folder. @@ -93,8 +94,9 @@ CatalogKey ck = (CatalogKey) key; res = this.getParentId().compareTo(ck.getParentId()); if (res == 0) { - res = this.getNodeName().getUnicodeString().compareTo( - ck.getNodeName().getUnicodeString()); + res = + this.getNodeName().getUnicodeString().compareTo( + ck.getNodeName().getUnicodeString()); } } return res; @@ -102,6 +104,7 @@ /* * (non-Javadoc) + * * @see org.jnode.fs.hfsplus.tree.AbstractKey#getBytes() */ public byte[] getBytes() { @@ -111,16 +114,18 @@ System.arraycopy(nodeName.getBytes(), 0, data, 6, nodeName.getLength()); return data; } - + /* * (non-Javadoc) + * * @see java.lang.Object#toString() */ public final String toString() { StringBuffer s = new StringBuffer(); - s.append("[length, Parent ID, Node name]:").append(getKeyLength()).append(",").append(getParentId().getId()) - .append(",").append((getNodeName() != null) ? getNodeName().getUnicodeString() : ""); + s.append("[length, Parent ID, Node name]:").append(getKeyLength()).append(",").append( + getParentId().getId()).append(",").append( + (getNodeName() != null) ? getNodeName().getUnicodeString() : ""); return s.toString(); } - + } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -17,24 +17,25 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus.catalog; import org.jnode.fs.hfsplus.HFSUnicodeString; import org.jnode.util.BigEndian; +public class CatalogThread { - -public class CatalogThread { - public static final int CATALOG_THREAD_SIZE = 512; - /**The catalog thread record type. Can be a file or a folder. */ + /** The catalog thread record type. Can be a file or a folder. */ private int recordType; - /** the catalog node id of the file or folder referenced by the thread record. */ + /** + * the catalog node id of the file or folder referenced by the thread + * record. + */ private CatalogNodeId parentId; /** the name of the file or folder reference by the thread record. */ private HFSUnicodeString nodeName; - + /** * Create catalog thread from existing data. * @@ -51,27 +52,29 @@ /** * Create a new catalog thread. * - * @param type catalog thread record type. - * @param parent {@link CatalogNodeId} of the file or folder reference by the tread record. - * @param name {@link HFSUnicodeString} represent the name of the file or folder reference by the tread record. + * @param type catalog thread record type. + * @param parent {@link CatalogNodeId} of the file or folder reference by + * the tread record. + * @param name {@link HFSUnicodeString} represent the name of the file or + * folder reference by the tread record. */ public CatalogThread(int type, CatalogNodeId parent, HFSUnicodeString name) { - this.recordType = type; - this.parentId = parent; - this.nodeName = name; + this.recordType = type; + this.parentId = parent; + this.nodeName = name; } - + /** * * @return */ public byte[] getBytes() { - byte[] data = new byte[512]; + byte[] data = new byte[512]; BigEndian.setInt16(data, 0, recordType); BigEndian.setInt32(data, 4, parentId.getId()); System.arraycopy(parentId.getBytes(), 0, data, 4, 4); System.arraycopy(nodeName.getBytes(), 0, data, 8, nodeName.getBytes().length); return data; } - + } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -17,13 +17,13 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus.extent; import org.jnode.util.BigEndian; public class ExtentDescriptor { - /** The size pf the extent descriptor. */ + /** The size of the extent descriptor. */ public static final int EXTENT_DESCRIPTOR_LENGTH = 8; /** The first allocation block. */ private int startBlock; @@ -37,47 +37,48 @@ * @param blockCount number of blocks in the extent. */ public ExtentDescriptor(int startBlock, int blockCount) { - this.startBlock = startBlock; - this.blockCount = blockCount; - } - + this.startBlock = startBlock; + this.blockCount = blockCount; + } + /** * Create extent descriptor from existing data. * * @param src byte array contains existing extent descriptor informations. * @param offset position where data for extent descriptor begin. */ - public ExtentDescriptor(final byte[] src, final int offset) { - byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; + public ExtentDescriptor(final byte[] src, final int offset) { + byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; System.arraycopy(src, offset, data, 0, EXTENT_DESCRIPTOR_LENGTH); startBlock = BigEndian.getInt32(data, 0); - blockCount = BigEndian.getInt32(data, 4); + blockCount = BigEndian.getInt32(data, 4); } - /** - * - * @return - */ + + /** + * + * @return + */ public final byte[] getBytes() { - byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; - BigEndian.setInt32(data, 0, startBlock); - BigEndian.setInt32(data, 4, blockCount); - return data; - } + byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; + BigEndian.setInt32(data, 0, startBlock); + BigEndian.setInt32(data, 4, blockCount); + return data; + } public final String toString() { return "Start block : " + startBlock + "\tBlock count : " + blockCount + "\n"; } - public int getStartBlock() { - return startBlock; - } + public int getStartBlock() { + return startBlock; + } - public int getBlockCount() { - return blockCount; - } - - public boolean isEmpty(){ - return (startBlock == 0 || blockCount == 0); - } + public int getBlockCount() { + return blockCount; + } + public boolean isEmpty() { + return (startBlock == 0 || blockCount == 0); + } + } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentKey.java 2009-03-13 19:35:50 UTC (rev 5097) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentKey.java 2009-03-13 20:07:21 UTC (rev 5098) @@ -27,93 +27,93 @@ public class ExtentKey extends AbstractKey { - public static final byte DATA_FORK = (byte) 0x00; - public static final byte RESOURCE_FORK = (byte) 0xFF; - public static final int KEY_LENGTH = 12; + public static final byte DATA_FORK = (byte) 0x00; + public static final byte RESOURCE_FORK = (byte) 0xFF; + public static final int KEY_LENGTH = 12; - private int forkType; - private int pad; - private CatalogNodeId fileId; - private int startBlock; + private int forkType; + private int pad; + private CatalogNodeId fileId; + private int startBlock; - /** - * - * @param src - * @param offset - */ - public ExtentKey(final byte[] src, final int offset) { - byte[] ek = new byte[KEY_LENGTH]; - System.arraycopy(src, offset, ek, 0, KEY_LENGTH); - keyLength = BigEndian.getInt16(ek, 0); - forkType = BigEndian.getInt8(ek, 2); - pad = BigEndian.getInt8(ek, 3); - fileId = new CatalogNodeId(ek, 4); - startBlock = BigEndian.getInt32(ek, 8); - } + /** + * + * @param src + * @param offset + */ + public ExtentKey(final byte[] src, final int offset) { + byte[] ek = new byte[KEY_LENGTH]; + System.arraycopy(src, offset, ek, 0, KEY_LENGTH); + keyLength = BigEndian.getInt16(ek, 0); + forkType = BigEndian.getInt8(ek, 2); + pad = BigEndian.getInt8(ek, 3); + fileId = new CatalogNodeId(ek, 4); + startBlock = BigEndian.getInt32(ek, 8); + } - /** - * - * @param forkType - * @param pad - * @param fileId - * @param startBlock - */ - public ExtentKey(int forkType, int pad, CatalogNodeId fileId, int startBlock) { - super(); - this.forkType = forkType; - this.pad = pad; - this.fileId = fileId; - this.startBlock = startBlock; - } + /** + * + * @param forkType + * @param pad + * @param fileId + * @param startBlock + */ + public ExtentKey(int forkType, int pad, CatalogNodeId fileId, int startBlock) { + super(); + this.forkType = forkType; + this.pad = pad; + this.fileId = fileId; + this.startBlock = startBlock; + } - @Override - public final int compareTo(final Key key) { - int res = -1; - if (key instanceof ExtentKey) { - ExtentKey compareKey = (ExtentKey) key; - res = fileId.compareTo(compareKey.getFileId()); - if (res == 0) { - res = compareForkType(compareKey.getForkType()); - if (res == 0) { - return compareStartBlock(compareKey.getStartBlock()); - } - } - } - return res; - } + @Override + public final int compareTo(final Key key) { + int res = -1; + if (key instanceof ExtentKey) { + ExtentKey compareKey = (ExtentKey) key; + res = fileId.compareTo(compareKey.getFileId()); + if (res == 0) { + res = compareForkType(compareKey.getForkType()); + if (res == 0) { + return compareStartBlock(compareKey.getStartBlock()); + } + } + } + return res; + } - @Override - public byte[] getBytes() { - byte[] data = new byte[this.getKeyLength()]; - return data; - } + @Override + public byte[] getBytes() { + byte[] data = new byte[this.getKeyLength()]; + return data; + } - private int compareForkType(int fork) { - Integer currentForkType = Integer.valueOf(forkType); - Integer forkType = Integer.valueOf(fork); - return currentForkType.compareTo(forkType); - } + private int compareForkType(int fork) { + Integer currentForkType = Integer.valueOf(forkType); + Integer forkType = Integer.valueOf(fork); + return currentForkType.compareTo(forkType); + } - private int compareStartBlock(int block) { - Integer currentStartBlock = Integer.valueOf(startBlock); - Integer startBlock = Integer.valueOf(block); - return currentStartBlock.compareTo(startBlock); - } + private int compareStartBlock(int block) { + Integer currentStartBlock = Integer.valueOf(startBlock); + Integer startBlock = Integer.valueOf(block); + return currentStartBlock.compareTo(startBlock); + } - public int getForkType() { - return forkType; - } + public int getForkType() { + return forkType; + } - public int getPad() { - return pad; - } + public int getPad() { + return pad; + } - public CatalogNodeId getFileId() { - return fileId; - } + public CatalogNodeId getFileId() { + return fileId; + } - public int getStartBlock() { - return startBlock; - } + public int getStartBlock() { + return startBlock; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |