From 1d23aa2699adc469e3df0ce0cb83df863836495b Mon Sep 17 00:00:00 2001 From: amosshi Date: Mon, 9 Sep 2019 22:31:17 -0700 Subject: [PATCH] #4 Checkstyle improvements --- .../biv/plugin/PluginManager.java | 10 +- .../commonlib/core/DataInputEx.java | 12 +- .../commonlib/core/DefaultFileComponent.java | 7 +- .../commonlib/core/PosDataInputStream.java | 213 +++++++++++------- .../format/bmp/BitmapFileHeader.java | 4 +- .../freeinternals/format/bmp/DIBHeader.java | 76 +++---- .../format/dex/PosDataInputStreamDex.java | 12 +- .../freeinternals/format/jpeg/tiff/IFD.java | 2 +- .../format/jpeg/tiff/IFDParse.java | 4 +- .../format/jpeg/tiff/TIFFHeader.java | 4 +- .../format/zip/CentralDirectoryStructure.java | 24 +- .../zip/EndOfCentralDirectoryRecord.java | 14 +- .../format/zip/LocalFileHeader.java | 16 +- pom.xml | 33 +++ 14 files changed, 260 insertions(+), 171 deletions(-) diff --git a/BinaryInternalsViewer/src/main/java/org/freeinternals/biv/plugin/PluginManager.java b/BinaryInternalsViewer/src/main/java/org/freeinternals/biv/plugin/PluginManager.java index af9e9da..461d0c5 100644 --- a/BinaryInternalsViewer/src/main/java/org/freeinternals/biv/plugin/PluginManager.java +++ b/BinaryInternalsViewer/src/main/java/org/freeinternals/biv/plugin/PluginManager.java @@ -55,9 +55,6 @@ private static void loadPlugins() { if (plguinFile.isFile() & plguinFile.getName().toLowerCase().endsWith(".jar")) { try { JarFile jar = new JarFile(plguinFile); - if (jar == null) { - continue; - } Manifest mf = jar.getManifest(); if (mf == null) { @@ -86,20 +83,19 @@ private static void loadPlugin(File pluginFile, String pluginDescClassName) thro if (cls == null) { return; } - PLUGINS.put(pluginFile.getName(), (PluginDescriptor) cls.newInstance()); + PLUGINS.put(pluginFile.getName(), (PluginDescriptor) cls.getDeclaredConstructor().newInstance()); } public static String getPlugedExtensions(){ StringBuilder builder = new StringBuilder(16); if (!PLUGINS.isEmpty()) { builder.append(" - "); - for (PluginDescriptor plugin : PLUGINS.values()) { - String[] exts = plugin.getExtensions(); + PLUGINS.values().stream().map((plugin) -> plugin.getExtensions()).forEachOrdered((exts) -> { for (String ext : exts) { builder.append(ext); builder.append(", "); } - } + }); builder.append(" ..."); } diff --git a/CommonLib/src/main/java/org/freeinternals/commonlib/core/DataInputEx.java b/CommonLib/src/main/java/org/freeinternals/commonlib/core/DataInputEx.java index 58624f9..4b77fdf 100644 --- a/CommonLib/src/main/java/org/freeinternals/commonlib/core/DataInputEx.java +++ b/CommonLib/src/main/java/org/freeinternals/commonlib/core/DataInputEx.java @@ -42,7 +42,7 @@ public interface DataInputEx { * @return the signed 16-bit value read. * @throws IOException I/O Error */ - short readShort_LittleEndian() throws IOException; + short readShortInLittleEndian() throws IOException; /** * Reads two input bytes and returns an int value in the range @@ -56,7 +56,7 @@ public interface DataInputEx { * @return the unsigned 16-bit value read. * @throws IOException I/O Error */ - int readUnsignedShort_LittleEndian() throws IOException; + int readUnsignedShortInLittleEndian() throws IOException; /** * Reads four input bytes and returns an int value. Let @@ -72,7 +72,7 @@ public interface DataInputEx { * @return the int value read. * @exception IOException if an I/O error occurs. */ - int readInt_LittleEndian() throws IOException; + int readIntInLittleEndian() throws IOException; /** * Reads four input bytes as unsigned integer and returns a @@ -90,7 +90,7 @@ public interface DataInputEx { * @return the long value read. * @throws java.io.IOException I/O Error */ - long readUnsignedInt_LittleEndian() throws IOException; + long readUnsignedIntInLittleEndian() throws IOException; /** * Reads eight input bytes and returns a {@code long} value. @@ -98,7 +98,7 @@ public interface DataInputEx { * @return the long value read. * @throws java.io.IOException I/O Error */ - long readLong_LittleEndian() throws IOException; + long readLongInLittleEndian() throws IOException; /** * Reads eight input bytes and returns a {@code unsigned long} value. @@ -114,7 +114,7 @@ public interface DataInputEx { * @return the unsigned long value read * @throws java.io.IOException I/O Error */ - BigInteger readUnsignedLong_LittleEndian() throws IOException; + BigInteger readUnsignedLongInLittleEndian() throws IOException; /** * Reads length input bytes as an ASCII string. diff --git a/CommonLib/src/main/java/org/freeinternals/commonlib/core/DefaultFileComponent.java b/CommonLib/src/main/java/org/freeinternals/commonlib/core/DefaultFileComponent.java index f0aa633..1f1acf2 100644 --- a/CommonLib/src/main/java/org/freeinternals/commonlib/core/DefaultFileComponent.java +++ b/CommonLib/src/main/java/org/freeinternals/commonlib/core/DefaultFileComponent.java @@ -5,6 +5,7 @@ import org.freeinternals.commonlib.ui.JTreeNodeFileComponent; /** + * Default implementation for {@link FileComponent}. * * @author Amos Shi */ @@ -18,7 +19,7 @@ public class DefaultFileComponent extends FileComponent implements GenerateTreeN * @param start Start Position of the File component * @param len Length of the File component */ - public DefaultFileComponent(int start, int len) { + public DefaultFileComponent(final int start, final int len) { super.startPos = start; super.length = len; } @@ -30,13 +31,13 @@ public DefaultFileComponent(int start, int len) { * @param len Length of the File component * @param text Text of the Tree Node */ - public DefaultFileComponent(int start, int len, String text) { + public DefaultFileComponent(final int start, final int len, final String text) { this(start, len); this.treeNodeText = text; } @Override - public void generateTreeNode(DefaultMutableTreeNode parentNode) { + public void generateTreeNode(final DefaultMutableTreeNode parentNode) { parentNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( super.startPos, super.length, diff --git a/CommonLib/src/main/java/org/freeinternals/commonlib/core/PosDataInputStream.java b/CommonLib/src/main/java/org/freeinternals/commonlib/core/PosDataInputStream.java index 5445930..0774a76 100644 --- a/CommonLib/src/main/java/org/freeinternals/commonlib/core/PosDataInputStream.java +++ b/CommonLib/src/main/java/org/freeinternals/commonlib/core/PosDataInputStream.java @@ -15,17 +15,76 @@ * * @author Amos Shi */ -public final class PosDataInputStream extends DataInputStream implements DataInputEx { - +public class PosDataInputStream extends DataInputStream implements DataInputEx { + + /** + * Shift Operators, offset with 8. + */ + private static final int SHIFT_8 = 8; + /** + * Shift Operators, offset with 16. + */ + private static final int SHIFT_16 = 16; + /** + * Shift Operators, offset with 24. + */ + private static final int SHIFT_24 = 24; + /** + * Shift Operators, offset with 32. + */ + private static final int SHIFT_32 = 32; + /** + * Shift Operators, offset with 40. + */ + private static final int SHIFT_40 = 40; + /** + * Shift Operators, offset with 48. + */ + private static final int SHIFT_48 = 48; /** - * Offset of the 1st byte + * Shift Operators, offset with 56. + */ + private static final int SHIFT_56 = 56; + /** + * Half Byte length: 4. + */ + private static final int BYTE_LENGTH_4 = 4; + /** + * Full Byte length: 8. + */ + private static final int BYTE_LENGTH_8 = 8; + + /** Byte offset 0. */ + private static final int BYTE_OFFSET_0 = 0; + /** Byte offset 1. */ + private static final int BYTE_OFFSET_1 = 1; + /** Byte offset 2. */ + private static final int BYTE_OFFSET_2 = 2; + /** Byte offset 3. */ + private static final int BYTE_OFFSET_3 = 3; + /** Byte offset 4. */ + private static final int BYTE_OFFSET_4 = 4; + /** Byte offset 5. */ + private static final int BYTE_OFFSET_5 = 5; + /** Byte offset 6. */ + private static final int BYTE_OFFSET_6 = 6; + /** Byte offset 7. */ + private static final int BYTE_OFFSET_7 = 7; + /** + * Byte max value: 255. + */ + private static final int BYTE_MAX_255 = 255; + + + /** + * Offset of the 1st byte. */ protected int offset = 0; /** - * Creates a new instance of PosDataInputStream + * Creates a new instance of PosDataInputStream. * - * @param in + * @param in Binary data input stream */ public PosDataInputStream(final PosByteArrayInputStream in) { super(in); @@ -35,8 +94,8 @@ public PosDataInputStream(final PosByteArrayInputStream in) { * Create a sub {@link PosDataInputStream}, which starts from * offset. * - * @param in - * @param offset + * @param in Binary data input stream + * @param offset Offset of the stream */ public PosDataInputStream(final PosByteArrayInputStream in, int offset) { super(in); @@ -48,11 +107,11 @@ public PosDataInputStream(final PosByteArrayInputStream in, int offset) { * startPos of original stream, with length * length. * - * @param startPos - * @param length + * @param startPos Start position + * @param length Length * @return A partial {@link PosDataInputStream} object */ - public PosDataInputStream getPartialStream(int startPos, int length) { + public PosDataInputStream getPartialStream(final int startPos, final int length) { return new PosDataInputStream( new PosByteArrayInputStream(this.getBuf(startPos, length)), startPos); @@ -103,7 +162,7 @@ public byte[] getBuf() { * @param length Length of data to be read * @return the partial byte array */ - public byte[] getBuf(int startPos, int length) { + public byte[] getBuf(final int startPos, final int length) { if ((startPos < 0) || (length < 1)) { throw new IllegalArgumentException("startIndex or length is not valid. startIndex = " + startPos + ", length = " + length); } @@ -121,27 +180,27 @@ public byte[] getBuf(int startPos, int length) { /////////////////////////////////////////////////////////////////////////// // Interface Methods @Override - public short readShort_LittleEndian() throws IOException { + public short readShortInLittleEndian() throws IOException { int ch1 = this.in.read(); int ch2 = this.in.read(); if ((ch1 | ch2) < 0) { throw new EOFException(); } - return (short) ((ch2 << 8) + (ch1)); + return (short) ((ch2 << SHIFT_8) + (ch1)); } @Override - public int readUnsignedShort_LittleEndian() throws IOException { + public int readUnsignedShortInLittleEndian() throws IOException { int ch1 = this.in.read(); int ch2 = this.in.read(); if ((ch1 | ch2) < 0) { throw new EOFException(); } - return (ch2 << 8) + (ch1); + return (ch2 << SHIFT_8) + (ch1); } @Override - public int readInt_LittleEndian() throws IOException { + public int readIntInLittleEndian() throws IOException { int ch1 = this.in.read(); int ch2 = this.in.read(); int ch3 = this.in.read(); @@ -149,65 +208,65 @@ public int readInt_LittleEndian() throws IOException { if ((ch1 | ch2 | ch3 | ch4) < 0) { throw new EOFException(); } - return (int) (((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1))); + return (int) (((ch4 << SHIFT_24) + (ch3 << SHIFT_16) + (ch2 << SHIFT_8) + (ch1))); } @Override public long readUnsignedInt() throws IOException { - final byte readBuffer[] = new byte[8]; - - super.readFully(readBuffer, 4, 4); - readBuffer[0] = 0; - readBuffer[1] = 0; - readBuffer[2] = 0; - readBuffer[3] = 0; - - return (((long) readBuffer[0] << 56) - + ((long) (readBuffer[1] & 255) << 48) - + ((long) (readBuffer[2] & 255) << 40) - + ((long) (readBuffer[3] & 255) << 32) - + ((long) (readBuffer[4] & 255) << 24) - + ((readBuffer[5] & 255) << 16) - + ((readBuffer[6] & 255) << 8) - + ((readBuffer[7] & 255))); + final byte readBuffer[] = new byte[BYTE_LENGTH_8]; + + super.readFully(readBuffer, BYTE_LENGTH_4, BYTE_LENGTH_4); + readBuffer[BYTE_OFFSET_0] = 0; + readBuffer[BYTE_OFFSET_1] = 0; + readBuffer[BYTE_OFFSET_2] = 0; + readBuffer[BYTE_OFFSET_3] = 0; + + return (((long) readBuffer[BYTE_OFFSET_0] << SHIFT_56) + + ((long) (readBuffer[BYTE_OFFSET_1] & BYTE_MAX_255) << SHIFT_48) + + ((long) (readBuffer[BYTE_OFFSET_2] & BYTE_MAX_255) << SHIFT_40) + + ((long) (readBuffer[BYTE_OFFSET_3] & BYTE_MAX_255) << SHIFT_32) + + ((long) (readBuffer[BYTE_OFFSET_4] & BYTE_MAX_255) << SHIFT_24) + + ((readBuffer[BYTE_OFFSET_5] & BYTE_MAX_255) << SHIFT_16) + + ((readBuffer[BYTE_OFFSET_6] & BYTE_MAX_255) << SHIFT_8) + + ((readBuffer[BYTE_OFFSET_7] & BYTE_MAX_255))); } @Override - public long readUnsignedInt_LittleEndian() throws IOException { - final byte readBuffer[] = new byte[8]; - - super.readFully(readBuffer, 0, 4); - readBuffer[7] = readBuffer[0]; - readBuffer[6] = readBuffer[1]; - readBuffer[5] = readBuffer[2]; - readBuffer[4] = readBuffer[3]; - readBuffer[0] = 0; - readBuffer[1] = 0; - readBuffer[2] = 0; - readBuffer[3] = 0; - - return (((long) readBuffer[0] << 56) - + ((long) (readBuffer[1] & 255) << 48) - + ((long) (readBuffer[2] & 255) << 40) - + ((long) (readBuffer[3] & 255) << 32) - + ((long) (readBuffer[4] & 255) << 24) - + ((readBuffer[5] & 255) << 16) - + ((readBuffer[6] & 255) << 8) - + ((readBuffer[7] & 255))); + public long readUnsignedIntInLittleEndian() throws IOException { + final byte readBuffer[] = new byte[BYTE_LENGTH_8]; + + super.readFully(readBuffer, 0, BYTE_LENGTH_4); + readBuffer[BYTE_OFFSET_7] = readBuffer[BYTE_OFFSET_0]; + readBuffer[BYTE_OFFSET_6] = readBuffer[BYTE_OFFSET_1]; + readBuffer[BYTE_OFFSET_5] = readBuffer[BYTE_OFFSET_2]; + readBuffer[BYTE_OFFSET_4] = readBuffer[BYTE_OFFSET_3]; + readBuffer[BYTE_OFFSET_0] = 0; + readBuffer[BYTE_OFFSET_1] = 0; + readBuffer[BYTE_OFFSET_2] = 0; + readBuffer[BYTE_OFFSET_3] = 0; + + return (((long) readBuffer[BYTE_OFFSET_0] << SHIFT_56) + + ((long) (readBuffer[BYTE_OFFSET_1] & BYTE_MAX_255) << SHIFT_48) + + ((long) (readBuffer[BYTE_OFFSET_2] & BYTE_MAX_255) << SHIFT_40) + + ((long) (readBuffer[BYTE_OFFSET_3] & BYTE_MAX_255) << SHIFT_32) + + ((long) (readBuffer[BYTE_OFFSET_4] & BYTE_MAX_255) << SHIFT_24) + + ((readBuffer[BYTE_OFFSET_5] & BYTE_MAX_255) << SHIFT_16) + + ((readBuffer[BYTE_OFFSET_6] & BYTE_MAX_255) << SHIFT_8) + + ((readBuffer[BYTE_OFFSET_7] & BYTE_MAX_255))); } @Override - public long readLong_LittleEndian() throws IOException { - final byte readBuffer[] = new byte[8]; + public long readLongInLittleEndian() throws IOException { + final byte readBuffer[] = new byte[BYTE_LENGTH_8]; super.readFully(readBuffer, 0, 8); - return (((long) readBuffer[7] << 56) - + ((long) (readBuffer[6] & 255) << 48) - + ((long) (readBuffer[5] & 255) << 40) - + ((long) (readBuffer[4] & 255) << 32) - + ((long) (readBuffer[3] & 255) << 24) - + ((readBuffer[2] & 255) << 16) - + ((readBuffer[1] & 255) << 8) - + ((readBuffer[0] & 255))); + return (((long) readBuffer[BYTE_OFFSET_7] << SHIFT_56) + + ((long) (readBuffer[BYTE_OFFSET_6] & BYTE_MAX_255) << SHIFT_48) + + ((long) (readBuffer[BYTE_OFFSET_5] & BYTE_MAX_255) << SHIFT_40) + + ((long) (readBuffer[BYTE_OFFSET_4] & BYTE_MAX_255) << SHIFT_32) + + ((long) (readBuffer[BYTE_OFFSET_3] & BYTE_MAX_255) << SHIFT_24) + + ((readBuffer[BYTE_OFFSET_2] & BYTE_MAX_255) << SHIFT_16) + + ((readBuffer[BYTE_OFFSET_1] & BYTE_MAX_255) << SHIFT_8) + + ((readBuffer[BYTE_OFFSET_0] & BYTE_MAX_255))); } /** @@ -217,18 +276,18 @@ public long readLong_LittleEndian() throws IOException { */ @Override public BigInteger readUnsignedLong() throws IOException { - final byte readBuffer[] = new byte[8]; - super.readFully(readBuffer, 0, 8); + final byte readBuffer[] = new byte[BYTE_LENGTH_8]; + super.readFully(readBuffer, 0, BYTE_LENGTH_8); return new BigInteger(1, readBuffer); } @Override - public BigInteger readUnsignedLong_LittleEndian() throws IOException { - final byte readBuffer[] = new byte[8]; - final byte readBufferLE[] = new byte[8]; - super.readFully(readBuffer, 0, 8); - for (int i = 0; i < 8; i++) { - readBufferLE[i] = readBuffer[7 - i]; + public BigInteger readUnsignedLongInLittleEndian() throws IOException { + final byte readBuffer[] = new byte[BYTE_LENGTH_8]; + final byte readBufferLE[] = new byte[BYTE_LENGTH_8]; + super.readFully(readBuffer, 0, BYTE_LENGTH_8); + for (int i = 0; i < BYTE_LENGTH_8; i++) { + readBufferLE[i] = readBuffer[BYTE_LENGTH_8 - 1 - i]; } return new BigInteger(1, readBufferLE); @@ -263,7 +322,7 @@ public String readASCII() throws IOException { @Override public String readASCIIUntil(final byte end) throws IOException { byte b; - StringBuilder sb = new StringBuilder(100); + StringBuilder sb = new StringBuilder(); do { try { @@ -284,9 +343,9 @@ public String readASCIIUntil(final byte end) throws IOException { * Read current byte array as ASCII string until any byte in * array end. * - * @param end - * @return - * @throws java.io.IOException + * @param end End value for the ASCII string + * @return ASCII as string + * @throws java.io.IOException Read failed */ public String readASCIIUntil(byte... end) throws IOException { if (end == null || end.length < 1) { @@ -315,7 +374,7 @@ public String readASCIIUntil(byte... end) throws IOException { * Read current byte array as ASCII string until a {@link NEWLINE} flag * found. * - * @return + * @return * @throws java.io.IOException */ public ASCIILine readASCIILine() throws IOException { diff --git a/FormatBMP/src/main/java/org/freeinternals/format/bmp/BitmapFileHeader.java b/FormatBMP/src/main/java/org/freeinternals/format/bmp/BitmapFileHeader.java index b82a88f..9be4e34 100644 --- a/FormatBMP/src/main/java/org/freeinternals/format/bmp/BitmapFileHeader.java +++ b/FormatBMP/src/main/java/org/freeinternals/format/bmp/BitmapFileHeader.java @@ -50,10 +50,10 @@ public class BitmapFileHeader extends FileComponent implements GenerateTreeNode this.length = LENGTH; this.magic = input.readASCII(2); - this.fileSize = input.readUnsignedInt_LittleEndian(); + this.fileSize = input.readUnsignedIntInLittleEndian(); input.readFully(this.creator1); input.readFully(this.creator2); - this.offset = input.readUnsignedInt_LittleEndian(); + this.offset = input.readUnsignedIntInLittleEndian(); if (this.fileSize != input.getBuf().length) { // File size exception diff --git a/FormatBMP/src/main/java/org/freeinternals/format/bmp/DIBHeader.java b/FormatBMP/src/main/java/org/freeinternals/format/bmp/DIBHeader.java index b9c52d6..3b6dd7d 100644 --- a/FormatBMP/src/main/java/org/freeinternals/format/bmp/DIBHeader.java +++ b/FormatBMP/src/main/java/org/freeinternals/format/bmp/DIBHeader.java @@ -26,7 +26,7 @@ public class DIBHeader extends FileComponent implements GenerateTreeNode { DIBHeader(final PosDataInputStream input) throws IOException { this.startPos = input.getPos(); - this.size = input.readInt_LittleEndian(); + this.size = input.readIntInLittleEndian(); this.length = this.size; switch (this.size) { case 12: @@ -169,10 +169,10 @@ public class BITMAPCOREHEADER extends FileComponent implements GenerateTreeNode this.startPos = input.getPos() - 4; this.length = SIZE; - this.Width = input.readUnsignedShort_LittleEndian(); - this.Height = input.readUnsignedShort_LittleEndian(); - this.Planes = input.readUnsignedShort_LittleEndian(); - this.BitCount = input.readUnsignedShort_LittleEndian(); + this.Width = input.readUnsignedShortInLittleEndian(); + this.Height = input.readUnsignedShortInLittleEndian(); + this.Planes = input.readUnsignedShortInLittleEndian(); + this.BitCount = input.readUnsignedShortInLittleEndian(); } public void generateTreeNode(DefaultMutableTreeNode node) { @@ -248,16 +248,16 @@ public class BITMAPINFOHEADER extends FileComponent implements GenerateTreeNode this.startPos = input.getPos() - 4; this.length = SIZE; - this.Width = input.readInt_LittleEndian(); - this.Height = input.readInt_LittleEndian(); - this.Planes = input.readUnsignedShort_LittleEndian(); - this.BitCount = input.readUnsignedShort_LittleEndian(); - this.Compression = input.readInt_LittleEndian(); - this.SizeImage = input.readUnsignedInt_LittleEndian(); - this.XPelsPerMeter = input.readInt_LittleEndian(); - this.YPelsPerMeter = input.readInt_LittleEndian(); - this.ColorsUsed = input.readUnsignedInt_LittleEndian(); - this.ColorsImportant = input.readUnsignedInt_LittleEndian(); + this.Width = input.readIntInLittleEndian(); + this.Height = input.readIntInLittleEndian(); + this.Planes = input.readUnsignedShortInLittleEndian(); + this.BitCount = input.readUnsignedShortInLittleEndian(); + this.Compression = input.readIntInLittleEndian(); + this.SizeImage = input.readUnsignedIntInLittleEndian(); + this.XPelsPerMeter = input.readIntInLittleEndian(); + this.YPelsPerMeter = input.readIntInLittleEndian(); + this.ColorsUsed = input.readUnsignedIntInLittleEndian(); + this.ColorsImportant = input.readUnsignedIntInLittleEndian(); } public void generateTreeNode(DefaultMutableTreeNode node) { @@ -415,14 +415,14 @@ public class BITMAPCOREHEADER2 extends BITMAPINFOHEADER { super(input); this.length = BITMAPCOREHEADER2.SIZE; - this.ResUnit = input.readUnsignedShort_LittleEndian(); - this.Reserved = input.readUnsignedShort_LittleEndian(); - this.Orientation = input.readUnsignedShort_LittleEndian(); - this.Halftoning = input.readUnsignedShort_LittleEndian(); - this.HalftoneSize1 = input.readUnsignedInt_LittleEndian(); - this.HalftoneSize2 = input.readUnsignedInt_LittleEndian(); - this.ColorSpace = input.readUnsignedInt_LittleEndian(); - this.AppData = input.readUnsignedInt_LittleEndian(); + this.ResUnit = input.readUnsignedShortInLittleEndian(); + this.Reserved = input.readUnsignedShortInLittleEndian(); + this.Orientation = input.readUnsignedShortInLittleEndian(); + this.Halftoning = input.readUnsignedShortInLittleEndian(); + this.HalftoneSize1 = input.readUnsignedIntInLittleEndian(); + this.HalftoneSize2 = input.readUnsignedIntInLittleEndian(); + this.ColorSpace = input.readUnsignedIntInLittleEndian(); + this.AppData = input.readUnsignedIntInLittleEndian(); } @Override @@ -520,15 +520,15 @@ public class BITMAPV4HEADER extends BITMAPINFOHEADER { super(input); this.length = BITMAPV4HEADER.SIZE; - this.RedMask = input.readUnsignedInt_LittleEndian(); - this.GreenMask = input.readUnsignedInt_LittleEndian(); - this.BlueMask = input.readUnsignedInt_LittleEndian(); - this.AlphaMask = input.readUnsignedInt_LittleEndian(); - this.ColorSpaceType = input.readInt_LittleEndian(); + this.RedMask = input.readUnsignedIntInLittleEndian(); + this.GreenMask = input.readUnsignedIntInLittleEndian(); + this.BlueMask = input.readUnsignedIntInLittleEndian(); + this.AlphaMask = input.readUnsignedIntInLittleEndian(); + this.ColorSpaceType = input.readIntInLittleEndian(); this.Endpoints = new CIEXYZTRIPLE(input); - this.GammaRed = input.readUnsignedInt_LittleEndian(); - this.GammaGreen = input.readUnsignedInt_LittleEndian(); - this.GammaBlue = input.readUnsignedInt_LittleEndian(); + this.GammaRed = input.readUnsignedIntInLittleEndian(); + this.GammaGreen = input.readUnsignedIntInLittleEndian(); + this.GammaBlue = input.readUnsignedIntInLittleEndian(); } /** @@ -627,10 +627,10 @@ public class BITMAPV5HEADER extends BITMAPV4HEADER { super(input); this.length = SIZE; - this.Intent = input.readUnsignedInt_LittleEndian(); - this.ICCProfileData = input.readUnsignedInt_LittleEndian(); - this.ICCProfileSize = input.readUnsignedInt_LittleEndian(); - this.Reserved = input.readUnsignedInt_LittleEndian(); + this.Intent = input.readUnsignedIntInLittleEndian(); + this.ICCProfileData = input.readUnsignedIntInLittleEndian(); + this.ICCProfileSize = input.readUnsignedIntInLittleEndian(); + this.Reserved = input.readUnsignedIntInLittleEndian(); } @Override @@ -683,9 +683,9 @@ public class CIEXYZ { public final long z; CIEXYZ(final PosDataInputStream input) throws IOException { - this.x = input.readUnsignedInt_LittleEndian(); - this.y = input.readUnsignedInt_LittleEndian(); - this.z = input.readUnsignedInt_LittleEndian(); + this.x = input.readUnsignedIntInLittleEndian(); + this.y = input.readUnsignedIntInLittleEndian(); + this.z = input.readUnsignedIntInLittleEndian(); } } diff --git a/FormatDEX/src/main/java/org/freeinternals/format/dex/PosDataInputStreamDex.java b/FormatDEX/src/main/java/org/freeinternals/format/dex/PosDataInputStreamDex.java index ff8240a..80423e5 100644 --- a/FormatDEX/src/main/java/org/freeinternals/format/dex/PosDataInputStreamDex.java +++ b/FormatDEX/src/main/java/org/freeinternals/format/dex/PosDataInputStreamDex.java @@ -65,7 +65,7 @@ public Dex_short Dex_short() throws IOException { if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) { return new Dex_short(this.readShort()); } else { - return new Dex_short(this.readShort_LittleEndian()); + return new Dex_short(this.readShortInLittleEndian()); } } @@ -79,7 +79,7 @@ public Dex_ushort Dex_ushort() throws IOException { if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) { return new Dex_ushort(this.readUnsignedShort()); } else { - return new Dex_ushort(this.readUnsignedShort_LittleEndian()); + return new Dex_ushort(this.readUnsignedShortInLittleEndian()); } } @@ -93,7 +93,7 @@ public Dex_int Dex_int() throws IOException { if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) { return new Dex_int(this.readInt()); } else { - return new Dex_int(this.readInt_LittleEndian()); + return new Dex_int(this.readIntInLittleEndian()); } } @@ -107,7 +107,7 @@ public Dex_uint Dex_uint() throws IOException { if (this.endian.value == HeaderItem.Endian.ENDIAN_CONSTANT.value) { return new Dex_uint(this.readUnsignedInt()); } else { - return new Dex_uint(this.readUnsignedInt_LittleEndian()); + return new Dex_uint(this.readUnsignedIntInLittleEndian()); } } @@ -121,7 +121,7 @@ public Dex_long Dex_long() throws IOException { if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) { return new Dex_long(this.readLong()); } else { - return new Dex_long(this.readLong_LittleEndian()); + return new Dex_long(this.readLongInLittleEndian()); } } @@ -135,7 +135,7 @@ public Dex_ulong Dex_ulong() throws IOException { if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) { return new Dex_ulong(this.readUnsignedLong()); } else { - return new Dex_ulong(this.readUnsignedLong_LittleEndian()); + return new Dex_ulong(this.readUnsignedLongInLittleEndian()); } } diff --git a/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFD.java b/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFD.java index 0f9ff49..4877bdc 100644 --- a/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFD.java +++ b/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFD.java @@ -145,7 +145,7 @@ protected final long readUnsignedInt(final PosDataInputStream pDIS) throws IOExc if (this.byte_order == TIFFHeader.BYTEORDER_BIGENDIAN) { return pDIS.readUnsignedInt(); } else { - return pDIS.readUnsignedInt_LittleEndian(); + return pDIS.readUnsignedIntInLittleEndian(); } } diff --git a/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFDParse.java b/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFDParse.java index 08339fe..4170ba1 100644 --- a/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFDParse.java +++ b/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/IFDParse.java @@ -226,7 +226,7 @@ public static int readUnsignedShort(final PosDataInputStream pDIS, int byteOrder if (byteOrder == TIFFHeader.BYTEORDER_BIGENDIAN) { return pDIS.readUnsignedShort(); } else { - return pDIS.readUnsignedShort_LittleEndian(); + return pDIS.readUnsignedShortInLittleEndian(); } } @@ -234,7 +234,7 @@ public static int readInt(final PosDataInputStream pDIS, int byteOrder) throws I if (byteOrder == TIFFHeader.BYTEORDER_BIGENDIAN) { return pDIS.readInt(); } else { - return pDIS.readInt_LittleEndian(); + return pDIS.readIntInLittleEndian(); } } } diff --git a/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/TIFFHeader.java b/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/TIFFHeader.java index 45016f2..ff9a082 100644 --- a/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/TIFFHeader.java +++ b/FormatJPEG/src/main/java/org/freeinternals/format/jpeg/tiff/TIFFHeader.java @@ -41,8 +41,8 @@ public TIFFHeader(final PosDataInputStream pDisMarker) this.arbitray_number = pDisMarker.readUnsignedShort(); this.offset_0ifd = pDisMarker.readInt(); } else if (this.byte_order == TIFFHeader.BYTEORDER_LITTLEENDIAN) { - this.arbitray_number = pDisMarker.readUnsignedShort_LittleEndian(); - this.offset_0ifd = pDisMarker.readInt_LittleEndian(); + this.arbitray_number = pDisMarker.readUnsignedShortInLittleEndian(); + this.offset_0ifd = pDisMarker.readIntInLittleEndian(); } else { throw new FileFormatException(String.format("Marker APP01: Un-recognized TIFF header byte order value: expected value is %x or %s, current value is %x.", TIFFHeader.BYTEORDER_BIGENDIAN, TIFFHeader.BYTEORDER_LITTLEENDIAN, this.byte_order)); } diff --git a/FormatZIP/src/main/java/org/freeinternals/format/zip/CentralDirectoryStructure.java b/FormatZIP/src/main/java/org/freeinternals/format/zip/CentralDirectoryStructure.java index 6db967c..82b5cee 100644 --- a/FormatZIP/src/main/java/org/freeinternals/format/zip/CentralDirectoryStructure.java +++ b/FormatZIP/src/main/java/org/freeinternals/format/zip/CentralDirectoryStructure.java @@ -118,24 +118,24 @@ public class FileHeader { if (BytesTool.isByteArraySame(this.Signature, ZIPFile.CENTRAL_FILE_HEADER) == false) { throw new FileFormatException("Signature does not match for 'central file header signature'."); } - this.VersionMadeBy = stream.readUnsignedShort_LittleEndian(); - this.VersionNeededToExtract = stream.readUnsignedShort_LittleEndian(); + this.VersionMadeBy = stream.readUnsignedShortInLittleEndian(); + this.VersionNeededToExtract = stream.readUnsignedShortInLittleEndian(); stream.read(this.GeneralPurposeBitFlag); - this.CompressionMethod = stream.readUnsignedShort_LittleEndian(); - this.LastModFileTime = stream.readUnsignedShort_LittleEndian(); + this.CompressionMethod = stream.readUnsignedShortInLittleEndian(); + this.LastModFileTime = stream.readUnsignedShortInLittleEndian(); this.LastModFileTimeValue = new MSDosTime(this.LastModFileTime); - this.LastModFileDate = stream.readUnsignedShort_LittleEndian(); + this.LastModFileDate = stream.readUnsignedShortInLittleEndian(); this.LastModFileDateValue = new MSDosDate(this.LastModFileDate); stream.read(this.CRC32); - this.CompressedSize = stream.readUnsignedInt_LittleEndian(); - this.UncompressedSize = stream.readUnsignedInt_LittleEndian(); - this.FileNameLength = stream.readUnsignedShort_LittleEndian(); - this.ExtraFieldLength = stream.readUnsignedShort_LittleEndian(); - this.FileCommentLength = stream.readUnsignedShort_LittleEndian(); - this.DiskNumberStart = stream.readUnsignedShort_LittleEndian(); + this.CompressedSize = stream.readUnsignedIntInLittleEndian(); + this.UncompressedSize = stream.readUnsignedIntInLittleEndian(); + this.FileNameLength = stream.readUnsignedShortInLittleEndian(); + this.ExtraFieldLength = stream.readUnsignedShortInLittleEndian(); + this.FileCommentLength = stream.readUnsignedShortInLittleEndian(); + this.DiskNumberStart = stream.readUnsignedShortInLittleEndian(); stream.read(this.InternalFileAttributes); stream.read(this.ExternalFileAttributes); - this.RelativeOffsetOfLocalHeader = stream.readUnsignedInt_LittleEndian(); + this.RelativeOffsetOfLocalHeader = stream.readUnsignedIntInLittleEndian(); if (this.FileNameLength > 0) { this.FileName = new byte[this.FileNameLength]; stream.read(this.FileName); diff --git a/FormatZIP/src/main/java/org/freeinternals/format/zip/EndOfCentralDirectoryRecord.java b/FormatZIP/src/main/java/org/freeinternals/format/zip/EndOfCentralDirectoryRecord.java index a3f75b5..2c81a13 100644 --- a/FormatZIP/src/main/java/org/freeinternals/format/zip/EndOfCentralDirectoryRecord.java +++ b/FormatZIP/src/main/java/org/freeinternals/format/zip/EndOfCentralDirectoryRecord.java @@ -56,13 +56,13 @@ public class EndOfCentralDirectoryRecord extends FileComponent { if (BytesTool.isByteArraySame(this.Signature, ZIPFile.CENTRAL_END) == false) { throw new FileFormatException("Signature does not match for 'end of central directory signature'."); } - this.DiskNumber = stream.readUnsignedShort_LittleEndian(); - this.DiskNumberWithSCD = stream.readUnsignedShort_LittleEndian(); - this.EntryTotalNumberDisk = stream.readUnsignedShort_LittleEndian(); - this.EntryTotalNumber = stream.readUnsignedShort_LittleEndian(); - this.CentralDirectorySize = stream.readUnsignedInt_LittleEndian(); - this.CentralDirectoryOffset = stream.readUnsignedInt_LittleEndian(); - this.ZipFileCommentLength = stream.readUnsignedShort_LittleEndian(); + this.DiskNumber = stream.readUnsignedShortInLittleEndian(); + this.DiskNumberWithSCD = stream.readUnsignedShortInLittleEndian(); + this.EntryTotalNumberDisk = stream.readUnsignedShortInLittleEndian(); + this.EntryTotalNumber = stream.readUnsignedShortInLittleEndian(); + this.CentralDirectorySize = stream.readUnsignedIntInLittleEndian(); + this.CentralDirectoryOffset = stream.readUnsignedIntInLittleEndian(); + this.ZipFileCommentLength = stream.readUnsignedShortInLittleEndian(); if (this.ZipFileCommentLength > 0) { this.ZipFileComment = new byte[this.ZipFileCommentLength]; stream.read(this.ZipFileComment); diff --git a/FormatZIP/src/main/java/org/freeinternals/format/zip/LocalFileHeader.java b/FormatZIP/src/main/java/org/freeinternals/format/zip/LocalFileHeader.java index 76313fb..a305de4 100644 --- a/FormatZIP/src/main/java/org/freeinternals/format/zip/LocalFileHeader.java +++ b/FormatZIP/src/main/java/org/freeinternals/format/zip/LocalFileHeader.java @@ -88,18 +88,18 @@ public class LocalFileHeader extends FileComponent { if (BytesTool.isByteArraySame(this.Signature, ZIPFile.LOCAL_FILE_HEADER) == false) { throw new FileFormatException("Signature does not match for 'local file header signature'."); } - this.VersionNeededToExtract = stream.readUnsignedShort_LittleEndian(); + this.VersionNeededToExtract = stream.readUnsignedShortInLittleEndian(); stream.read(this.GeneralPurposeBitFlag); - this.CompressionMethod = stream.readUnsignedShort_LittleEndian(); - this.LastModFileTime = stream.readUnsignedShort_LittleEndian(); + this.CompressionMethod = stream.readUnsignedShortInLittleEndian(); + this.LastModFileTime = stream.readUnsignedShortInLittleEndian(); this.LastModFileTimeValue = new MSDosTime(this.LastModFileTime); - this.LastModFileDate = stream.readUnsignedShort_LittleEndian(); + this.LastModFileDate = stream.readUnsignedShortInLittleEndian(); this.LastModFileDateValue = new MSDosDate(this.LastModFileDate); stream.read(this.CRC32); - this.CompressedSize = stream.readUnsignedInt_LittleEndian(); - this.UncompressedSize = stream.readUnsignedInt_LittleEndian(); - this.FileNameLength = stream.readUnsignedShort_LittleEndian(); - this.ExtraFieldLength = stream.readUnsignedShort_LittleEndian(); + this.CompressedSize = stream.readUnsignedIntInLittleEndian(); + this.UncompressedSize = stream.readUnsignedIntInLittleEndian(); + this.FileNameLength = stream.readUnsignedShortInLittleEndian(); + this.ExtraFieldLength = stream.readUnsignedShortInLittleEndian(); if (this.FileNameLength > 0) { this.FileName = new byte[this.FileNameLength]; stream.read(this.FileName); diff --git a/pom.xml b/pom.xml index 75ae567..9b64d1c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,39 @@ + + + + + org.apache.maven.plugins