原来这是一个判断当前参数的方法:
if(O02.length == 0 || O06(new String[] {
"help", "h", "?", "/?"
}))
{
System.out.println(O07.O08);
return false;
}
这一段是帮助系统,既然我们要修改,那么先把帮助系统处理了.就当咱们肯定能把这个修改成功完成.
目标锁定O07.O08(这是一个final static String):
public O07()
{
}
static
{
O0995 = System.getProperty("line.separator");
if(O0995 == null)
{
System.out.println("Warning:System Property line.separator not defined\n");
O0995 = "\r\n";
}
O0997 = "Copyright (c) 2000-2003 Polygon Enterprises." + O0995 + "New Versions available from http://www.java2html.com" + O0995 + "(type j2h with no arguments to get help)";
O08 = O0995 + "Usage: [j2h|java j2h|java -jar j2h.jar][options]"
+ O0995 + "-d <destination> Destination output directory"
+ O0995 + "-js <java source> Java Source directory"
+ O0995 + "-jd <javadoc> [web_reference] JavaDoc Source directory"
+ O0995 + "-m <margin> Margin Size (with Line Numbers)"
+ O0995 + "-t <tabsize> Tab size"
+ O0995 + "-n <name> Title Name"
+ O0995 + "-nh Prevents the header from being displayed"
+ O0995 + "-nf Prevents the footer from being displayed"
//我在这里添加了encoding的帮助信息
+ O0995 +"-encoding set the html \"charset\""
+O0995 + "-s Simple output, just include the Java source and stylesheet.css files"
+ O0995 + "-h (or no arguments) This Help" + O0995
+ O0995 + "Edit generated stylesheet.css file to change colours & styles"
+ O0995 + "View generated index.html in browser to see results after running"
+ O0995;
}
现在使用java2html的时候已经有了对encoding的帮助信息了.
String as2[] = O010(new String[] {"javasource", "js"}, false, -1);
帮助信息后我们看到了类似这样的方法调用,看来这是判断参数内容的方法了
private String[] O010(String as[], boolean flag, int i)
throws BadOptionException
{
int j = 0;
int k = 0;
Vector vector = new Vector();
for(; j < O02.length; j++)
{
for(int l = 0; l < as.length; l++)
{
if(!O02[j].equalsIgnoreCase("-" + as[l]))
{
continue;
}
O03[j] = true;
j++;
if(k == i)
{
throw new BadOptionException(as[0] + " should only be set " + i + " time(s)");
}
if(j >= O02.length)
{
throw new BadOptionException("Value not set for " + as[0]);
}
O03[j] = true;
vector.addElement(O02[j]);
k++;
break;
}
}
if(flag && k == 0)
{
throw new BadOptionException(as[0] + " needs to be set");
} else
{
return O026(vector);
}
}
原来这个方法是把用户送进来的参数(as)和java2html默认的参数比较,如果是java2html的参数那么把用户的参数取值.
我们先把咱们的参数添加上吧.
//添加我们自定义的参数
String as3[] = O010(new String[] {
"encoding", "encoding"
}, false, -1);
//同样依葫芦画瓢
if(as3.length > 0)
{
java2html.setEncoding(as3[0]);
}
这样用户的参数就送进了as[]了.
不过现在java2html中并没有setEncoding方法.我们的添加一个.
回到java2html.java中添加:
//我在这里设定了默认的字符编码,因为utf-8基本上支持所有的字符编码.
private String encoding="UTF-8";
//添加一个新方法
public void setEncoding(String strEncoding){
encoding=strEncoding;
}
这样,用户的参数就已经送到java2html类中了.
欲知后事如何,且听下回分解.
本文地址:http://com.8s8s.com/it/it17541.htm