Java2HTML改造手记(4) (转)

Java2HTML改造手记(4) (转)[@more@]

Java2HTML改造手记(4)

XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" />

原来这是一个判断当前参数的方法:

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 ");

  O0995 = " ";

  }

  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 output directory"

  + O0995 + "-js source>  Java Source directory"

  + O0995 + "-jd [web_reference]  JavaDoc Source directory"

  + O0995 + "-m   Margin Size (with Line Numbers)"

  + O0995 + "-t   Tab size"

  + O0995 + "-n   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类中了.

欲知后事如何,且听下回分解.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-959615/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-959615/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值