From: <ga...@us...> - 2009-01-10 11:26:38
|
Revision: 4844 http://jnode.svn.sourceforge.net/jnode/?rev=4844&view=rev Author: galatnm Date: 2009-01-10 11:26:31 +0000 (Sat, 10 Jan 2009) Log Message: ----------- Checkstyle fixes. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.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/CatalogFolder.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/BTHeaderRecord.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/NodeDescriptor.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -53,8 +53,7 @@ * @throws FileSystemException * */ - public void initializeDefaultsValues(long blockDeviceSize, long sectorSize) - throws FileSystemException { + public void initializeDefaultsValues(long blockDeviceSize, long sectorSize) throws FileSystemException { long clumpSize = 0; this.blockDeviceSize = blockDeviceSize; if (resourceClumpBlocks == 0) { @@ -82,55 +81,50 @@ } long sectorCount = blockDeviceSize / sectorSize; if (catalogClumpBlocks == 0) { - clumpSize = getBTreeClumpSize(blockSize, catalogNodeSize, - sectorCount, true); + clumpSize = getBTreeClumpSize(blockSize, catalogNodeSize, sectorCount, true); } else { clumpSize = clumpSizeCalculation(catalogClumpBlocks); if (clumpSize % catalogNodeSize != 0) { - throw new FileSystemException( - "clump size is not a multiple of node size"); + throw new FileSystemException("clump size is not a multiple of node size"); } } catalogClumpSize = (int) clumpSize; if (extentClumpBlocks == 0) { - clumpSize = getBTreeClumpSize(blockSize, extentNodeSize, - sectorCount, false); + clumpSize = getBTreeClumpSize(blockSize, extentNodeSize, sectorCount, false); } else { clumpSize = clumpSizeCalculation(extentClumpBlocks); } extentClumpSize = (int) clumpSize; - - if(attributeClumpBlocks == 0){ + + if (attributeClumpBlocks == 0) { clumpSize = 0; } else { clumpSize = clumpSizeCalculation(attributeClumpBlocks); - if(clumpSize % attributeNodeSize != 0){ + if (clumpSize % attributeNodeSize != 0) { throw new FileSystemException("clump size is not a multiple of attribute node size"); } } - attributeClumpSize = (int)clumpSize; - + attributeClumpSize = (int) clumpSize; + long totalBlocks = this.getBlockCount(); long minClumpSize = this.getBlockCount() >> 3; if ((totalBlocks & 7) == 0) { ++minClumpSize; } - if(bitmapClumpBlocks == 0){ + if (bitmapClumpBlocks == 0) { clumpSize = minClumpSize; } else { clumpSize = clumpSizeCalculation(bitmapClumpBlocks); - if(clumpSize < minClumpSize){ + if (clumpSize < minClumpSize) { throw new FileSystemException("bitmap clump size is too small."); } } - allocationClumpSize = (int)clumpSize; - + allocationClumpSize = (int) clumpSize; + } - private int[] extentClumpTable = new int[] { 4, 4, 4, 5, 5, 6, 7, 8, 9, 11, - 14, 16, 20, 25, 32 }; - private int[] catalogClumpTable = new int[] { 4, 6, 8, 11, 14, 19, 25, 34, - 45, 60, 80, 107, 144, 192, 256 }; + private int[] extentClumpTable = new int[] {4, 4, 4, 5, 5, 6, 7, 8, 9, 11, 14, 16, 20, 25, 32 }; + private int[] catalogClumpTable = new int[] {4, 6, 8, 11, 14, 19, 25, 34, 45, 60, 80, 107, 144, 192, 256 }; /** * @@ -140,8 +134,7 @@ * @param catalog * @return */ - private long getBTreeClumpSize(int blockSize, int nodeSize, long sectors, - boolean catalog) { + private long getBTreeClumpSize(int blockSize, int nodeSize, long sectors, boolean catalog) { long clumpSize = 0; if (sectors < 0x200000) { clumpSize = (sectors << 2); @@ -172,13 +165,13 @@ private int clumpSizeCalculation(long clumpBlocks) throws FileSystemException { long clumpSize = clumpBlocks * blockSize; if ((clumpSize & 0XFFFFFFFF00000000L) == 0) { - throw new FileSystemException("Too many blocks (" + clumpBlocks + ") for clump size (" + clumpSize +")."); + throw new FileSystemException("Too many blocks (" + clumpBlocks + ") for clump size (" + clumpSize + ")."); } return (int) clumpSize; } - - private long round(long x, long y){ - return (((x+y)-1)/y*y); + + private long round(long x, long y) { + return (((x + y) - 1) / y * y); } public String getVolumeName() { Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -72,8 +72,7 @@ * * @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; /* @@ -87,7 +86,7 @@ } else if (blockSize == 1024) { burnedBlocksBeforeVH = 1; } - + // Populate volume header. this.setMagic(HfsPlusConstants.HFSPLUS_SUPER_MAGIC); this.setVersion(HfsPlusConstants.HFSPLUS_MIN_VERSION); @@ -116,8 +115,8 @@ long blockUsed = 2 + burnedBlocksBeforeVH + burnedBlocksAfterAltVH + bitmapBlocks; HFSPlusForkData forkdata = new HFSPlusForkData(); forkdata.setTotalSize(allocationClumpSize); - forkdata.setClumpSize((int)allocationClumpSize); - forkdata.setTotalBlocks((int)bitmapBlocks); + forkdata.setClumpSize((int) allocationClumpSize); + forkdata.setTotalBlocks((int) bitmapBlocks); ExtentDescriptor desc = new ExtentDescriptor(); desc.setStartBlock(1 + burnedBlocksBeforeVH); desc.setBlockCount(0); @@ -136,7 +135,7 @@ this.setJournalInfoBlock(0); nextBlock = desc.getStartBlock() + desc.getBlockCount(); } - // Extent B-Tree initialization + // Extent B-Tree initialization forkdata = new HFSPlusForkData(); forkdata.setTotalSize(params.getExtentClumpSize()); forkdata.setClumpSize(params.getExtentClumpSize()); @@ -159,12 +158,12 @@ forkdata.setExtentDescriptor(0, desc); System.arraycopy(forkdata.getBytes(), 0, data, 272, forkdata.FORK_DATA_LENGTH); blockUsed += forkdata.getTotalBlocks(); - + this.setFreeBlocks(this.getFreeBlocks() - (int) blockUsed); this.setNextAllocation((int) blockUsed - 1 - burnedBlocksAfterAltVH + 10 * (this.getCatalogFile().getClumpSize() / this.getBlockSize())); } - + /** * Calculate the number of blocks needed for bitmap. * Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -23,13 +23,13 @@ private NodeDescriptor btnd; private BTHeaderRecord bthr; private int firstNodeOffset; - + /** * Create new Catalog * * @param params */ - public Catalog(HFSPlusParams params){ + public Catalog(HFSPlusParams params) { btnd = new NodeDescriptor(); btnd.setKind(HfsPlusConstants.BT_HEADER_NODE); btnd.setHeight(0); @@ -42,20 +42,21 @@ bthr.setLastLeafNode(1); bthr.setLeafRecords(params.isJournaled() ? 6 : 2); bthr.setNodeSize(params.getCatalogNodeSize()); - bthr.setTotalNodes(params.getCatalogClumpSize()/params.getCatalogNodeSize()); + bthr.setTotalNodes(params.getCatalogClumpSize() / params.getCatalogNodeSize()); bthr.setFreeNodes(bthr.getTotalNodes() - 2); bthr.setClumpSize(params.getCatalogClumpSize()); - //TODO initialize attributes, max key length and key comparaison type. + // TODO initialize attributes, max key length and key comparaison type. // Root directory - CatalogKey ck = new CatalogKey(CatalogNodeId.HFSPLUS_POR_CNID,new HFSUnicodeString(params.getVolumeName())); + CatalogKey ck = new CatalogKey(CatalogNodeId.HFSPLUS_POR_CNID, new HFSUnicodeString(params.getVolumeName())); CatalogFolder folder = new CatalogFolder(); folder.setFolderId(CatalogNodeId.HFSPLUS_ROOT_CNID); folder.setValence(params.isJournaled() ? 2 : 0); - //TODO creation date, content modification date, text encoding and access rights. - ck = new CatalogKey(CatalogNodeId.HFSPLUS_ROOT_CNID,new HFSUnicodeString("")); - CatalogThread ct = new CatalogThread(HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); + // TODO creation date, content modification date, text encoding and access rights. + ck = new CatalogKey(CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); + CatalogThread ct = new CatalogThread(HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, + CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); } - + /** * Create Catalog based on catalog file that exist on the file system. * @@ -91,7 +92,8 @@ * @return * @throws IOException */ - public final LeafRecord getRecord(final CatalogNodeId parentID) throws IOException { + public final LeafRecord getRecord(final CatalogNodeId parentID) + throws IOException { int currentOffset = firstNodeOffset; int currentNodeNumber = getBTHeaderRecord().getRootNode(); int currentNodeSize = getBTHeaderRecord().getNodeSize(); @@ -126,7 +128,8 @@ * @return * @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()); } @@ -137,7 +140,8 @@ * @return * @throws IOException */ - public final LeafRecord[] getRecords(final CatalogNodeId parentID, final int nodeNumber) throws IOException { + public final LeafRecord[] getRecords(final CatalogNodeId parentID, final int nodeNumber) + throws IOException { try { int currentOffset = firstNodeOffset; int currentNodeNumber = nodeNumber; @@ -159,8 +163,7 @@ } return lfList.toArray(new LeafRecord[lfList.size()]); } else if (currentBtnd.getKind() == HfsPlusConstants.BT_LEAF_NODE) { - CatalogLeafNode leaf = new CatalogLeafNode(currentBtnd, nodeData.array(), - currentNodeSize); + CatalogLeafNode leaf = new CatalogLeafNode(currentBtnd, nodeData.array(), currentNodeSize); LeafRecord[] lr = leaf.findAll(parentID); log.debug("Leaf record size: " + lr.length); return lr; @@ -182,8 +185,8 @@ * @return * @throws IOException */ - public final LeafRecord getRecord(final CatalogNodeId parentID, - final HFSUnicodeString nodeName) throws IOException { + public final LeafRecord getRecord(final CatalogNodeId parentID, final HFSUnicodeString nodeName) + throws IOException { int currentOffset = firstNodeOffset; int currentNodeNumber = getBTHeaderRecord().getRootNode(); int currentNodeSize = getBTHeaderRecord().getNodeSize(); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -30,7 +30,7 @@ public final void setValence(int valence) { BigEndian.setInt32(data, 4, valence); } - + public final int getValence() { return BigEndian.getInt32(data, 4); } @@ -38,8 +38,8 @@ public final CatalogNodeId getFolderId() { return new CatalogNodeId(data, 8); } - - public final void setFolderId(CatalogNodeId folderId){ + + public final void setFolderId(CatalogNodeId folderId) { System.arraycopy(folderId.getBytes(), 0, data, 8, folderId.getBytes().length); } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -51,7 +51,6 @@ } else if (key.getParentId().getId() == parentId.getId()) { result.addLast(rec); } - } if (largestMatchingKey != null) { @@ -64,8 +63,8 @@ IndexRecord largestMatchingRecord = null; for (int i = 0; i < records.length; ++i) { if (records[i].getKey().compareTo(key) <= 0 - && (largestMatchingRecord == null || - records[i].getKey().compareTo(largestMatchingRecord.getKey()) > 0)) { + && (largestMatchingRecord == null + || records[i].getKey().compareTo(largestMatchingRecord.getKey()) > 0)) { largestMatchingRecord = records[i]; } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/command/FormatHfsPlusCommand.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -3,26 +3,26 @@ import org.jnode.fs.Formatter; import org.jnode.fs.command.AbstractFormatCommand; import org.jnode.fs.hfsplus.HFSPlusParams; -import org.jnode.fs.hfsplus.HfsPlusConstants; import org.jnode.fs.hfsplus.HfsPlusFileSystem; import org.jnode.fs.hfsplus.HfsPlusFileSystemFormatter; import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.StringArgument; public class FormatHfsPlusCommand extends AbstractFormatCommand<HfsPlusFileSystem> { - - private final StringArgument ARG_VOLUME_NAME = - new StringArgument("volumename", Argument.OPTIONAL, "set volume name"); + private final StringArgument ARG_VOLUME_NAME = new StringArgument("volumename", Argument.OPTIONAL, + "set volume name"); + public FormatHfsPlusCommand() { super("Format a block device with HFS+ filesystem"); registerArguments(ARG_VOLUME_NAME); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) + throws Exception { new FormatHfsPlusCommand().execute(args); } - + @Override protected Formatter<HfsPlusFileSystem> getFormatter() { HFSPlusParams params = new HFSPlusParams(); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/BTHeaderRecord.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/BTHeaderRecord.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/BTHeaderRecord.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -9,7 +9,7 @@ public BTHeaderRecord() { data = new byte[BT_HEADER_RECORD_LENGTH]; } - + public BTHeaderRecord(final byte[] src) { data = new byte[BT_HEADER_RECORD_LENGTH]; System.arraycopy(src, 0, data, 0, BT_HEADER_RECORD_LENGTH); @@ -19,23 +19,23 @@ return BigEndian.getInt16(data, 0); } - public void setTreeDepth(int depth){ + public void setTreeDepth(int depth) { BigEndian.setInt16(data, 0, depth); } - + public final int getRootNode() { return BigEndian.getInt32(data, 2); } - - public void setRootNode(int node){ + + public void setRootNode(int node) { BigEndian.setInt32(data, 2, node); } public final int getLeafRecords() { return BigEndian.getInt32(data, 6); } - - public void setLeafRecords(int count){ + + public void setLeafRecords(int count) { BigEndian.setInt32(data, 6, count); } @@ -43,15 +43,15 @@ return BigEndian.getInt32(data, 10); } - public void settFirstLeafNode(int node){ + public void settFirstLeafNode(int node) { BigEndian.setInt32(data, 10, node); } - + public final int getLastLeafNode() { return BigEndian.getInt32(data, 14); } - - public void setLastLeafNode(int node){ + + public void setLastLeafNode(int node) { BigEndian.setInt32(data, 14, node); } @@ -59,58 +59,58 @@ return BigEndian.getInt16(data, 18); } - public void setNodeSize(int size){ + public void setNodeSize(int size) { BigEndian.setInt16(data, 18, size); } - - public int getMaxKeyLength(){ + + public int getMaxKeyLength() { return BigEndian.getInt16(data, 20); } - - public void setMaxKeyLength(int length){ + + public void setMaxKeyLength(int length) { BigEndian.setInt16(data, 20, length); } - - public int getTotalNodes(){ + + public int getTotalNodes() { return BigEndian.getInt32(data, 22); } - - public void setTotalNodes(int count){ + + public void setTotalNodes(int count) { BigEndian.setInt32(data, 22, count); } - - public int getFreeNodes(){ + + public int getFreeNodes() { return BigEndian.getInt32(data, 26); } - - public void setFreeNodes(int count){ + + public void setFreeNodes(int count) { BigEndian.setInt32(data, 26, count); } - - public int getClumpSize(){ + + public int getClumpSize() { return BigEndian.getInt32(data, 32); } - - public void setClumpSize(int size){ + + public void setClumpSize(int size) { BigEndian.setInt32(data, 32, size); } - - public int getTreeType(){ + + public int getTreeType() { return BigEndian.getInt8(data, 36); } - - public void setTreeType(int type){ + + public void setTreeType(int type) { BigEndian.setInt8(data, 36, type); } - - public int getKeyCompareType(){ + + public int getKeyCompareType() { return BigEndian.getInt8(data, 37); } - - public void setKeyCompareType(int type){ + + public void setKeyCompareType(int type) { BigEndian.setInt8(data, 38, type); } - + public final String toString() { return ("Root node: " + getRootNode() + "\n" + "First leaf: " + getFirstLeafNode() + "\n" + "Last leaf: " + getLastLeafNode() + "\n" + "node size: " + getNodeSize() + "\n"); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/NodeDescriptor.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/NodeDescriptor.java 2009-01-10 07:30:50 UTC (rev 4843) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/NodeDescriptor.java 2009-01-10 11:26:31 UTC (rev 4844) @@ -1,16 +1,15 @@ package org.jnode.fs.hfsplus.tree; -import org.jnode.fs.hfsplus.HfsPlusConstants; import org.jnode.util.BigEndian; public class NodeDescriptor { public static final int BT_NODE_DESCRIPTOR_LENGTH = 14; private byte[] data; - public NodeDescriptor(){ + public NodeDescriptor() { data = new byte[BT_NODE_DESCRIPTOR_LENGTH]; } - + public NodeDescriptor(final byte[] src) { data = new byte[BT_NODE_DESCRIPTOR_LENGTH]; System.arraycopy(src, 0, data, 0, BT_NODE_DESCRIPTOR_LENGTH); @@ -27,8 +26,8 @@ public final int getKind() { return BigEndian.getInt8(data, 8); } - - public void setKind(int kind){ + + public void setKind(int kind) { BigEndian.setInt8(data, 8, kind); } @@ -36,15 +35,15 @@ return BigEndian.getInt8(data, 9); } - public void setHeight(int height){ + public void setHeight(int height) { BigEndian.setInt8(data, 9, height); } - + public final int getNumRecords() { return BigEndian.getInt16(data, 10); } - - public void setRecordCount(int count){ + + public void setRecordCount(int count) { BigEndian.setInt16(data, 10, count); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |