@Override, generics and unused imports

This commit is contained in:
Charlie Groves
2009-08-17 20:13:31 +00:00
parent a31171c575
commit 31cace3107
17 changed files with 69 additions and 54 deletions
@@ -23,12 +23,6 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.threerings.getdown.data;
import java.io.FileInputStream;
import com.samskivert.io.StreamUtil;
import static com.threerings.getdown.Log.log;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.BufferedReader;
@@ -81,6 +75,8 @@ import com.threerings.getdown.util.LaunchUtil;
import com.threerings.getdown.util.MetaProgressObserver;
import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log;
/**
* Parses and provide access to the information contained in the <code>getdown.txt</code>
* configuration file.
@@ -140,6 +136,7 @@ public class Application
public String installError;
/** Generates a string representation of this instance. */
@Override
public String toString ()
{
return "[name=" + name + ", bg=" + backgroundImage + ", pi=" + progressImage +
@@ -750,7 +747,7 @@ public class Application
}
// pass along any pass-through arguments
for (Map.Entry entry : System.getProperties().entrySet()) {
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
String key = (String)entry.getKey();
if (key.startsWith(PROP_PASSTHROUGH_PREFIX)) {
key = key.substring(PROP_PASSTHROUGH_PREFIX.length());
@@ -834,7 +831,7 @@ public class Application
URLClassLoader loader = new URLClassLoader(
jars.toArray(new URL[jars.size()]),
ClassLoader.getSystemClassLoader()) {
protected PermissionCollection getPermissions (CodeSource code) {
@Override protected PermissionCollection getPermissions (CodeSource code) {
Permissions perms = new Permissions();
perms.add(new AllPermission());
return perms;
@@ -856,7 +853,7 @@ public class Application
// pass along any pass-through arguments
Map<String, String> passProps = new HashMap<String, String>();
for (Map.Entry entry : System.getProperties().entrySet()) {
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
String key = (String)entry.getKey();
if (key.startsWith(PROP_PASSTHROUGH_PREFIX)) {
key = key.substring(PROP_PASSTHROUGH_PREFIX.length());
@@ -6,13 +6,13 @@
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
@@ -33,7 +33,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import com.samskivert.text.MessageUtil;
@@ -63,9 +62,7 @@ public class Digest
// parse and validate our digest file contents
StringBuilder data = new StringBuilder();
File dfile = new File(appdir, DIGEST_FILE);
List pairs = ConfigUtil.parsePairs(dfile, false);
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
String[] pair = (String[])iter.next();
for (String[] pair : ConfigUtil.parsePairs(dfile, false)) {
if (pair[0].equals(DIGEST_FILE)) {
_metaDigest = pair[1];
break;
@@ -132,8 +129,7 @@ public class Digest
new OutputStreamWriter(new FileOutputStream(output), "UTF-8"));
// compute and append the MD5 digest of each resource in the list
for (Iterator<Resource> iter = resources.iterator(); iter.hasNext();) {
Resource rsrc = iter.next();
for (Resource rsrc : resources) {
String path = rsrc.getPath();
try {
String digest = rsrc.computeDigest(md, null);
@@ -6,13 +6,13 @@
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
@@ -32,7 +32,6 @@ import java.net.URL;
import java.security.MessageDigest;
import java.util.Comparator;
import java.util.Iterator;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -180,6 +179,7 @@ public class Resource
/**
* If our path is equal, we are equal.
*/
@Override
public boolean equals (Object other)
{
if (other instanceof Resource) {
@@ -192,6 +192,7 @@ public class Resource
/**
* We hash on our path.
*/
@Override
public int hashCode ()
{
return _path.hashCode();
@@ -200,6 +201,7 @@ public class Resource
/**
* Returns a string representation of this instance.
*/
@Override
public String toString ()
{
return _path;
@@ -228,9 +230,7 @@ public class Resource
entries.sort(ENTRY_COMP);
int eidx = 0;
for (Iterator iter = entries.iterator(); iter.hasNext(); ) {
JarEntry entry = (JarEntry)iter.next();
for (JarEntry entry : entries) {
// skip metadata; we just want the goods
if (entry.getName().startsWith("META-INF")) {
updateProgress(obs, eidx, entries.size());
@@ -76,6 +76,7 @@ public class AbortPanel extends JFrame
}
// documentation inherited
@Override
public Dimension getPreferredSize ()
{
// this is annoyingly hardcoded, but we can't just force the width
@@ -139,6 +139,7 @@ public abstract class Getdown extends Thread
}
}
@Override
public void run ()
{
// if we have no messages, just bail because we're hosed; the error message will be
@@ -245,7 +246,7 @@ public abstract class Getdown extends Thread
boolean enabled = false;
RegistryKey.initialize();
RegistryKey r = new RegistryKey(RootKey.HKEY_CURRENT_USER, PROXY_REGISTRY);
for (Iterator iter = r.values(); iter.hasNext(); ) {
for (Iterator<?> iter = r.values(); iter.hasNext(); ) {
RegistryValue value = (RegistryValue)iter.next();
if (value.getName().equals("ProxyEnable")) {
enabled = value.getStringValue().equals("1");
@@ -277,7 +278,7 @@ public abstract class Getdown extends Thread
File pfile = _app.getLocalPath("proxy.txt");
if (pfile.exists()) {
try {
HashMap pconf = ConfigUtil.parseConfig(pfile, false);
HashMap<String, Object> pconf = ConfigUtil.parseConfig(pfile, false);
setProxyProperties((String)pconf.get("host"), (String)pconf.get("port"));
return true;
} catch (IOException ioe) {
@@ -744,7 +745,7 @@ public abstract class Getdown extends Thread
// spawn a daemon thread that will catch the early bits of stderr in case the
// launch fails
Thread t = new Thread() {
public void run () {
@Override public void run () {
copyStream(stderr, System.err);
}
};
@@ -971,6 +972,7 @@ public abstract class Getdown extends Thread
_url = url;
}
@Override
public void run () {
try {
HttpURLConnection ucon = (HttpURLConnection)_url.openConnection();
@@ -27,6 +27,7 @@ import java.awt.Container;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.io.File;
import java.io.FileOutputStream;
@@ -99,6 +100,7 @@ public class GetdownApp
try {
Getdown app = new Getdown(appDir, appId) {
@Override
protected Container createContainer () {
// create our user interface, and display it
String title =
@@ -106,6 +108,7 @@ public class GetdownApp
if (_frame == null) {
_frame = new JFrame(title);
_frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing (WindowEvent evt) {
handleWindowClose();
}
@@ -115,9 +118,10 @@ public class GetdownApp
_frame.setTitle(title);
_frame.getContentPane().removeAll();
}
_frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
return _frame.getContentPane();
}
@Override
protected void showContainer () {
if (_frame != null) {
_frame.pack();
@@ -125,12 +129,14 @@ public class GetdownApp
_frame.setVisible(true);
}
}
@Override
protected void disposeContainer () {
if (_frame != null) {
_frame.dispose();
_frame = null;
}
}
@Override
protected void exit (int exitCode) {
System.exit(exitCode);
}
@@ -61,25 +61,32 @@ public class GetdownApplet extends JApplet
// statically included trusted keys.
_getdown = new Getdown(_config.appdir, null, GetdownApplet.class.getSigners(),
_config.jvmargs) {
@Override
protected Container createContainer () {
getContentPane().removeAll();
return getContentPane();
}
@Override
protected RotatingBackgrounds getBackground () {
return _config.getBackgroundImages(GetdownApplet.this);
}
@Override
protected void showContainer () {
((JPanel)getContentPane()).revalidate();
}
@Override
protected void disposeContainer () {
// nothing to do as we're in an applet
}
@Override
protected boolean invokeDirect () {
return _config.invokeDirect;
}
@Override
protected JApplet getApplet () {
return GetdownApplet.this;
}
@Override
protected void exit (int exitCode) {
_app.releaseLock();
_config.redirect();
@@ -96,6 +96,7 @@ public class ProxyPanel extends JPanel
}
// documentation inherited
@Override
public void addNotify ()
{
super.addNotify();
@@ -103,6 +104,7 @@ public class ProxyPanel extends JPanel
}
// documentation inherited
@Override
public Dimension getPreferredSize ()
{
// this is annoyingly hardcoded, but we can't just force the width
@@ -144,6 +146,7 @@ public class ProxyPanel extends JPanel
protected static class SaneTextField extends JTextField
{
@Override
public Dimension getPreferredSize () {
Dimension d = super.getPreferredSize();
d.width = Math.max(d.width, 150);
@@ -36,6 +36,7 @@ import java.util.ResourceBundle;
import javax.swing.JComponent;
import com.samskivert.swing.Label;
import com.samskivert.swing.LabelStyleConstants;
import com.samskivert.swing.util.SwingUtil;
import com.samskivert.text.MessageUtil;
import com.samskivert.util.StringUtil;
@@ -110,7 +111,7 @@ public class StatusPanel extends JComponent
_newplab = new Label(label, _ifc.progressText, _font);
if (_ifc.textShadow != null) {
_newplab.setAlternateColor(_ifc.textShadow);
_newplab.setStyle(Label.SHADOW);
_newplab.setStyle(LabelStyleConstants.SHADOW);
}
repaint();
}
@@ -128,12 +129,13 @@ public class StatusPanel extends JComponent
_newlab.setTargetWidth(width);
if (_ifc.textShadow != null) {
_newlab.setAlternateColor(_ifc.textShadow);
_newlab.setStyle(Label.SHADOW);
_newlab.setStyle(LabelStyleConstants.SHADOW);
}
repaint();
}
// documentation inherited
@Override
public void paintComponent (Graphics g)
{
super.paintComponent(g);
@@ -204,6 +206,7 @@ public class StatusPanel extends JComponent
}
// documentation inherited
@Override
public Dimension getPreferredSize ()
{
return _psize;
@@ -60,6 +60,7 @@ public class HTTPDownloader extends Downloader
* Issues a HEAD request for the specified resource and notes the
* amount of data we will be downloading to account for it.
*/
@Override
protected long checkSize (Resource rsrc)
throws IOException
{
@@ -80,6 +81,7 @@ public class HTTPDownloader extends Downloader
}
// documentation inherited
@Override
protected void doDownload (Resource rsrc)
throws IOException
{
@@ -58,6 +58,7 @@ public class TorrentDownloader extends Downloader
}
// documentation inherited
@Override
protected long checkSize(Resource rsrc)
throws IOException
{
@@ -89,6 +90,7 @@ public class TorrentDownloader extends Downloader
}
// documentation inherited
@Override
protected void doDownload(Resource rsrc)
throws IOException
{
@@ -6,13 +6,13 @@
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
@@ -131,7 +131,7 @@ public class Differ
// by leaving it out, it will be left as is during the
// patching process
continue;
}
}
// otherwise potentially create a jar diff
if (rsrc.getPath().endsWith(".jar")) {
@@ -192,8 +192,8 @@ public class Differ
JarOutputStream jout = new JarOutputStream(
new BufferedOutputStream(new FileOutputStream(temp)));
byte[] buffer = new byte[4096];
for (Enumeration iter = jar.entries(); iter.hasMoreElements(); ) {
JarEntry entry = (JarEntry)iter.nextElement();
for (Enumeration<JarEntry> iter = jar.entries(); iter.hasMoreElements(); ) {
JarEntry entry = iter.nextElement();
entry.setCompressedSize(-1);
jout.putNextEntry(entry);
InputStream in = jar.getInputStream(entry);
@@ -83,6 +83,7 @@ public class DigesterTask extends Task
/**
* Performs the actual work of the task.
*/
@Override
public void execute () throws BuildException
{
// make sure appdir is set
@@ -6,13 +6,13 @@
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
@@ -88,7 +88,7 @@ public class JarDiffPatcher
determineNameMapping(jarDiff, ignoreSet, renameMap);
// get all keys in renameMap
Object[] keys = renameMap.keySet().toArray();
String[] keys = renameMap.keySet().toArray(new String[renameMap.size()]);
// Files to implicit move
Set<String> oldjarNames = new HashSet<String>();
@@ -139,9 +139,8 @@ public class JarDiffPatcher
}
// go through the renameMap and apply move for each entry
for (int j = 0; j < keys.length; j++) {
for (String newName : keys) {
// Apply move <oldName> <newName> command
String newName = (String)keys[j];
String oldName = renameMap.get(newName);
// Get source JarEntry
@@ -177,10 +176,10 @@ public class JarDiffPatcher
}
// implicit move
Iterator iEntries = oldjarNames.iterator();
Iterator<String> iEntries = oldjarNames.iterator();
if (iEntries != null) {
while (iEntries.hasNext()) {
String name = (String)iEntries.next();
String name = iEntries.next();
JarEntry entry = oldJar.getJarEntry(name);
updateObserver(observer, currentEntry, size);
currentEntry++;
@@ -6,13 +6,13 @@
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
@@ -29,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
@@ -74,9 +75,9 @@ public class Patcher
_plength = patch.length();
JarFile file = new JarFile(patch);
Enumeration entries = file.entries(); // old skool!
Enumeration<JarEntry> entries = file.entries(); // old skool!
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
JarEntry entry = entries.nextElement();
String path = entry.getName();
long elength = entry.getCompressedSize();
@@ -6,13 +6,13 @@
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
@@ -31,7 +31,6 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import com.samskivert.io.StreamUtil;
@@ -136,14 +135,12 @@ public class ConfigUtil
public static HashMap<String, Object> parseConfig (File config, boolean checkPlatform)
throws IOException
{
List<String[]> pairs = parsePairs(config, checkPlatform);
HashMap<String, Object> data = new HashMap<String, Object>();
// I thought that we could use HashMap<String, String[]> and put new String[] {pair[1]} for
// the null case, but it mysteriously dies on launch, so leaving it as HashMap<String,
// Object> for now
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
String[] pair = (String[])iter.next();
for (String[] pair : parsePairs(config, checkPlatform)) {
Object value = data.get(pair[0]);
if (value == null) {
data.put(pair[0], pair[1]);
@@ -165,7 +162,7 @@ public class ConfigUtil
* Massages a single string into an array and leaves existing array values as is. Simplifies
* access to parameters that are expected to be arrays.
*/
public static String[] getMultiValue (HashMap data, String name)
public static String[] getMultiValue (HashMap<String, Object> data, String name)
{
Object value = data.get(name);
if (value instanceof String) {
@@ -28,8 +28,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.Level;
import com.samskivert.io.StreamUtil;
import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil;