Java2HTML改造手記(4)(轉(zhuǎn))-創(chuàng)新互聯(lián)

Java2HTML改造手記(4) (轉(zhuǎn))[@more@]

Java2HTML改造手記(4)

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

成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比大英網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式大英網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋大英地區(qū)。費(fèi)用合理售后完善,10多年實(shí)體公司更值得信賴。

原來(lái)這是一個(gè)判斷當(dāng)前參數(shù)的方法:

if(O02.length == 0 || O06(new String[] {

  "help", "h", "?", "/?"

}))

  {

  System.out.println(O07.O08);

  return false;

  }

這一段是幫助系統(tǒng),既然我們要修改,那么先把幫助系統(tǒng)處理了.就當(dāng)咱們肯定能把這個(gè)修改成功完成.

目標(biāo)鎖定O07.O08(這是一個(gè)final static String):

  public O07()

  {

  }

  static

  {

  O0995 = System.getProperty("line.separator");

  if(O0995 == null)

  {

  System.out.println("Warning:System Property line.separator not definedn");

  O0995 = "rn";

  }

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

  }

現(xiàn)在使用java2html的時(shí)候已經(jīng)有了對(duì)encoding的幫助信息了.

String as2[] = O010(new String[] {"javasource", "js"}, false, -1);

幫助信息后我們看到了類似這樣的方法調(diào)用,看來(lái)這是判斷參數(shù)內(nèi)容的方法了

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

  }

  }

原來(lái)這個(gè)方法是把用戶送進(jìn)來(lái)的參數(shù)(as)和java2html默認(rèn)的參數(shù)比較,如果是java2html的參數(shù)那么把用戶的參數(shù)取值.

我們先把咱們的參數(shù)添加上吧.

//添加我們自定義的參數(shù)

  String as3[] = O010(new String[] {

  "encoding", "encoding"

  }, false, -1);

//同樣依葫蘆畫(huà)瓢

  if(as3.length > 0)

  {

  java2html.setEncoding(as3[0]);

  }

這樣用戶的參數(shù)就送進(jìn)了as[]了.

不過(guò)現(xiàn)在java2html中并沒(méi)有setEncoding方法.我們的添加一個(gè).

回到j(luò)ava2html.java中添加:

//我在這里設(shè)定了默認(rèn)的字符編碼,因?yàn)閡tf-8基本上支持所有的字符編碼.

private String encoding="UTF-8";

//添加一個(gè)新方法

  public void setEncoding(String strEncoding){

    encoding=strEncoding;

}

這樣,用戶的參數(shù)就已經(jīng)送到j(luò)ava2html類中了.

欲知后事如何,且聽(tīng)下回分解.


分享名稱:Java2HTML改造手記(4)(轉(zhuǎn))-創(chuàng)新互聯(lián)
瀏覽路徑:http://muchs.cn/article4/psooe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、定制網(wǎng)站、網(wǎng)站收錄微信小程序、外貿(mào)網(wǎng)站建設(shè)企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)