Skip to content

Commit

Permalink
Merge pull request #348 from openpreserve/refact/core-apps-warnings
Browse files Browse the repository at this point in the history
MAINT - Core and apps compiler warnings
  • Loading branch information
carlwilson authored May 21, 2018
2 parents 667fe96 + c630d83 commit 66ec7c6
Show file tree
Hide file tree
Showing 45 changed files with 504 additions and 722 deletions.
1 change: 0 additions & 1 deletion jhove-apps/src/main/java/ADump.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public static void main (String [] args)
FileInputStream file = new FileInputStream (args[0]);
BufferedInputStream buffer = new BufferedInputStream (file);
DataInputStream stream = new DataInputStream (buffer);
ADump dump = new ADump (); // Just to access contained classes
long os = 0;
for (int i=0; i<4; i++) {
int ch;
Expand Down
7 changes: 3 additions & 4 deletions jhove-apps/src/main/java/GDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ public static void main (String [] args)
System.exit (-1);
}

try {
FileInputStream file = new FileInputStream (args[0]);
BufferedInputStream buffer = new BufferedInputStream (file);
DataInputStream stream = new DataInputStream (buffer);
try (FileInputStream file = new FileInputStream (args[0]);
BufferedInputStream buffer = new BufferedInputStream (file);
DataInputStream stream = new DataInputStream (buffer)) {
boolean bigEndian = false;

String signature = readChars (stream, 3);
Expand Down
9 changes: 4 additions & 5 deletions jhove-apps/src/main/java/J2Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public static void main (String [] args)
DataInputStream stream = new DataInputStream (buffer);
J2Dump dump = new J2Dump (); // Just to access contained classes
long os = 0;
boolean bigEndian = true;
int i;
for (i = 0; i < 12; i++) {
int ch;
Expand All @@ -78,7 +77,7 @@ public static void main (String [] args)
os += 12;

boolean endOfFile = false;
Stack boxStack = new Stack ();
Stack<Box> boxStack = new Stack<>();
while (!endOfFile) {
//If there are boxes on the stack, see if there's space
//left in the top one.
Expand All @@ -88,7 +87,7 @@ public static void main (String [] args)
if (boxStack.isEmpty ()) {
break;
}
boxtop = (Box) boxStack.peek ();
boxtop = boxStack.peek ();
if (boxtop.bytesLeft > 0) {
break;
}
Expand Down Expand Up @@ -135,13 +134,13 @@ public static void main (String [] args)


/* Constructs a qualifying prefix to indicate nested boxes. */
private static String stackPrefix (Stack boxStack)
private static String stackPrefix (Stack<Box> boxStack)
{
StringBuffer retval = new StringBuffer ();
// In defiance of gravity, we rummage through the stack
// of boxes starting at the bottom.
for (int i = 0; i < boxStack.size(); i++) {
Box box = (Box) boxStack.elementAt (i);
Box box = boxStack.elementAt (i);
// Remove trailing spaces from types for better readability
retval.append (box.type.trim() + "/");
}
Expand Down
12 changes: 4 additions & 8 deletions jhove-apps/src/main/java/JDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ public static void main (String [] args)
System.exit (-1);
}

try {
FileInputStream file = new FileInputStream (args[0]);
BufferedInputStream buffer = new BufferedInputStream (file);
DataInputStream stream = new DataInputStream (buffer);
try (FileInputStream file = new FileInputStream (args[0]);
BufferedInputStream buffer = new BufferedInputStream (file);
DataInputStream stream = new DataInputStream (buffer)) {
boolean bigEndian = true;

long os = 0;
Expand All @@ -60,9 +59,7 @@ public static void main (String [] args)
if (!readingECS) {
if (!haveCode) {
code = stream.readUnsignedByte ();
for (int i=0;
(code = stream.readUnsignedByte ()) == 0xff;
i++) {
while(stream.readUnsignedByte () == 0xff) {
System.out.println (leading (os, 8) + os +
": fill 0xff");
os++;
Expand Down Expand Up @@ -115,7 +112,6 @@ else if ((code >= 0xc0 && code <= 0xc3) ||
int Nf = stream.readUnsignedByte ();
int [] Ci = new int [Nf];
int [] Hi = new int [Nf];
int [] Vi = new int [Nf];
int [] Tqi = new int [Nf];
for (int i=0; i<Nf; i++) {
Ci[i] = stream.readUnsignedByte ();
Expand Down
2 changes: 1 addition & 1 deletion jhove-apps/src/main/java/Jhove.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ else if (args[i].charAt (0) == '"') {
boolean checksum = false;
boolean showRaw = false;
boolean signature = false;
List<String> list = new ArrayList<String> ();
List<String> list = new ArrayList<> ();


/**********************************************************
Expand Down
34 changes: 15 additions & 19 deletions jhove-apps/src/main/java/TDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TDump
/** Count of IFDs. */
private static int _nIFDs;
/** Sorted associative map of tags. */
private static Map _tags;
private static Map<String, String> _tags;

/******************************************************************
* MAIN ENTRY POINT.
Expand Down Expand Up @@ -70,14 +70,11 @@ else if (tiff == null) {

/* Accumlate all tag definitions in a sorted map. */

_tags = new TreeMap ();
_tags = new TreeMap<> ();

int err = 0;
try {

/* Read TIFF header. */

RandomAccessFile file = new RandomAccessFile (tiff, "r");
try (/* Read TIFF header. */
RandomAccessFile file = new RandomAccessFile (tiff, "r")) {
boolean bigEndian = true;
int b1 = ModuleBase.readUnsignedByte (file);
int b2 = ModuleBase.readUnsignedByte (file);
Expand Down Expand Up @@ -106,10 +103,10 @@ else if (tiff == null) {

/* Display all tags in offset-sorted order. */

Iterator iter = _tags.keySet ().iterator ();
Iterator<String> iter = _tags.keySet ().iterator ();
while (iter.hasNext ()) {
String os = (String) iter.next ();
System.out.println (os + ": " + (String) _tags.get (os));
String os = iter.next ();
System.out.println (os + ": " + _tags.get (os));
}
if (err != 0) {
System.exit (err);
Expand All @@ -131,16 +128,15 @@ private static long readIFD (RandomAccessFile file, boolean bigEndian,
throws Exception
{
int nIFD = ++_nIFDs;
List subIFDs = new ArrayList ();
List stripByteCounts = new ArrayList ();
List stripOffsets = new ArrayList ();
List<Long> subIFDs = new ArrayList<> ();
List<Long> stripByteCounts = new ArrayList<> ();
List<Long> stripOffsets = new ArrayList<> ();

file.seek (offset);
int nEntries = ModuleBase.readUnsignedShort (file, bigEndian);
_tags.put (leading (offset, 8) + offset, "IFD " + nIFD + " with " +
nEntries + " entries");

String name = null;
for (int i=0; i<nEntries; i++) {
long os = offset + 2 + i*12;
file.seek (os);
Expand Down Expand Up @@ -283,10 +279,10 @@ else if (type == IFD.SHORT) {
buffer.append (" " + sh);

if (tag == 273) {
stripOffsets.add (new Long ((long) sh));
stripOffsets.add (new Long (sh));
}
else if (tag == 279) {
stripByteCounts.add (new Long ((long) sh));
stripByteCounts.add (new Long (sh));
}

}
Expand Down Expand Up @@ -333,7 +329,7 @@ else if (type == IFD.SSHORT) {

if (!nosub) {
for (int i=0; i<subIFDs.size (); i++) {
long os = ((Long) subIFDs.get (i)).longValue ();
long os = subIFDs.get (i).longValue ();
while ((os = readIFD (file, bigEndian, os, nobyte, nosub)) > 0) {
}
}
Expand All @@ -347,8 +343,8 @@ else if (type == IFD.SSHORT) {
int len = stripOffsets.size ();
if (len > 0) {
for (int j=0; j<len; j++) {
long start = ((Long) stripOffsets.get (j)).longValue ();
long count = ((Long) stripByteCounts.get (j)).longValue ();
long start = stripOffsets.get (j).longValue ();
long count = stripByteCounts.get (j).longValue ();
long finish= start + count - 1;
_tags.put (leading (start, 8) + start, "(Image " + nIFD +
",strip " + (j+1) + ") IMAGEDATA " + count +
Expand Down
2 changes: 1 addition & 1 deletion jhove-apps/src/main/java/UserHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* USA
**********************************************************************/

import java.io.*;


/**
* Determine the default value of the Java user.home property.
Expand Down
1 change: 0 additions & 1 deletion jhove-apps/src/main/java/WDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public static void main (String [] args)
FileInputStream file = new FileInputStream (args[0]);
BufferedInputStream buffer = new BufferedInputStream (file);
DataInputStream stream = new DataInputStream (buffer);
ADump dump = new ADump (); // Just to access contained classes
long os = 0;
for (int i=0; i<4; i++) {
int ch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void writeFile (List<ModuleInfo> modules,
File homeDir,
File tempDir,
String encoding,
int bufferSize) throws IOException
int bufferSize)
{
writeHead ();

Expand Down Expand Up @@ -159,7 +159,7 @@ public void writeFile (List<ModuleInfo> modules,
}

/* Write the fixed lines which begin the config file */
private void writeHead () throws IOException
private void writeHead ()
{
_confOut.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
_confOut.println("<jhoveConfig version=\"1.0\"");
Expand All @@ -173,7 +173,7 @@ private void writeHead () throws IOException
}

/* Write out the fixed end of the config file */
private void writeTail () throws IOException
private void writeTail ()
{
_confOut.println("</jhoveConfig>");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,15 @@ public DefaultConfigurationBuilder (File location) {


public void writeDefaultConfigFile () throws IOException {
// if (TEMP_DEBUG) {
// String configFileName = "null";
// if (configFile != null)
// configFileName = configFile.getAbsolutePath();
// System.out.println ("writeDefaultConfigFile: path is " + configFileName);
// }
ConfigWriter cw = new ConfigWriter (configFile, null);
List<ModuleInfo> modules = getModules();
// TextHandler, XmlHandler, and AuditHandler are loaded by
// default, so there are no handlers to put in the config file.
List<String[]> handlers = new ArrayList<String[]> ();
List<String[]> handlers = new ArrayList<> ();
File homeDir = new File (JHOVE_DIR);
File tempDir = new File (TEMP_DIR);
try {
cw.writeFile(modules, handlers, homeDir, tempDir,
DEFAULT_ENCODING, DEFAULT_BUFFER_SIZE);
}
catch (IOException e) {
// if (TEMP_DEBUG)
// e.printStackTrace();
throw e;
}
cw.writeFile(modules, handlers, homeDir, tempDir,
DEFAULT_ENCODING, DEFAULT_BUFFER_SIZE);
}

// public void writeDefaultConfigFile () throws IOException {
Expand All @@ -90,7 +77,7 @@ public File getConfigFile () {

protected List<ModuleInfo> getModules () {
int nModules = builtInModules.length;
ArrayList<ModuleInfo> mods = new ArrayList<ModuleInfo> (nModules);
ArrayList<ModuleInfo> mods = new ArrayList<> (nModules);
try {
for (int i = 0; i < nModules; i++) {
Class<?> cls = builtInModules[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public AppInfoWindow (App app, JhoveBase jbase)
super ("Application Info", app, jbase);
setSaveActionListener (
new ActionListener() {
@Override
public void actionPerformed (ActionEvent e) {
saveInfo ();
}
Expand Down Expand Up @@ -86,11 +87,11 @@ private void showApp (App app, JhoveBase jbase)
if (saxClass != null) {
texta.append ("SAX parser: " + saxClass + eol);
}
Iterator iter = jbase.getModuleMap ().keySet ().iterator ();
Iterator<String> iter = jbase.getModuleMap ().keySet ().iterator ();
while (iter.hasNext ()) {
//Module module = jbase.getModuleMap ((String) iter.next ());
Map moduleMap = jbase.getModuleMap ();
Module module = (Module) moduleMap.get ((String) iter.next ());
Map<String, Module> moduleMap = jbase.getModuleMap ();
Module module = moduleMap.get (iter.next ());
texta.append (" Module: " + module.getName () + " " +
module.getRelease () + eol);
}
Expand Down
Loading

0 comments on commit 66ec7c6

Please sign in to comment.