Checked in patch from Stefan Matthias Aust:

* Don't call static methods as instance methods
* Remove unused imports
* Remove variables that are never read
This commit is contained in:
hns 2003-07-08 13:52:36 +00:00
parent cc29ebbaf4
commit 2f39d4f908
27 changed files with 64 additions and 95 deletions

View file

@ -116,7 +116,6 @@ public class GifEncoder extends ImageEncoder
int index = 0;
for ( int row = 0; row < height; ++row )
{
int rowOffset = row * width;
for ( int col = 0; col < width; ++col )
{
int rgb = rgbPixels[row][col];

View file

@ -90,11 +90,11 @@ public class DocFunction extends DocFileElement {
// if we're currently parsing a functionbody and come to the start
// of the next function or eof -> read function body
if (curFunction != null && (tok== ts.FUNCTION || ts.eof())) {
if (curFunction != null && (tok== TokenStream.FUNCTION || ts.eof())) {
curFunction.content = "function " + Util.getStringFromFile(location, curFunctionStart, endOfLastToken);
}
if (tok == ts.FUNCTION) {
if (tok == TokenStream.FUNCTION) {
// store the function start for parsing the function body later
curFunctionStart = getPoint (ts);
// get and chop the comment
@ -111,12 +111,12 @@ public class DocFunction extends DocFileElement {
// subloop on the tokenstream: find the parameters of a function
// only if it's a function (and not a macro or an action)
if (curFunction.type == FUNCTION) {
while (!ts.eof() && tok != ts.RP) {
while (!ts.eof() && tok != TokenStream.RP) {
// store the position of the last token
endOfLastToken = getPoint (ts);
// new token
tok = ts.getToken();
if (tok==ts.NAME) {
if (tok==TokenStream.NAME) {
curFunction.addParameter (ts.getString());
}
}

View file

@ -58,7 +58,6 @@ public class DocSkin extends DocFileElement {
ArrayList partBuffer = new ArrayList();
char[] source = content.toCharArray();
int sourceLength = source.length;
int start = 0;
for (int i = 0; i < (sourceLength - 1); i++) {
if ((source[i] == '<') && (source[i + 1] == '%')) {
@ -92,8 +91,6 @@ public class DocSkin extends DocFileElement {
partBuffer.add(str);
}
}
start = j + 2;
}
i = j + 1;

View file

@ -447,7 +447,7 @@ public final class Application implements IPathElement, Runnable {
// give it 3 more tries, waiting 3 seconds each time.
for (int i = 0; i < 4; i++) {
try {
Thread.currentThread().sleep(3000);
Thread.sleep(3000);
return (RequestEvaluator) freeThreads.pop();
} catch (EmptyStackException nothreads) {
@ -1450,7 +1450,7 @@ public final class Application implements IPathElement, Runnable {
// sleep until the next full minute
try {
worker.sleep(sleepInterval);
Thread.sleep(sleepInterval);
} catch (InterruptedException x) {
logEvent("Scheduler for " + name + " interrupted");
worker = null;

View file

@ -103,8 +103,6 @@ public final class RequestEvaluator implements Runnable {
*
*/
public void run() {
int txcount = 0;
// first, set a local variable to the current transactor thread so we know
// when it's time to quit because another thread took over.
Transactor localrtx = (Transactor) Thread.currentThread();
@ -351,8 +349,7 @@ public final class RequestEvaluator implements Runnable {
// wait a bit longer with each try
int base = 800 * tries;
Thread.currentThread().sleep((long) (base +
(Math.random() * base * 2)));
Thread.sleep((long) (base + (Math.random() * base * 2)));
} catch (Exception ignore) {
}
@ -905,4 +902,5 @@ public final class RequestEvaluator implements Runnable {
return null;
}
}

View file

@ -87,8 +87,6 @@ public final class Skin {
private void parse() {
ArrayList partBuffer = new ArrayList();
int start = 0;
for (int i = 0; i < (sourceLength - 1); i++) {
if ((source[i] == '<') && (source[i + 1] == '%')) {
// found macro start tag
@ -102,7 +100,6 @@ public final class Skin {
if (j > (i + 2)) {
partBuffer.add(new Macro(i, j + 2));
start = j + 2;
}
i = j + 1;
@ -376,7 +373,7 @@ public final class Skin {
public void render(RequestEvaluator reval, Object thisObject, Map paramObject,
Map handlerCache) throws RedirectException {
if ((sandbox != null) && !sandbox.contains(fullName)) {
String h = (handler == null) ? "global" : handler;
//String h = (handler == null) ? "global" : handler;
reval.res.write("[Macro " + fullName + " not allowed in sandbox]");

View file

@ -309,7 +309,6 @@ public abstract class ImageWrapper {
StringTokenizer tk = new StringTokenizer(string);
StringBuffer buffer = new StringBuffer();
int spaceWidth = metrics.stringWidth(" ");
int currentLine = 0;
int currentWidth = 0;
int maxWidth = w - 2;
int maxHeight = (h + addedSpace) - 2;

View file

@ -545,11 +545,9 @@ public class Server implements IPathElement, Runnable {
}
}
int count = 0;
while (Thread.currentThread() == mainThread) {
try {
mainThread.sleep(3000L);
Thread.sleep(3000L);
} catch (InterruptedException ie) {
}
@ -629,7 +627,7 @@ public class Server implements IPathElement, Runnable {
addr = InetAddress.getLocalHost();
}
try {
Socket socket = new Socket(addr, addrPort.getPort());
new Socket(addr, addrPort.getPort());
} catch (IOException x) {
// we couldn't connect to the socket because no server
// is running on it yet. Everything's ok.

View file

@ -167,7 +167,6 @@ public class TransientNode implements INode, Serializable {
* @return ...
*/
public String getFullName(INode root) {
String fullname = "";
String divider = null;
StringBuffer b = new StringBuffer();
TransientNode p = this;
@ -548,7 +547,7 @@ public class TransientNode implements INode, Serializable {
}
// nodes.remove (node);
Object what = nodeMap.remove(node.getName().toLowerCase());
nodeMap.remove(node.getName().toLowerCase());
// Server.throwNodeEvent (new NodeEvent (node, NodeEvent.NODE_REMOVED));
// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.SUBNODE_REMOVED, node));
@ -923,7 +922,7 @@ public class TransientNode implements INode, Serializable {
}
try {
Property p = (Property) propMap.remove(propname.toLowerCase());
propMap.remove(propname.toLowerCase());
lastmodified = System.currentTimeMillis();
} catch (Exception ignore) {

View file

@ -484,7 +484,6 @@ public final class Node implements INode, Serializable {
* @return ...
*/
public String getFullName(INode root) {
String fullname = "";
String divider = null;
StringBuffer b = new StringBuffer();
INode p = this;
@ -839,8 +838,6 @@ public final class Node implements INode, Serializable {
node.makePersistentCapable();
}
String n = node.getName();
// if (n.indexOf('/') > -1)
// throw new RuntimeException ("\"/\" found in Node name.");
// only mark this node as modified if subnodes are not in relational db
@ -1153,11 +1150,13 @@ public final class Node implements INode, Serializable {
return null;
}
/*
DbMapping smap = null;
if (dbmap != null) {
smap = dbmap.getSubnodeMapping();
}
*/
Node retval = null;
@ -1291,9 +1290,11 @@ public final class Node implements INode, Serializable {
// check if the subnode is in relational db and has a link back to this
// which needs to be unset
/*
if (dbmap != null) {
Relation srel = dbmap.getSubnodeRelation();
}
*/
// check if subnodes are also accessed as properties. If so, also unset the property
if ((dbmap != null) && (node.dbmap != null)) {

View file

@ -183,8 +183,6 @@ public final class NodeManager {
*/
public void deleteNode(Node node) throws Exception {
if (node != null) {
String id = node.getID();
synchronized (this) {
Transactor tx = (Transactor) Thread.currentThread();
@ -362,7 +360,7 @@ public final class NodeManager {
} else {
// node fetched from db is null, cache result using nullNode
synchronized (cache) {
Node oldnode = (Node) cache.put(key, new Node());
cache.put(key, new Node());
// we ignore the case that onother thread has created the node in the meantime
return null;

View file

@ -109,7 +109,6 @@ public final class Relation {
////////////////////////////////////////////////////////////////////////////////////////////
public void update(String desc, Properties props) {
Application app = ownType.getApplication();
boolean notPrimitive = false;
if ((desc == null) || "".equals(desc.trim())) {
if (propName != null) {

View file

@ -91,7 +91,7 @@ public class Replicator implements Runnable {
try {
if (runner != null) {
runner.sleep(1000L);
Thread.sleep(1000L);
}
} catch (InterruptedException ir) {
runner = null;

View file

@ -18,10 +18,7 @@ package helma.objectmodel.db;
import helma.objectmodel.*;
import helma.objectmodel.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.*;
import java.util.Date;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
@ -200,7 +197,7 @@ public final class XmlDatabase implements IDatabase {
writer.setMaxLevels(1);
boolean result = writer.write((Node) node);
writer.write((Node) node);
writer.close();
}
@ -225,7 +222,7 @@ public final class XmlDatabase implements IDatabase {
*
* @param enc ...
*/
public void setEncoding(String enc) {
public void setEncoding(String encoding) {
this.encoding = encoding;
}

View file

@ -24,6 +24,7 @@ import helma.objectmodel.db.*;
import helma.util.HtmlEncoder;
import helma.util.MimePart;
import org.mozilla.javascript.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
@ -63,8 +64,8 @@ public class GlobalObject extends ScriptableObject {
};
defineFunctionProperties(globalFuncs, GlobalObject.class, 0);
put("app", this, cx.toObject(new ApplicationBean(app), this));
put("Xml", this, cx.toObject(new XmlObject(core), this));
put("app", this, Context.toObject(new ApplicationBean(app), this));
put("Xml", this, Context.toObject(new XmlObject(core), this));
}
/**

View file

@ -22,6 +22,7 @@ import helma.framework.core.*;
import helma.objectmodel.*;
import helma.objectmodel.db.*;
import org.mozilla.javascript.*;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@ -91,7 +92,7 @@ public class HopObject extends ScriptableObject {
for (int i=0; i<cnst.length; i++) try {
FunctionObject fo = new FunctionObject("ctor", cnst[i], engine.global);
Object obj = fo.call(cx, engine.global, null, args);
return cx.toObject(obj, engine.global);
return Context.toObject(obj, engine.global);
} catch (JavaScriptException x) {
Object value = x.getValue();
if (value instanceof Throwable) {
@ -262,7 +263,6 @@ public class HopObject extends ScriptableObject {
return null;
}
Context cx = Context.getCurrentContext();
Object n = null;
if (id instanceof Number) {
@ -274,7 +274,7 @@ public class HopObject extends ScriptableObject {
if (n == null) {
return null;
} else {
return cx.toObject(n, core.global);
return Context.toObject(n, core.global);
}
}
@ -334,7 +334,6 @@ public class HopObject extends ScriptableObject {
* @return ...
*/
public Object[] jsFunction_list() {
int l = node.numberOfNodes();
Enumeration e = node.getSubnodes();
ArrayList a = new ArrayList();
@ -358,11 +357,11 @@ public class HopObject extends ScriptableObject {
}
if (child instanceof HopObject) {
INode added = node.addNode(((HopObject) child).node);
node.addNode(((HopObject) child).node);
return true;
} else if (child instanceof INode) {
INode added = node.addNode((INode) child);
node.addNode((INode) child);
return true;
}
@ -384,11 +383,11 @@ public class HopObject extends ScriptableObject {
}
if (child instanceof HopObject) {
INode added = node.addNode(((HopObject) child).node, index);
node.addNode(((HopObject) child).node, index);
return true;
} else if (child instanceof INode) {
INode added = node.addNode((INode) child, index);
node.addNode((INode) child, index);
return true;
}
@ -416,7 +415,7 @@ public class HopObject extends ScriptableObject {
}
}
} catch (Exception x) {
System.err.println("XXX: " + x);
System.err.println("Error in HopObject.remove(): " + x);
x.printStackTrace();
}
}
@ -610,7 +609,7 @@ public class HopObject extends ScriptableObject {
if (n == null) {
return NOT_FOUND;
} else {
return cx.toObject(n, core.global);
return Context.toObject(n, core.global);
}
}
@ -620,7 +619,7 @@ public class HopObject extends ScriptableObject {
if (obj == null) {
return NOT_FOUND;
} else {
return cx.toObject(obj, core.global);
return Context.toObject(obj, core.global);
}
}
}
@ -723,12 +722,8 @@ public class HopObject extends ScriptableObject {
public Object get(int idx, Scriptable start) {
if (node != null) {
INode n = node.getSubnodeAt(idx);
if (n == null) {
return NOT_FOUND;
} else {
Context cx = Context.getCurrentContext();
return cx.toObject(n, core.global);
if (n != null) {
return Context.toObject(n, core.global);
}
}

View file

@ -82,13 +82,11 @@ public class MapWrapper extends ScriptableObject {
Object obj = map.get(name);
if (obj != null && !(obj instanceof Scriptable)) {
Context cx = Context.getCurrentContext();
if (obj instanceof String) {
return obj;
}
return cx.toObject(obj, core.global);
return Context.toObject(obj, core.global);
}
return obj;
@ -151,9 +149,7 @@ public class MapWrapper extends ScriptableObject {
Object obj = map.get(Integer.toString(idx));
if (obj != null && !(obj instanceof Scriptable)) {
Context cx = Context.getCurrentContext();
return cx.toObject(obj, core.global);
return Context.toObject(obj, core.global);
}
return obj;

View file

@ -29,6 +29,7 @@ import helma.util.SystemMap;
import helma.util.SystemProperties;
import helma.util.Updatable;
import org.mozilla.javascript.*;
import java.io.*;
import java.text.*;
import java.util.*;
@ -109,7 +110,7 @@ public final class RhinoCore {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
} finally {
context.exit();
Context.exit();
}
}
@ -168,8 +169,6 @@ public final class RhinoCore {
if (op == null) {
try {
Context context = Context.getCurrentContext();
op = new HopObject(name); // context.newObject (global /*, "HopObject" */);
op.setPrototype(opp);
op.setParentScope(global);
@ -237,8 +236,6 @@ public final class RhinoCore {
if (op == null) {
try {
Context context = Context.getCurrentContext();
op = new HopObject(name); // context.newObject (global /*, "HopObject" */);
op.setPrototype(opp);
op.setParentScope(global);

View file

@ -29,6 +29,7 @@ import helma.scripting.*;
import helma.util.CacheMap;
import helma.util.Updatable;
import org.mozilla.javascript.*;
import java.io.*;
import java.util.*;
@ -190,7 +191,7 @@ public class RhinoEngine implements ScriptingEngine {
// register path elements with their prototype
for (int j = 0; j < path.size(); j++) {
Object pathElem = path.get(j);
Scriptable wrappedElement = context.toObject(pathElem, global);
Scriptable wrappedElement = Context.toObject(pathElem, global);
arr.put(j, arr, wrappedElement);
@ -204,7 +205,7 @@ public class RhinoEngine implements ScriptingEngine {
v = arr;
}
scriptable = context.toObject(v, global);
scriptable = Context.toObject(v, global);
global.put(k, global, scriptable);
} catch (Exception x) {
app.logEvent("Error setting global variable " + k + ": " + x);
@ -223,7 +224,7 @@ public class RhinoEngine implements ScriptingEngine {
public void exitContext() {
context.removeThreadLocal("reval");
context.removeThreadLocal("engine");
context.exit();
Context.exit();
thread = null;
// loop through previous globals and unset them, if necessary.
@ -250,7 +251,7 @@ public class RhinoEngine implements ScriptingEngine {
if (thisObject == null) {
eso = global;
} else {
eso = context.toObject(thisObject, global);
eso = Context.toObject(thisObject, global);
}
try {
for (int i = 0; i < args.length; i++) {
@ -258,7 +259,7 @@ public class RhinoEngine implements ScriptingEngine {
if (xmlrpc) {
args[i] = core.processXmlRpcArgument (args[i]);
} else if (args[i] != null) {
args[i] = context.toObject(args[i], global);
args[i] = Context.toObject(args[i], global);
}
}
@ -327,7 +328,7 @@ public class RhinoEngine implements ScriptingEngine {
if (t != null && t.isAlive()) {
t.interrupt();
try {
Thread.currentThread().sleep(5000);
Thread.sleep(5000);
if (t.isAlive()) {
// thread is still running, gotta stop it.
t.stop();
@ -377,7 +378,7 @@ public class RhinoEngine implements ScriptingEngine {
}
}
Scriptable so = context.toObject(obj, global);
Scriptable so = Context.toObject(obj, global);
try {
Object prop = so.get(propname, so);
@ -459,7 +460,7 @@ public class RhinoEngine implements ScriptingEngine {
// retrieve res.skinpath, an array of objects that tell us where to look for skins
// (strings for directory names and INodes for internal, db-stored skinsets)
Object[] skinpath = reval.res.getSkinpath();
core.unwrapSkinpath(skinpath);
RhinoCore.unwrapSkinpath(skinpath);
skin = app.getSkin(protoName, skinName, skinpath);
reval.res.cacheSkin(key, skin);
}

View file

@ -407,7 +407,6 @@ class RowSet {
if (!firstRowSeen) {
throw new SQLException("Attempt to access data before the first row is read");
}
int hash = propertyName.hashCode();
try {
int index = -1; // indicates not a valid index value
try {

View file

@ -51,7 +51,7 @@ public class ImageObject {
}
}
FunctionObject ctor = new FunctionObject("Image", ctorMember, scope);
((ScriptableObject)scope).defineProperty(scope, "Image", ctor, ScriptableObject.DONTENUM);
ScriptableObject.defineProperty(scope, "Image", ctor, ScriptableObject.DONTENUM);
global = scope;
// ctor.addAsConstructor(scope, proto);
}
@ -105,6 +105,6 @@ public class ImageObject {
throw new RuntimeException("Error creating image: Bad parameters or setup problem.");
}
return cx.toObject(img, global);
return Context.toObject(img, global);
}
}

View file

@ -76,7 +76,7 @@ public class XmlObject {
writer.setDatabaseMode(false);
boolean result = writer.write(node);
writer.write(node);
writer.close();
@ -112,7 +112,7 @@ public class XmlObject {
// writer.setMaxLevels(arguments[1].toInt32());
writer.setDatabaseMode(false);
boolean result = writer.write(node);
writer.write(node);
writer.flush();

View file

@ -88,7 +88,7 @@ public class XmlRpcObject extends BaseFunction {
}
}
FunctionObject ctor = new FunctionObject("Remote", ctorMember, scope);
((ScriptableObject)scope).defineProperty(scope, "Remote", ctor, ScriptableObject.DONTENUM);
ScriptableObject.defineProperty(scope, "Remote", ctor, ScriptableObject.DONTENUM);
// ctor.addAsConstructor(scope, proto);
}

View file

@ -162,7 +162,7 @@ public abstract class AbstractServletClient extends HttpServlet {
}
}
} catch (Exception upx) {
sendError(response, response.SC_REQUEST_ENTITY_TOO_LARGE,
sendError(response, HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE,
"Sorry, upload size exceeds limit of " + uploadLimit +
"kB.");
@ -256,8 +256,6 @@ public abstract class AbstractServletClient extends HttpServlet {
ResponseTrans restrans = execute(reqtrans);
// set cookies
int ncookies = restrans.countCookies();
if (restrans.countCookies() > 0) {
CookieTrans[] resCookies = restrans.getCookies();
@ -275,11 +273,11 @@ public abstract class AbstractServletClient extends HttpServlet {
} catch (Exception x) {
try {
if (debug) {
sendError(response, response.SC_INTERNAL_SERVER_ERROR,
sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Error in request handler:" + x);
x.printStackTrace();
} else {
sendError(response, response.SC_INTERNAL_SERVER_ERROR,
sendError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"The server encountered an error while processing your request. " +
"Please check back later.");
}
@ -403,9 +401,9 @@ public abstract class AbstractServletClient extends HttpServlet {
// send status code 303 for HTTP 1.1, 302 otherwise
if (isOneDotOne(req.getProtocol())) {
res.setStatus(res.SC_SEE_OTHER);
res.setStatus(HttpServletResponse.SC_SEE_OTHER);
} else {
res.setStatus(res.SC_MOVED_TEMPORARILY);
res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
}
res.setContentType("text/html");
@ -577,7 +575,6 @@ public abstract class AbstractServletClient extends HttpServlet {
public static void parseParameters(Map map, byte[] data, String encoding)
throws UnsupportedEncodingException {
if ((data != null) && (data.length > 0)) {
int pos = 0;
int ix = 0;
int ox = 0;
String key = null;

View file

@ -1,4 +1,7 @@
/* $Log$
/* Revision 1.1 2002/10/31 08:39:34 hannes
/* Added GNU Diff class from http://www.bmsi.com/java/#diff
/*
* Revision 1.3 2000/03/03 21:58:03 stuart
* move discard_confusing_lines and shift_boundaries to class file_data
*
@ -312,7 +315,7 @@ public class Diff {
int d = diag (xoff, xlim, yoff, ylim);
int c = cost;
int f = fdiag[fdiagoff + d];
//int f = fdiag[fdiagoff + d];
int b = bdiag[bdiagoff + d];
if (c == 1)

View file

@ -473,8 +473,6 @@ public final class Logger {
}
public void run() {
long start = System.currentTimeMillis();
try {
GZIPOutputStream zip = new GZIPOutputStream(new FileOutputStream(temp));
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));

View file

@ -64,7 +64,7 @@ public class XmlUtils {
if (obj instanceof String) {
try {
// first try to interpret string as URL
URL url = new URL(obj.toString());
new URL(obj.toString());
doc = parser.parse(obj.toString());
} catch (MalformedURLException nourl) {