|
|
@ -18,7 +18,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package jode.decompiler; |
|
|
|
package jode.decompiler; |
|
|
|
import jode.Decompiler; |
|
|
|
import jode.GlobalOptions; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.type.*; |
|
|
|
import jode.type.*; |
|
|
|
|
|
|
|
|
|
|
@ -33,6 +33,18 @@ public class ImportHandler { |
|
|
|
String className; |
|
|
|
String className; |
|
|
|
String pkg; |
|
|
|
String pkg; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int importPackageLimit; |
|
|
|
|
|
|
|
int importClassLimit; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ImportHandler() { |
|
|
|
|
|
|
|
this(3,3); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ImportHandler(int packageLimit, int classLimit) { |
|
|
|
|
|
|
|
importPackageLimit = packageLimit; |
|
|
|
|
|
|
|
importClassLimit = classLimit; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Checks if the className conflicts with a class imported from |
|
|
|
* Checks if the className conflicts with a class imported from |
|
|
|
* another package and must be fully qualified therefore. |
|
|
|
* another package and must be fully qualified therefore. |
|
|
@ -88,12 +100,12 @@ public class ImportHandler { |
|
|
|
String importName = (String) enum.nextElement(); |
|
|
|
String importName = (String) enum.nextElement(); |
|
|
|
Integer vote = (Integer) imports.get(importName); |
|
|
|
Integer vote = (Integer) imports.get(importName); |
|
|
|
if (!importName.endsWith(".*")) { |
|
|
|
if (!importName.endsWith(".*")) { |
|
|
|
if (vote.intValue() < Decompiler.importClassLimit) |
|
|
|
if (vote.intValue() < importClassLimit) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
int delim = importName.lastIndexOf("."); |
|
|
|
int delim = importName.lastIndexOf("."); |
|
|
|
Integer pkgvote = (Integer) |
|
|
|
Integer pkgvote = (Integer) |
|
|
|
imports.get(importName.substring(0, delim)+".*"); |
|
|
|
imports.get(importName.substring(0, delim)+".*"); |
|
|
|
if (pkgvote.intValue() >= Decompiler.importPackageLimit) |
|
|
|
if (pkgvote.intValue() >= importPackageLimit) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
/* This is a single Class import, that is not |
|
|
|
/* This is a single Class import, that is not |
|
|
@ -102,7 +114,7 @@ public class ImportHandler { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
classImports.addElement(importName); |
|
|
|
classImports.addElement(importName); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (vote.intValue() < Decompiler.importPackageLimit) |
|
|
|
if (vote.intValue() < importPackageLimit) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
newImports.put(importName, dummyVote); |
|
|
|
newImports.put(importName, dummyVote); |
|
|
|
} |
|
|
|
} |
|
|
@ -134,7 +146,7 @@ public class ImportHandler { |
|
|
|
writer.println("/* "+ className |
|
|
|
writer.println("/* "+ className |
|
|
|
+ " - Decompiled by JoDe (Jochen's Decompiler)"); |
|
|
|
+ " - Decompiled by JoDe (Jochen's Decompiler)"); |
|
|
|
writer.println(" * Send comments or bug reports to " |
|
|
|
writer.println(" * Send comments or bug reports to " |
|
|
|
+ Decompiler.email); |
|
|
|
+ GlobalOptions.email); |
|
|
|
writer.println(" */"); |
|
|
|
writer.println(" */"); |
|
|
|
if (pkg.length() != 0) |
|
|
|
if (pkg.length() != 0) |
|
|
|
writer.println("package "+pkg+";"); |
|
|
|
writer.println("package "+pkg+";"); |
|
|
@ -150,7 +162,7 @@ public class ImportHandler { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void error(String message) { |
|
|
|
public void error(String message) { |
|
|
|
Decompiler.err.println(message); |
|
|
|
GlobalOptions.err.println(message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void init(String className) { |
|
|
|
public void init(String className) { |
|
|
@ -177,7 +189,7 @@ public class ImportHandler { |
|
|
|
|
|
|
|
|
|
|
|
Integer pkgVote = (Integer) imports.get(pkgName+".*"); |
|
|
|
Integer pkgVote = (Integer) imports.get(pkgName+".*"); |
|
|
|
if (pkgVote != null |
|
|
|
if (pkgVote != null |
|
|
|
&& pkgVote.intValue() >= Decompiler.importPackageLimit) |
|
|
|
&& pkgVote.intValue() >= importPackageLimit) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Integer i = (Integer) imports.get(name); |
|
|
|
Integer i = (Integer) imports.get(name); |
|
|
@ -191,7 +203,7 @@ public class ImportHandler { |
|
|
|
i = new Integer(1); |
|
|
|
i = new Integer(1); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (i.intValue() >= Decompiler.importClassLimit) |
|
|
|
if (i.intValue() >= importClassLimit) |
|
|
|
return; |
|
|
|
return; |
|
|
|
i = new Integer(i.intValue()+1); |
|
|
|
i = new Integer(i.intValue()+1); |
|
|
|
} |
|
|
|
} |
|
|
|