逝者如斯夫

          靜而思之
          數據加載中……

          如何進制轉換

          代碼示例:
          int?a?=?32;
          System.out.println(
          "二進制:?"+Integer.toBinaryString(a));
          System.out.println(
          "十六進制:?"+Integer.toHexString(a));
          System.out.println(
          "八進制:?"+Integer.toOctalString(a));
          System.out.println(
          "十二進制:?"+Integer.toString(month,?12));

          String?s
          ="66";
          System.out.println(Integer.toString(Integer.parseInt(s,
          12),?6));

          posted @ 2007-04-20 10:36 ideame 閱讀(788) | 評論 (0)編輯 收藏

          復合常量的問題

          可以使用一個變量或字段記錄幾個復合狀態:



          int?a?=?1;
          System.out.println(a);
          System.out.println(
          "Integer.toBinaryString(a)="?+
          Integer.toBinaryString(a));
          System.out.println(
          "Integer.toHexString(a)="?+?Integer.toHexString(a));
          System.out.println(
          "Integer.toOctalString(a)="?+
          Integer.toOctalString(a));
          a?
          =?2;
          System.out.println(a);
          System.out.println(
          "Integer.toBinaryString(a)="?+
          Integer.toBinaryString(a));
          System.out.println(
          "Integer.toHexString(a)="?+?Integer.toHexString(a));
          System.out.println(
          "Integer.toOctalString(a)="?+
          Integer.toOctalString(a));

          a?
          =?4;
          System.out.println(a);
          System.out.println(
          "Integer.toBinaryString(a)="?+
          Integer.toBinaryString(a));
          System.out.println(
          "Integer.toHexString(a)="?+?Integer.toHexString(a));
          System.out.println(
          "Integer.toOctalString(a)="?+
          Integer.toOctalString(a));

          a?
          =?8;
          System.out.println(a);
          System.out.println(
          "Integer.toBinaryString(a)="?+
          Integer.toBinaryString(a));
          System.out.println(
          "Integer.toHexString(a)="?+?Integer.toHexString(a));
          System.out.println(
          "Integer.toOctalString(a)="?+
          Integer.toOctalString(a));

          int?b?=?1?|?2?|?4?|?8;
          System.out.println(
          "1?|?2?|?4?|?8?=?"?+?b);

          int?b1?=?4;
          System.out.println(b1?
          +?"?is?In?"?+?b?+?"???"?+?((b1?&?b)?==?b1)?);



          posted @ 2007-04-20 10:26 ideame 閱讀(866) | 評論 (0)編輯 收藏

          JVM參數優化

          來源: 網奇

          設置服務器端的 JVM:JAVA_OPTS="-server -Xms3000m -Xmx3000m -Xss512k"

          -server:一定要作為第一個參數,在多個CPU時性能佳

          -Xms:初始Heap大小,使用的最小內存

          -Xmx:java heap最大值,使用的最大內存

          上面兩個值一般設置為同樣的大小。

          -Xss:每個線程的Stack大小

          -verbose:gc 現實垃圾收集信息

          -Xloggc:gc.log 指定垃圾收集日志文件

          剛剛了解到的一些參數(待實踐測試)

          -Xmn:young generation的heap大小,一般設置為Xmx的3、4分之一

          -XX:+UseParNewGC :縮短minor收集的時間

          -XX:+UseConcMarkSweepGC :縮短major收集的時間

          提示:此選項在Heap Size 比較大而且Major收集時間較長的情況下使用更合適

          posted @ 2007-04-13 09:05 ideame 閱讀(4298) | 評論 (0)編輯 收藏

          SVN WEB 安裝:“mod_dav_svn.so is garbled”

          根據網上的一些資料,按照如下步驟

          1. 首先將Subversion安裝目錄bin\下面的兩個文件:mod_authz_svn.somod_dav_svn.so復制到Apache安裝目錄modules\目錄下。
          2. 找到Apache安裝目錄下的conf目錄,用文本編輯器打開httpd.conf,找到一下兩行:

            #LoadModule dav_module modules/mod_dav.so
            #LoadModule dav_fs_module modules/mod_dav_fs.so

            將每行前面的注釋符"#"去掉。再在所有LoadModule語句的最后添加一下幾行:

            #SVN
            LoadModule dav_svn_module modules/mod_dav_svn.so
            LoadModule authz_svn_module modules/mod_authz_svn.so
            <Location /svn>
            DAV svn
            SVNParentPath "E:/svnrepos"
            </Location>

          但是使用啟動測試一直有錯,返回

          Syntax error on line 143 of C:\apache\conf\httpd.conf: API module structure 'dav_svn_module' in file C:\apache\modules\mod_dav_svn.so is garbled - perhaps this is not an Apache module DSO?
          Apache could not be started


          后來再看資料,好像是SVN1.4.3提供的so文件只支持APACHE2.0,并不支持2.2版本的,除非重新編譯。好在已經有人解決了,下載了一個支持APACHE2.2的,但卻是SVN1.3.2的,死馬當活馬醫了,放到SVN1.4中居然也可以,hoho~~。我是把所有和SVN有關的文件(含動態連接庫文件)全部放在了APACHE安裝目錄的svn目錄里,配置文件如下:

          LoadModule dav_svn_module svn/mod_dav_svn_1.3.so
          LoadModule authz_svn_module svn/mod_authz_svn_1.3.so
          <Location /svn>
          DAV svn
          SVNParentPath "E:/svnrepos"
          </Location>

          Technorati :

          posted @ 2007-03-28 11:58 ideame 閱讀(7075) | 評論 (3)編輯 收藏

          DHTML的onScroll事件

               摘要:   閱讀全文

          posted @ 2007-03-25 02:32 ideame 閱讀(6045) | 評論 (0)編輯 收藏

          關于JavaBean和XML的轉換

          今天試了個XML和JavaBean轉換的軟件JOX,之前一直有這樣的需求,但比較來比較去還是這個比較簡單實用。我想除非我有WS的需求,否則象JIBX和APACHE 的WS工具對我來說都是重量級的。

          先看看輸出結果:

          ????????????
          ??
          <? xml?version="1.0"?encoding="ISO-8859-1" ?>
          ??
          < ApproxItem? java-class ="com.greatwall.csi.np.model.ApproxItem" >
          ??????
          < expose? java-class ="java.lang.Double" > 0.23 </ expose >
          ??????
          < list? java-class ="com.greatwall.csi.np.model.ApproxInfo" >
          ??????????
          < IDno > bbb </ IDno >
          ??????????
          < birth? java-class ="java.lang.Integer" > 222 </ birth >
          ??????
          </ list >
          ??????
          < map? java-class ="java.util.HashMap" >
          ??????????
          < dd? java-class ="com.greatwall.csi.np.model.ApproxInfo" >
          ??????????????
          < IDno > bbb </ IDno >
          ??????????????
          < birth? java-class ="java.lang.Integer" > 222 </ birth >
          ??????????
          </ dd >
          ??????????
          < ss? java-class ="com.greatwall.csi.np.model.ApproxInfo" >
          ??????????????
          < IDno > bbb </ IDno >
          ??????????????
          < birth? java-class ="java.lang.Integer" > 222 </ birth >
          ??????????
          </ ss >
          ??????
          </ map >
          ??????
          < month? java-class ="java.lang.Integer" > 3923 </ month >
          ??
          </ ApproxItem > ?

          在看看原來的JavaBean:

          ?? package ?com.greatwall.csi.np.model;

          ??
          import ?java.util.ArrayList;
          ??
          import ?java.util.HashMap;

          ??
          public ? class ?ApproxItem?{
          ??????
          public ? int ?getMonth()?{
          ??????????
          return ?month;
          ??????}

          ??????
          public ? void ?setMonth( int ?month)?{
          ??????????
          this .month? = ?month;
          ??????}

          ??????
          public ? double ?getExpose()?{
          ??????????
          return ?expose;
          ??????}

          ??????
          public ? void ?setExpose( double ?expose)?{
          ??????????
          this .expose? = ?expose;
          ??????}

          ??????
          public ?ArrayList?getList()?{
          ??????????
          return ?list;
          ??????}

          ??????
          public ?HashMap?getMap()?{

          ??????????
          return ?map;
          ??????}

          ??????
          public ? void ?setList(ArrayList?list)?{
          ??????????
          this .list? = ?list;
          ??????}

          ??????
          public ? void ?setMap(HashMap?map)?{
          ??????????
          this .map? = ?map;
          ??????}

          ??????
          private ? int ?month;
          ??????
          private ? double ?expose;
          ??????
          private ?ArrayList?list;
          ??????
          private ?HashMap?map;
          ??}

          處理結果是令人滿意的。實現過程如下:


          public ? class ?JOXUtils?{

          ????
          /**
          ?????*?Retrieves?a?bean?object?for?the
          ?????*?received?XML?and?matching?bean?class
          ?????
          */
          ????
          public ? static ?Object?fromXML(String?xml,?Class?className)?{
          ????????ByteArrayInputStream?xmlData?
          = ? new ?ByteArrayInputStream(xml.getBytes());
          ????????JOXBeanInputStream?joxIn?
          = ? new ?JOXBeanInputStream(xmlData);
          ????????
          try ?{
          ????????????
          return ?(Object)?joxIn.readObject(className);
          ????????}?
          catch ?(IOException?exc)?{
          ????????????exc.printStackTrace();
          ????????????
          return ? null ;
          ????????}
          ????????
          finally ?{
          ????????????
          try ?{
          ????????????????xmlData.close();
          ????????????????joxIn.close();
          ????????????}?
          catch ?(Exception?e)?{
          ????????????????e.printStackTrace();
          ????????????}
          ????????}
          ????}

          ????
          /**
          ?????*?Returns?an?XML?document?String?for?the?received?bean
          ?????
          */
          ????
          public ? static ?String?toXML(Object?bean)?{
          ????????ByteArrayOutputStream?xmlData?
          = ? new ?ByteArrayOutputStream();
          ????????JOXBeanOutputStream?joxOut?
          = ? new ?JOXBeanOutputStream(xmlData);
          ????????
          try ?{
          ????????????joxOut.writeObject(beanName(bean),?bean);
          ????????????
          return ?xmlData.toString();
          ????????}?
          catch ?(IOException?exc)?{
          ????????????exc.printStackTrace();
          ????????????
          return ? null ;
          ????????}
          ????????
          finally ?{
          ????????????
          try ?{
          ????????????????xmlData.close();
          ????????????????joxOut.close();
          ????????????}?
          catch ?(Exception?e)?{
          ????????????????e.printStackTrace();
          ????????????}
          ????????}
          ????}

          ????
          /**
          ?????*?Find?out?the?bean?class?name
          ?????
          */
          ????
          private ? static ?String?beanName(Object?bean)?{
          ????????String?fullClassName?
          = ?bean.getClass().getName();
          ????????String?classNameTemp?
          = ?fullClassName.substring(
          ????????????fullClassName.lastIndexOf(
          " . " )? + ? 1 ,
          ????????????fullClassName.length()
          ????????????);
          ????????
          return ?classNameTemp.substring( 0 ,? 1 )
          ????????????
          + ?classNameTemp.substring( 1 );
          ????}
          ????
          ????
          public ? static ? void ?main(String[]?args)?{
          ????????ApproxItem?approxItem?
          = ? new ?ApproxItem();
          ????????approxItem.setMonth(
          3923 );
          ????????approxItem.setExpose(
          0.23 );
          ????????approxItem.setMap(
          new ?HashMap());
          ????????ApproxInfo?approxInfo?
          = ? new ?ApproxInfo();
          ????????approxInfo.setBirth(
          111 );
          ????????approxInfo.setIDno(
          " aaa " );
          ????????approxItem.getMap().put(
          " ss " ,?approxInfo);
          ????????approxInfo.setBirth(
          222 );
          ????????approxInfo.setIDno(
          " bbb " );
          ????????approxItem.getMap().put(
          " dd " ,?approxInfo);
          ????????approxItem.setList(
          new ?ArrayList( 1 ));
          ????????approxItem.getList().add(approxInfo);
          ????????System.out.println(
          " JOXUtils.toXML(approxItem)= " );
          ???????System.out.println(JOXUtils.toXML(approxItem));
          ????}

          Wutka Consulting還提供了一個比較有趣的工具,Java2DTD,自從使用JDO做持久層框架,我就一直想找一個這樣的工具,因為JDO的映射文件并沒有將全部的JavaBean類描述到.jdo文件,所以在編程環境下一直無法獲取所有的實體類和字段的一個描述情況。廢話少說,馬上試一下。運行時需要3個包文件:beantodtd,需要轉換的實體classes,dtdparser。

          java?-cp?beantodtd-1.0;classes;d:/policy38/lib/dtdparser121.jar; BeanToDTD \n
          ?-
          mixed?com.greatwall.csi.bs.model.PersonBase

          -mixed參數是指定按JavaBean中的變量名生成屬性,還有些其它的參數,可以控制大小寫和連字符號等。另外由于我用的實體是JDO增強過的class文件,所以classpath還需要加上JDO實現的包。


          運行的結果有少少無奈,因為對于JavaBean中List這樣的容器字段類型,無法讓它識別出對象的類型,只能生成類似<!ELEMENT pension ANY>這樣的描述,如果在一個什么配置文件中可以設置的話那就更好了。

          另外還有一個DTD解析工具,可以解析DTD文件,目前還不知道有什么其它用途,使用如下方法可以解析后輸出控制臺:

          java?-classpath?d:/policy38/lib/dtdparser121.jar?com.wutka.dtd.Tokenize?code.dtd

          資源:

          http://www.wutka.com/download.html

          posted @ 2007-03-23 19:02 ideame 閱讀(6552) | 評論 (3)編輯 收藏

          jdk1.5編譯錯誤:varargs 方法的非 varargs 調用

          錯誤信息:

          警告: 最后一個參數使用了不準確的變量類型的 varargs 方法的非 varargs 調用;
          [javac] 對于 varargs 調用,應使用 java.lang.Object
          [javac] 對于非 varargs 調用,應使用 java.lang.Object[],這樣也可以抑制此警告

          程序是一樣的,在jdk1.4下可以編譯通過,但在1.5就不行。上網查了一下,解決辦法:

          ?Method?method? = ?cls.getMethod( " hashCode " ,? new ?Class[ 0 ]);? // ?編譯通過
          Method?method? = ?cls.getMethod( " hashCode " ,? null );? // ?編譯失敗

          allMethod[i].invoke(dbInstance,?
          new ?Object[]{});? // ?編譯通過
          allMethod[i].invoke(dbInstance,? null );? // ?編譯失敗



          posted @ 2007-03-23 15:10 ideame 閱讀(6205) | 評論 (0)編輯 收藏

          離線發布

          測試一下是否可以用離線工具zoundry。

          API地址: http://www.aygfsteel.com/ideame/services/metaweblog.aspx


          isOK。wonderful !

          posted @ 2007-03-23 14:45 ideame 閱讀(281) | 評論 (0)編輯 收藏

          僅列出標題
          共4頁: 上一頁 1 2 3 4 
          主站蜘蛛池模板: 德钦县| 桂阳县| 武邑县| 婺源县| 大冶市| 建瓯市| 塔城市| 通河县| 循化| 凭祥市| 沿河| 游戏| 顺义区| 历史| 广宗县| 峨山| 蒲城县| 葵青区| 拉孜县| 萨迦县| 阳朔县| 雅安市| 长丰县| 漠河县| 屏东市| 米泉市| 遂宁市| 互助| 祥云县| 兴城市| 镇康县| 达拉特旗| 夏河县| 界首市| 县级市| 和硕县| 鄂尔多斯市| 巴彦淖尔市| 新安县| 富顺县| 剑河县|