﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Skynet-随笔分类-javaGeneral</title><link>http://www.blogjava.net/Good-Game/category/26443.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 12 May 2008 08:33:25 GMT</lastBuildDate><pubDate>Mon, 12 May 2008 08:33:25 GMT</pubDate><ttl>60</ttl><item><title>java regex 正则部分高级特性使用</title><link>http://www.blogjava.net/Good-Game/archive/2008/05/04/197990.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Sun, 04 May 2008 01:59:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/05/04/197990.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/197990.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/05/04/197990.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/197990.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/197990.html</trackback:ping><description><![CDATA[这就不介绍了 代码上：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> unit;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.regex.Matcher;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.regex.Pattern;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.junit.Assert;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.junit.Test;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> RegexUnit {<br /><br /><br />    @Test<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * &lt;p&gt;向前\向后查找&lt;/p&gt;<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> unit9()</span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> Exception{<br />        String testStr </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">http://www.google.com</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />        <br />        </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 一般查找<br />         * .+(:) 查询出结果包含 :<br />         </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />        Pattern pattern </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">.+(:)</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);        <br />        Matcher matcher </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">  pattern.matcher(testStr);<br />            Assert.assertTrue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">错误： 查找出结果通过 .+(:) 此regex没有包含 : </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,<br />                    matcher.find() </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> matcher.group().equals(</span><span style="color: rgb(0, 0, 0);">"</span><b><font color="#0000ff"><span style="color: rgb(0, 0, 0);">http:</span></font></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) );<br />        <br />        </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">  向前查找<br />         *  .+(?=:) 查询结果不包含 :<br />         </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />        Pattern pattern2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">.+(?=:)</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        Matcher matcher2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pattern2.matcher(testStr);<br />            Assert.assertTrue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">错误： 查找出结果通过 .+(?=:) 此regex有包含 : </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,<br />                    matcher2.find()</span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> matcher2.group().equals(</span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">http</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br />        </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 向后查找<br />         * (?&lt;=:).+<br />         </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />        Pattern pattern3 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">(?&lt;=://).+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        Matcher matcher3 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pattern3.matcher(testStr);<br />            Assert.assertTrue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">错误：查找出结果包含 http:// 不向后查询</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,<br />                    matcher3.find()</span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> matcher3.group().equals(</span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">www.google.com</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) );<br />    }<br /><br /><br />    @Test<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"> 回朔应用 <br />     *  查询回朔、回朔替换、回朔大小写替换<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> unit8()</span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> Exception{<br />        String testStr </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">this is a block of of test,</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />                            </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> <b>several words here are are </b></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"><br />                            </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> <b>repeated , and and they should not be.</b> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />        <br />        Pattern pattern </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">[ ]+(\\w+)[ ]+\\1</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        Matcher matcher </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pattern.matcher(testStr);<br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">查询结果 <b>are are </b></span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        Assert.assertTrue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">错误：regex 不匹配 </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, <br />                matcher.find()</span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);">matcher.group().split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).length</span><span style="color: rgb(0, 0, 0);">&gt;=</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> );<br />        <br />        </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">( matcher.find() ){<br />            Assert.assertTrue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">错误：regex 不匹配 </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, <br />                    matcher.group().split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).length</span><span style="color: rgb(0, 0, 0);">&gt;=</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> );<br />        }<br />        <br />        <br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">替换</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        String testStr2s </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">313-555-1234</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />        Pattern pattern2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">(\\d{3})(-)(\\d{3})(-)(\\d{4})</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        Matcher mtmp </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">  pattern2.matcher(testStr2s);<br />        Assert.assertTrue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">错误：没有查替换</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,<br />                mtmp.find() </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> <br />                    mtmp.replaceAll(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">($1) $3-$5</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).equals(</span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">(313) 555-1234</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) );<br />        <br />        <br />        </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">大小写替换(java 不能成功)<br />         *  \E 结束 \L 或 \U转换<br />         *  \l  \L 把下一个字符(串)换为小写<br />         *  \ u  \U 把下一个字符(串)转换为大写 <br />         </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />        String testStr3 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><b><span style="color: rgb(0, 0, 0);">tt:google:xx</span></b><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />        Pattern pattern3 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">(?&lt;=:)(.+)(?=:)</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        Matcher matcher2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pattern3.matcher(testStr3);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( matcher2.find())<br />            System.out.println( matcher2.group() ) ;<br />    }<br />    <br />    <br />}<br /></span></div><br /><br /><br /><img src ="http://www.blogjava.net/Good-Game/aggbug/197990.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-05-04 09:59 <a href="http://www.blogjava.net/Good-Game/archive/2008/05/04/197990.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate 数据结构（ 树、多对多 结构表示 ）</title><link>http://www.blogjava.net/Good-Game/archive/2008/04/26/196293.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Sat, 26 Apr 2008 10:30:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/04/26/196293.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/196293.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/04/26/196293.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/196293.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/196293.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: level 类：Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->package hbm;import java.util.Set;/** * @hibernate.class table = "level" * where = " visible = ...&nbsp;&nbsp;<a href='http://www.blogjava.net/Good-Game/archive/2008/04/26/196293.html'>阅读全文</a><img src ="http://www.blogjava.net/Good-Game/aggbug/196293.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-04-26 18:30 <a href="http://www.blogjava.net/Good-Game/archive/2008/04/26/196293.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>权限设计的探讨阅读后感</title><link>http://www.blogjava.net/Good-Game/archive/2008/04/07/191376.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Mon, 07 Apr 2008 14:49:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/04/07/191376.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/191376.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/04/07/191376.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/191376.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/191376.html</trackback:ping><description><![CDATA[
		<p id="htie" align="center" goog_docs_charindex="1">
				<strong id="xz8e">
						<font id="aacz" size="5">    权限设计的探讨阅读后感</font>
				</strong>
		</p>
		<p id="iwal" align="center" goog_docs_charindex="1">
				<strong id="qm7f">    文章路径：<a id="n3dz" href="http://www.chinaitpower.com/A200508/2005-08-07/183934.html"><font color="#551a8b">http://www.chinaitpower.com/A200508/2005-08-07/183934.html<br /></font></a></strong>
		</p>
		<p id="r0vu" align="left" goog_docs_charindex="1">    <strong id="fohi"><font id="d-op" color="#073763">权限设计</font></strong>通常包括数据库设计、应用程序接口(API)设计、程序实现三个部分。</p>
		<p id="r3nr" align="left" goog_docs_charindex="1">    <strong id="w.bf"><font id="e2jr" color="#073763">权限分类：</font></strong></p>
		<p id="kvaw" align="left" goog_docs_charindex="1">        首先是<strong id="a-fu"><font id="fx9p" color="#000000">针对数据存取</font></strong>的权限，通常有录入、浏览、修改、删除四种。</p>
		<p id="h4bi" align="left" goog_docs_charindex="1">        其次是<strong id="obi3">功能</strong>，它可以包括例如统计等所有非直接数据存取操作，另外，我们还可能对一些关键数据表某些字段的存取进行限制。</p>
		<p id="uoaw" align="left" goog_docs_charindex="1"> </p>
		<p id="qt12" align="left" goog_docs_charindex="1"> </p>
		<p id="kiqc">权限表及相关内容大体可以用六个表来描述，如下： <br id="f:vt" />    1 <font id="m7-o" color="#660000"><strong id="vufz">拥有</strong><strong id="niv7">权限</strong></font><font id="dqei" color="#660000"><strong id="v13-">角色</strong></font>（即用户组）：具体<strong id="m2-j">拥有</strong>权限<strong id="g6tf">描述</strong>实体。</p>
		<p id="zrfy">    2 <strong id="at7h"><font id="h1zq" color="#660000">用户表</font></strong>：用户的描述，其它（如地址、电话等信息）； <br id="xst3" />    3 <strong id="cyqk"><font id="ij4q" color="#660000">角色-用户对应表</font></strong>：该表记录用户与角色之间的对应关系(<font id="nmsx" color="#660000">多对多关系</font>)，一个用户可以隶属于多个角色，一个角色组也可拥有多个用户。</p>
		<p id="k.px">    4 <strong id="t8.v"><font id="tup4" color="#660000">权限列表</font></strong>：程序<strong id="ohbe">所有</strong>权限列表。该表记录所有要加以控制的权限，如录入、修改、删除、执行等； <br id="garo" />    5 <strong id="u1ui"><font id="i00i" color="#660000">权限-角色-用户对应表</font></strong>：<strong id="ome4">权限</strong>对应<strong id="i0mi">角色</strong>(<font id="nmsx" color="#660000">多对多关系</font>)再由4表关系到<strong id="fl_2">用户</strong>。</p>
		<p id="iz:a"> </p>
		<p id="exir">
				<strong id="x2pu">
						<font id="gc1j" color="#6aa84f">在探讨文中的第4条，我怎么都不太理解？望大家探讨。反向权限吗？那怎么和系统中的拥有一起描述？</font>
				</strong>
		</p>
		<p id="ycb7"> </p>
		<p id="l8-y">
				<font id="vvel" color="#274e13">
						<strong id="forr">下面提出一些自己的见解：</strong>
				</font>
		</p>
		<p id="w769">
				<font id="hxx0" color="#274e13">
						<strong id="egjn">    </strong>
				</font>
				<font id="vz4o" color="#000000">1 用户表：用户的描述，其它（如地址、电话等信息）； </font>
		</p>
		<p id="q58-">
				<font id="pvhb" color="#000000">   2 权限列表：程序<strong id="n-8.">所有<font id="r7ps" color="#660000">权限</font></strong>列表。该表记录所有要加以控制的权限，如录入、修改、删除、执行等； <br id="xst3" />   3 权限树（模糊看成<strong id="wlsw">角色</strong>，但有些不同。树性结构，结构数据库中表外键自己）：孩子接点继承父亲接点全部权限，并在次上扩充和删减权限建立自己分支。</font>
		</p>
		<p id="lvyk">   4 权限列表-权限树：（多对多关系）用于描述此<strong id="mf:q"><font id="cum4" color="#990000">权限树接点</font></strong>对<font id="tu_b" color="#990000"><strong id="a_0.">父亲接点权限继承下</strong></font>，由<font id="whv." color="#990000"><strong id="sqre">自己添加和消减的权限</strong></font>；</p>
		<p id="g6_m">                                        本表中用一列枚举列用于表示本纪录是添加或删减权限。</p>
		<p id="x_rv">   5 用户-权限树：<strong id="ifkx">权限树接点</strong>对应<strong id="ycou">用户</strong>（多对一）关系。</p>
		<p id="yaqp">感觉自己的这种框架，能很好的扩充（在某接点下增，删某权限或直接找到<strong id="dwf0">最向近的一个权限树接点并继承</strong>）  </p>
		<p id="ur6l" align="right">
				<strong id="zg1o">大家多说说自己的见解，和对比下这两个框架的一些优缺点把。本人随时恭听。G_G</strong>
		</p>
		<p id="yxw." align="right">
				<strong id="rssr">与2008-4-7 22:50北京<br /></strong>
		</p>
		<p id="vs0-" align="right">google doc 原稿： <a class="tabcontent" id="publishedDocumentUrl" href="http://docs.google.com/Doc?id=dkvfctc_16hgvfkbfs" target="_blank">http://docs.google.com/Doc?id=dkvfctc_16hgvfkbfs</a></p>
		<p id="hfk_"> </p>
<img src ="http://www.blogjava.net/Good-Game/aggbug/191376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-04-07 22:49 <a href="http://www.blogjava.net/Good-Game/archive/2008/04/07/191376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>快速修改 xdoclet samples ant -build.xml 适应实际开发 </title><link>http://www.blogjava.net/Good-Game/archive/2008/03/26/188784.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Wed, 26 Mar 2008 08:29:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/03/26/188784.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/188784.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/03/26/188784.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/188784.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/188784.html</trackback:ping><description><![CDATA[目的：马上使用使用 xdoclet hibernate <br />使用：<a id="homepage1_HomePageDays_DaysList_ctl01_DayItem_DayList_ctl00_TitleUrl" href="/Good-Game/archive/2008/03/23/188055.html">xdoclet 2</a>            <br />            -&gt;   all jar  <br />            -&gt;   build.xml;build-dist.properties;maven.xml;project.properties;project.xml<br /><br />开始：<br />        1.在项目工程 根目录下建一文件夹：xdoclet 拷贝 *.xml 到此文件下<br />        2.在此目录下建 lib 并把 xdoclet  jar 放入 .<br />        3.修改 build.xml <br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);"> clean 改为 </span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">target </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="clean"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">delete </span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />            </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">fileset </span><span style="color: rgb(255, 0, 0);">dir</span><span style="color: rgb(0, 0, 255);">="${samples.dist.dir}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">include </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="**/*.hbm.xml"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />            </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">fileset</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">delete</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">&gt;<br /><br /></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);"> hibernatedoclet 改为 version 3.0 和 include **/*.java</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><br />        &lt;</span><span style="color: rgb(128, 0, 0);">hibernatedoclet </span><span style="color: rgb(255, 0, 0);"><img src="http://www.blogjava.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />            </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">fileset </span><span style="color: rgb(255, 0, 0);">dir</span><span style="color: rgb(0, 0, 255);">="${samples.java.dir}"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">include </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="**/*.java"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />            </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">fileset</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">hibernate </span><span style="color: rgb(255, 0, 0);">version</span><span style="color: rgb(0, 0, 255);">="3.0"</span><span style="color: rgb(0, 0, 255);">/&gt;</span></div><br /><font color="#0000ff">hbm2ddl&gt;&gt; http://blog.csdn.net/f1musicc/archive/2006/02/21/604699.aspx<br />eclipse-&gt;&gt;<br />    ant runtime home + classpath = 到本工程中的 classpath<br />    ant </font><font color="#0000ff">runtime </font><font color="#0000ff"> home + mysql jar ;<br />    ant </font><font color="#0000ff">runtime </font><font color="#0000ff"> home + commons-collection.jar<br /> <br /></font><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">target </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="hbm2ddl"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />          </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">mkdir </span><span style="color: rgb(255, 0, 0);">dir</span><span style="color: rgb(0, 0, 255);">="${hbm2ddl.sql.dir}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />          <br />          </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taskdef </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="hbm2ddl"</span><span style="color: rgb(255, 0, 0);"><br />             classname</span><span style="color: rgb(0, 0, 255);">="org.hibernate.tool.ant.HibernateToolTask"</span><span style="color: rgb(255, 0, 0);"> <br />              classpath</span><span style="color: rgb(0, 0, 255);">="E:\\test\\caijing\\WebRoot\\WEB-INF\\classes"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />        <br />          </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">hbm2ddl </span><span style="color: rgb(255, 0, 0);">destdir</span><span style="color: rgb(0, 0, 255);">="${hbm2ddl.sql.dir}"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                   </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">configuration </span><span style="color: rgb(255, 0, 0);">configurationfile</span><span style="color: rgb(0, 0, 255);">="../src/hibernate.cfg.xml"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />                   </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">hbm2ddl </span><span style="color: rgb(255, 0, 0);">export</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(255, 0, 0);"> console</span><span style="color: rgb(0, 0, 255);">="false"</span><span style="color: rgb(255, 0, 0);"> create</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(255, 0, 0);"> update</span><span style="color: rgb(0, 0, 255);">="false"</span><span style="color: rgb(255, 0, 0);"> drop</span><span style="color: rgb(0, 0, 255);">="false"</span><span style="color: rgb(255, 0, 0);"> outputfilename</span><span style="color: rgb(0, 0, 255);">="bestunix.sql"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />          </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">hbm2ddl</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br />        <br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br /><br /><br />-&gt;target-&gt;name=hibernate-&gt;hibernate version=3.0<br />4.修改 build-dist.properties-&gt; <br /><span style="color: rgb(0, 0, 0);">    samples.lib.dir</span><font color="#ff0000"><span style="color: rgb(0, 0, 0);"><font color="#006400">（指定工程jar）</font><br />    </span></font><span style="color: rgb(0, 0, 0);">samples.src.dir/</span><span style="color: rgb(0, 0, 0);">samples.java.dir</span><font color="#ff0000"><span style="color: rgb(0, 0, 0);"><font color="#006400">（代码所在）<br />    </font></span></font><span style="color: rgb(0, 0, 0);">samples.gen</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">src.dir </span><font color="#ff0000"><span style="color: rgb(0, 0, 0);"><font color="#006400">（映射生成地址）</font></span></font><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">        samples.dist.dir </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> ..\\src\\java\\questionnaire<br />        samples.lib.dir </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> ..\\lib  </span><font color="#ff0000"><span style="color: rgb(0, 0, 0);"></span></font><br /><span style="color: rgb(0, 0, 0);">        samples.src.dir </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> ..\\src\\java\\questionnaire<br />        samples.java.dir </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> ..\\src\\java\\questionnaire<br />        samples.gen</span><span style="color: rgb(128, 128, 128);">-</span><span style="color: rgb(0, 0, 0);">src.dir </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> ..\\src\\java\\questionnaire</span></div><br />加载到 eclipse 的 ant 中<br />调用这个 target 动起来了就这样。工作吧！<br /><br /><img src ="http://www.blogjava.net/Good-Game/aggbug/188784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-03-26 16:29 <a href="http://www.blogjava.net/Good-Game/archive/2008/03/26/188784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>xdoclet 2 </title><link>http://www.blogjava.net/Good-Game/archive/2008/03/23/188055.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Sun, 23 Mar 2008 10:38:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/03/23/188055.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/188055.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/03/23/188055.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/188055.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/188055.html</trackback:ping><description><![CDATA[XDoclet 2<br />   <span>all </span><span>XDoclet -&gt; </span><font color="#0000ff">http://xdoclet.sourceforge.net/xdoclet/install.html</font><br />   jar 下载： <a href="http://xdoclet.codehaus.org/">http://xdoclet.codehaus.org</a> <br />   eclipes 插件 xdoclet <a href="http://www.beust.com/doclipse/">http://www.beust.com/doclipse/<br /></a><br />XDoclet 1 一些工具<br />   <a href="http://xdoclet.sourceforge.net/xdoclet/tools.html">http://xdoclet.sourceforge.net/xdoclet/tools.html<br /></a><br />网上demo资料：<br />   <a href="/martinx/archive/2006/01/25/29197.html">http://www.blogjava.net/martinx/archive/2006/01/25/29197.html</a><br /><br />XDoclet 2 for Hibernate 3 <br />    <a href="http://www.hibernate.org/338.html">http://www.hibernate.org/338.html</a><br />    <font color="#0000ff">http://www.blogjava.net/martinx/archive/2006/01/25/29197.html</font><br /><br />XDoclet 2 Tags 说明<br />   <a href="http://xdoclet.codehaus.org/XDoclet+Plugins">http://xdoclet.codehaus.org/XDoclet+Plugins</a><br />XDoclet 1、2 对比<br />   <a href="http://bbmyth.javaeye.com/blog/31812">http://bbmyth.javaeye.com/blog/31812<br /></a><br /><br /><br />大家一起，XDoclet 2时代就要来到。我们大家一起跟上。<img src ="http://www.blogjava.net/Good-Game/aggbug/188055.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-03-23 18:38 <a href="http://www.blogjava.net/Good-Game/archive/2008/03/23/188055.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>扒网页数据（jdk+正则解析）</title><link>http://www.blogjava.net/Good-Game/archive/2008/03/09/184796.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Sun, 09 Mar 2008 02:46:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/03/09/184796.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/184796.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/03/09/184796.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/184796.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/184796.html</trackback:ping><description><![CDATA[数据扒出效果<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">双色球（</span><span style="color: rgb(0, 0, 0);">2008001</span><span style="color: rgb(0, 0, 0);">）</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">02</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">04</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">07</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">09</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">14</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">29</span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">03</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">双色球（</span><span style="color: rgb(0, 0, 0);">2008002</span><span style="color: rgb(0, 0, 0);">）</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">03</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">04</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">18</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">22</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">25</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">29</span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">09</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><img src="http://www.blogjava.net/images/dot.gif" />..</span><span style="color: rgb(0, 0, 0);"><br /></span></div><br />junit代码<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> test;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.InputStream;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.net.URL;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.net.URLConnection;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.regex.Matcher;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.regex.Pattern;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> junit.framework.TestCase;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> HttpConn </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> TestCase {<br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> testT() </span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> Exception {<br />        zq :<br />        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">2008001</span><span style="color: rgb(0, 0, 0);">;</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">){<br />            String num </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">  getQihao(i) ;<br />            System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">双色球（</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">）=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> num);<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(num</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">num.equals(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)) </span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);"> zq;<br />        }<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> String getQihao(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> qihao) </span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> Exception {<br />        URL url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> URL(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.cnlot.net/ssq/details.php?issue=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">qihao);<br />        URLConnection uconn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> url.openConnection();<br />        <br />        String num </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">;<br />        <br />        InputStream in </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> uconn.getInputStream();<br />        </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[] bs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[in.available()];<br />        in.read(bs);<br />        String date </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> String(bs) ;<br />        <br />        Pattern pa </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> .+color=red&gt;([0-9][0-9])&lt;.+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> );<br />        Matcher m </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pa.matcher(date);<br />        </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">( m.find() )<br />            num</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);"> m.group(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />        <br />         pa </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> .+color=blue&gt;([0-9][0-9])&lt;.+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> );<br />         m </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pa.matcher(date);<br />        </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">( m.find() )<br />            num </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> num.substring( </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,num.length()</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> )</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">#</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">m.group(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) ;<br />        <br />        pa </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Pattern.compile(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">^(([0-9][0-9],){5,}[0-9][0-9]#([0-9][0-9],)*[0-9][0-9]\\|)*(([0-9][0-9],){5,}[0-9][0-9]#([0-9][0-9],)*[0-9][0-9])*$</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        m </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">  pa.matcher(num);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( m.find() )<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> num ;<br />        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> <br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> ;<br />    }<br />}<br /></span></div><br /><br /><img src ="http://www.blogjava.net/Good-Game/aggbug/184796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-03-09 10:46 <a href="http://www.blogjava.net/Good-Game/archive/2008/03/09/184796.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jdk 时间触发器</title><link>http://www.blogjava.net/Good-Game/archive/2008/01/25/177688.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Fri, 25 Jan 2008 02:30:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/01/25/177688.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/177688.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/01/25/177688.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/177688.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/177688.html</trackback:ping><description><![CDATA[引用：http://blog.bcchinese.net/shiaohuazhang/archive/2005/02/16/10493.aspx <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">    timer </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Timer(</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br />    timer.schedule(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> RunTask(), </span><span style="color: rgb(0, 0, 0);">1000</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">60</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">1000</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">240</span><span style="color: rgb(0, 0, 0);">);<br /><br /><br /></span><span style="color: rgb(0, 128, 0);">////////////////////////////////////<br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> RunTask </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> TimerTask {<br />  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> run </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br />  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> RunTask() {<br />  }<br />  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> run() {<br />       <img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" />.<br />  }<br />  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> Logger logger </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Logger.getLogger(RunTask.</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">);<br />}<br /></span></div><br /><img src ="http://www.blogjava.net/Good-Game/aggbug/177688.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-01-25 10:30 <a href="http://www.blogjava.net/Good-Game/archive/2008/01/25/177688.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat 配置 jndi </title><link>http://www.blogjava.net/Good-Game/archive/2008/01/24/177485.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Thu, 24 Jan 2008 06:12:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/01/24/177485.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/177485.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/01/24/177485.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/177485.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/177485.html</trackback:ping><description><![CDATA[讨厌(370801149) 14:02:04
<globalnamingresources><resource name="jdbc ici" auth="Container" type="javax.sql.DataSource" driverclassname="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306 ici" username="root" password="123456" maxactive="100" maxidle="10" maxwait="-1" /></globalnamingresources>
☆づ(18246131) 14:02:45

web.xml,server.xml
讨厌(370801149) 14:02:57
server.xml
☆づ(18246131) 14:02:58
这两个地方，你都配置了吗？


讨厌(370801149) 14:03:01
en 
讨厌(370801149) 14:03:14
  <resource-ref><res-ref-name>jdbc ici</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth></resource-ref>
讨厌(370801149) 14:03:17
web.xml
讨厌(370801149) 14:03:28
<context docbase="kaici" path=" ici" reloadable="true" debug="0"><watchedresource>WEB-INF/web.xml</watchedresource><resourcelink name="jdbc ici" global="jdbc ici" type="javax.sql.DataSource" /></context>
讨厌(370801149) 14:03:33
context.xml<img src ="http://www.blogjava.net/Good-Game/aggbug/177485.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-01-24 14:12 <a href="http://www.blogjava.net/Good-Game/archive/2008/01/24/177485.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java,javascript 内连取数据</title><link>http://www.blogjava.net/Good-Game/archive/2008/01/09/173895.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Wed, 09 Jan 2008 01:46:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2008/01/09/173895.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/173895.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2008/01/09/173895.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/173895.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/173895.html</trackback:ping><description><![CDATA[java 内连<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">            <font color="#008000">//用 java jdk URL </font><br />            URL httpurl </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> URL(url);<br />            HttpURLConnection httpConn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />            httpConn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (HttpURLConnection) httpurl.openConnection();<br />            httpConn.setRequestMethod(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">POST</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />            httpConn.setDoOutput(</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br />            httpConn.setDoInput(</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br />              <font color="#006400">//</font></span><font color="#008000"><span style="color: rgb(0, 0, 0);"></span></font><span style="color: rgb(0, 0, 0);"><font color="#006400">正式连接</font><br />            httpConn.getOutputStream();<br />              <font color="#008000">/**输入参数<br />              PrintWriter outs = new PrintWriter(httpConn.getOutputStream());<br />            outs.print("&amp;back_url=" + returnurl);<br />            outs.print("&amp;orderid=" + deposit.getOrderId());<br />            outs.print("&amp;bussinessid=" + SZFConstant.B_ID);<br />            outs.print("&amp;digestString="<br />                    + MD5Util.MD5Encode(SZFConstant.B_ID + deposit.getOrderId()<br />                            + SZFConstant.KEY));<br />            outs.flush();<br />            outs.close();<br /><br />               GET 就不要 说 了  url + 参数<br />            */</font><br />            </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[] bb </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[httpConn.getInputStream().available()];<br />            httpConn.getInputStream().read(bb);<br />            <font color="#006400">//取得数据 </font><br />            String str </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> String(bb);</span></div><br />javascript 现在这种取法有个名字叫（ajax）(转)<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">link href</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.cc168.com.cn/css/index.css</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> rel</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">stylesheet</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/css</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">link rel</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">stylesheet</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> href</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.cc168.com.cn/css/framework.css</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/css</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">script language</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">javascript</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /> <br /> window.onload </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">()<br /> {<br />  CreateDateSelect();<br /> }<br /><br /> </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> xmlHttp </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> e;<br /> <br /> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">创建XMLHTTP对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> getXMLHTTPObj()<br /> {<br />  </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> C </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />  </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"><br />  {<br />     C </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ActiveXObject(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Msxml2.XMLHTTP</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />  }<br />  </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);">(e)<br />  {<br />   </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"><br />   {<br />    C </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ActiveXObject(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Microsoft.XMLHTTP</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />   }<br />   </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);">(sc)<br />   {<br />    C </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />   }<br />  }<br />  <br />  </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( </span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">C </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">typeof</span><span style="color: rgb(0, 0, 0);"> XMLHttpRequest </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">undefined</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> )<br />  {<br />   C </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XMLHttpRequest();<br />  }<br />  <br />  </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> C;<br /> }<br /> <br /> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">调用远程方法</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> callServer(e)<br /> { <br />  </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"><br />  {<br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( xmlHttp </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> xmlHttp .readyState </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> )<br />   {<br />    xmlHttp.abort();<br />   }<br />   <br />   xmlHttp </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getXMLHTTPObj();<br />   <br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( xmlHttp )<br />   {<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">outgroup</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).style.display </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">none</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">获取查询日期</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> dateSele </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> e.options[e.selectedIndex].value;<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">date</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> dateSele </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> 开放式基金净值</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /><br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">构造查询连接字符串</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">https://www.google.com/accounts/ManageAccount</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />    <br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">打开连接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(navigator.appName </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> 'Netscape'){<br />   </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />    netscape.security.PrivilegeManager.enablePrivilege(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">UniversalBrowserRead</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />   } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (e) {<br />       alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Permission UniversalBrowserRead denied.</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />   }}<br />    xmlHttp.open(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">GET</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, url, </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">设置回调函数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    xmlHttp.onreadystatechange </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> updatePage;<br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">发送请求</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    xmlHttp.send(</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">);<br />   }<br />   </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br />   {<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">flag</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">XMLHTTP对象创建失败</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />   }<br />  }<br />  </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (e)<br />  {<br />   document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">flag</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">查询错误:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> e;<br />  }<br /> }<br /> <br /> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回调处理函数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> updatePage()<br /> {<br />  </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (xmlHttp.readyState </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)<br />   {<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">flag</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">正在加载连接对象<img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />   }<br /><br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (xmlHttp.readyState </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)<br />   {<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">flag</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">连接对象加载完毕。</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />   }<br /><br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (xmlHttp.readyState </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">)<br />   {<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">flag</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">数据获取中<img src="http://www.blogjava.net/images/dot.gif" /><img src="http://www.blogjava.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />   }<br /><br />   </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (xmlHttp.readyState </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">)<br />   {<br />    </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> response </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> xmlHttp.responseText;<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">out</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> response;<br />    document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">outgroup</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).style.display </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">;<br />   }<br />  }<br />  </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (e)<br />  {<br />      document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">flag</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">回调处理错误:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> e;<br />  }<br /> }<br /><br /> </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">创建日期选择下拉框</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);"> CreateDateSelect()<br /> {<br /><br />  </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> html </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> [];<br />         <br />  </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> iYear</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">2005</span><span style="color: rgb(0, 0, 0);">; iYear</span><span style="color: rgb(0, 0, 0);">&lt;=</span><span style="color: rgb(0, 0, 0);">2006</span><span style="color: rgb(0, 0, 0);">; iYear </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)<br />  {<br />   </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">( </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> iMonth</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">; iMonth</span><span style="color: rgb(0, 0, 0);">&lt;=</span><span style="color: rgb(0, 0, 0);">12</span><span style="color: rgb(0, 0, 0);">; iMonth </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);"> )<br />   {<br />    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">( </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> iDay</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">; iDay</span><span style="color: rgb(0, 0, 0);">&lt;=</span><span style="color: rgb(0, 0, 0);">31</span><span style="color: rgb(0, 0, 0);">; iDay </span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);"> )<br />    { <br />    html[html.length] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;option value=\</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">  + iYear + </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> + iMonth + </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> + iDay + </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> iYear </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">年</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> iMonth </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">月</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> iDay </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">日</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;/option&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />    }<br />   }<br />  }<br />      <br />  document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">dateSele</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).innerHTML </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;select name=\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">dateSele\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> id=\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">dateSele\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> onchange=\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">callServer(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">);\</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> html.join(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;/select&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /> } <br /> </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">script</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"><br /></span></div><br /><img src ="http://www.blogjava.net/Good-Game/aggbug/173895.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2008-01-09 09:46 <a href="http://www.blogjava.net/Good-Game/archive/2008/01/09/173895.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>xdoclet 代码生成</title><link>http://www.blogjava.net/Good-Game/archive/2007/12/24/170123.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Mon, 24 Dec 2007 09:54:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2007/12/24/170123.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/170123.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2007/12/24/170123.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/170123.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/170123.html</trackback:ping><description><![CDATA[学习xdoclet 发现是很有用的。易于规范，使用方便；<br /><font color="#0000ff"><font color="#000000">参考：</font> http://blog.easyjf.com/html/blog/20061127/3290288676803397.htm<br /></font>官方完整API： <a href="http://xdoclet.sourceforge.net/xdoclet/templates/index.html">Template Language (*.xdt)</a><br /><br />因为参考中：是还是比较复杂的例（数本人愚钝^_^）特留一文：<br />1&gt;ant编辑文件 <br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml version="1.0" encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">project </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="xdocletExample"</span><span style="color: rgb(255, 0, 0);"> default</span><span style="color: rgb(0, 0, 255);">="doall"</span><span style="color: rgb(255, 0, 0);"> basedir</span><span style="color: rgb(0, 0, 255);">="."</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="basedir"</span><span style="color: rgb(255, 0, 0);"> location</span><span style="color: rgb(0, 0, 255);">="E:\ue_test\xdoclet"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="xdoclet.lib.dir"</span><span style="color: rgb(255, 0, 0);"> location</span><span style="color: rgb(0, 0, 255);">="D:\hbn\hibernate-3.2\xdoclet-1.2.3\lib"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="gen.src.dir"</span><span style="color: rgb(255, 0, 0);"> location</span><span style="color: rgb(0, 0, 255);">="${basedir}/target"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="src.dir"</span><span style="color: rgb(255, 0, 0);"> location</span><span style="color: rgb(0, 0, 255);">="${basedir}/src"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="template.dir"</span><span style="color: rgb(255, 0, 0);"> location</span><span style="color: rgb(0, 0, 255);">="${basedir}/template"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="customtag.dir"</span><span style="color: rgb(255, 0, 0);"> location</span><span style="color: rgb(0, 0, 255);">="${basedir}/bin"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">path </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="xdoclet.lib.path"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />       </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">fileset </span><span style="color: rgb(255, 0, 0);">dir</span><span style="color: rgb(0, 0, 255);">="${xdoclet.lib.dir}"</span><span style="color: rgb(255, 0, 0);"> includes</span><span style="color: rgb(0, 0, 255);">="*.jar"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">path</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taskdef </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="xdoclet"</span><span style="color: rgb(255, 0, 0);"> classname</span><span style="color: rgb(0, 0, 255);">="xdoclet.DocletTask"</span><span style="color: rgb(255, 0, 0);"> classpathref</span><span style="color: rgb(0, 0, 255);">="xdoclet.lib.path"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">   <br /><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">target </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="init"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">target </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="daogener"</span><span style="color: rgb(255, 0, 0);"> depends</span><span style="color: rgb(0, 0, 255);">="init"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />       </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">xdoclet </span><span style="color: rgb(255, 0, 0);">destdir</span><span style="color: rgb(0, 0, 255);">="${gen.src.dir}"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />           </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">fileset </span><span style="color: rgb(255, 0, 0);">dir</span><span style="color: rgb(0, 0, 255);">="${src.dir}"</span><span style="color: rgb(255, 0, 0);"> includes</span><span style="color: rgb(0, 0, 255);">="${cjava.file}"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />           </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">template </span><span style="color: rgb(255, 0, 0);">templateFile</span><span style="color: rgb(0, 0, 255);">="${xdt.file}"</span><span style="color: rgb(255, 0, 0);"> acceptInterfaces</span><span style="color: rgb(0, 0, 255);">="false"</span><span style="color: rgb(255, 0, 0);"> acceptAbstractClasses</span><span style="color: rgb(0, 0, 255);">="false"</span><span style="color: rgb(255, 0, 0);"> destinationfile</span><span style="color: rgb(0, 0, 255);">="{0}DAO.java"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />       </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">xdoclet</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">target </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="doall"</span><span style="color: rgb(255, 0, 0);"> depends</span><span style="color: rgb(0, 0, 255);">="daogener,daoimplgener"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">project</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br />在运行上面文件时候动态输入参数<br /> 1.依照的 .java 文件（ cjava.file ）；<br /> 2.依照的 .xdt.file 文件（ xdt.file ）；<br /><br />比如DOS中输入：<br /><b><font color="#a52a2a">E:\ue_test\xdoclet&gt;ant daogener <br />-Dxdt.file=template\daointerface.xdt <br />-Dcjava.file=test\TestXDoclet.java<br /><br /></font></b><font color="#a52a2a"><font color="#000000">2.参考的java文件（简单过头了 呵呵）<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> test;<br />  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />  * @hasRef<br />  </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> TestXDoclet{<br />    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * @ref.model name="sytp"<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> PubSystype sytp;<br /></span><span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> String gg;<br />}</span></div><br />3.xdt 模板 <br />  标签解释：<br /></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">  </span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:ifHasClassTag </span><span style="color: rgb(255, 0, 0);">tagName</span><span style="color: rgb(0, 0, 255);">="hasRef"</span><span style="color: rgb(0, 0, 255);">&gt;</span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 255);"><b><font color="#ffa500">判断 java文件中有 </font></b></span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 128, 0);"><b><font color="#ffa500">@hasRef</font></b><br />  </span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtField:forAllFields</span><span style="color: rgb(0, 0, 255);">&gt;  <b><font color="#ffa500">1&gt; 循环查找</font></b></span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 255);"><br />  <br /></span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 255);"></span><span style="color: rgb(0, 0, 0);">  <b><font color="#ffa500">2&gt;判断有</font></b></span></font></font></font></font><b><font color="#ffa500"><font><span style="color: rgb(0, 128, 0);">@ref.model name=。。</span></font></font></b><br /><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 255);">  &lt;</span><span style="color: rgb(128, 0, 0);">XDtField:ifHasFieldTag </span><span style="color: rgb(255, 0, 0);">tagName</span><span style="color: rgb(0, 0, 255);">="ref.model"</span><span style="color: rgb(255, 0, 0);"> paramName</span><span style="color: rgb(0, 0, 255);">="name"</span><span style="color: rgb(0, 0, 255);">&gt;<br />  <br />  <font color="#ffa500"><b>3&gt;取值</b></font><br />  </span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtField:fieldTagValue </span><span style="color: rgb(255, 0, 0);">tagName</span><span style="color: rgb(0, 0, 255);">="ref.model"</span><span style="color: rgb(255, 0, 0);"> paramName</span><span style="color: rgb(0, 0, 255);">="name"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 0, 255);">    <br /><br /></span></font></font></font></font><font><font><font color="#a52a2a"><font color="#000000"><span style="color: rgb(0, 128, 0);"></span></font></font></font></font><font color="#a52a2a"><font color="#000000"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">package com.hycs.bs.client.itf;<br /><br />import java.util.List;<br /><br /><font color="#006400">//这是 packageName.className 这和好理解</font><br />import </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtPackage:packageName </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:className </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">;<br /><br />public interface </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:className </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">DAO {<br /><br />    <font color="#006400">//添加</font><br />    boolean add(</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:className </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"> instance);<br />    <br />    <font color="#006400">//逻辑添加</font><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:ifHasClassTag </span><span style="color: rgb(255, 0, 0);">tagName</span><span style="color: rgb(0, 0, 255);">="hasRef"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        boolean add(</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:className </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"> instance,<br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtField:forAllFields</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtField:ifHasFieldTag </span><span style="color: rgb(255, 0, 0);">tagName</span><span style="color: rgb(0, 0, 255);">="ref.model"</span><span style="color: rgb(255, 0, 0);"> paramName</span><span style="color: rgb(0, 0, 255);">="name"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br />                        String </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtField:fieldTagValue </span><span style="color: rgb(255, 0, 0);">tagName</span><span style="color: rgb(0, 0, 255);">="ref.model"</span><span style="color: rgb(255, 0, 0);"> paramName</span><span style="color: rgb(0, 0, 255);">="name"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />                    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">XDtField:ifHasFieldTag</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">XDtField:forAllFields</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">);  <br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">XDtClass:ifHasClassTag</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />    <font color="#006400">//更新</font><br />    boolean update(</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:className </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"> instance);<br /><br /><br />   <font color="#006400"> //得到一个对象</font><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">XDtClass:className </span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"> get(String pkid);<br />}<br /></span></div><br /><font color="#ffa500"><font color="#000000">运行DOS-&gt;</font><b><br /></b></font></font></font><b><font color="#a52a2a">E:\ue_test\xdoclet&gt;ant daogener <br />-Dxdt.file=template\daointerface.xdt <br />-Dcjava.file=test\TestXDoclet.java<br /><br /></font></b><font color="#a52a2a"><font color="#000000">得到的代码：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> com.hycs.bs.client.itf;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.List;<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">这是 packageName.className 这和好理解</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> test.TestXDoclet;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">interface</span><span style="color: rgb(0, 0, 0);"> TestXDocletDAO {<br /><br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">添加</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> add(TestXDoclet instance);<br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">逻辑添加</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> add(TestXDoclet instance,String sytp);  <br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">更新</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> update(TestXDoclet instance);<br /><br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">得到一个对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    TestXDoclet get(String pkid);<br />}<br /></span></div><br /></font></font><font color="#a52a2a"><font color="#000000"><br /><br /></font></font><br /><br /><br /><img src ="http://www.blogjava.net/Good-Game/aggbug/170123.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2007-12-24 17:54 <a href="http://www.blogjava.net/Good-Game/archive/2007/12/24/170123.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>序列化和反序列化对象到 数据库</title><link>http://www.blogjava.net/Good-Game/archive/2007/11/29/164051.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Thu, 29 Nov 2007 09:35:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2007/11/29/164051.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/164051.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2007/11/29/164051.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/164051.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/164051.html</trackback:ping><description><![CDATA[
		<br />
		<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">
				<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
				<span style="color: rgb(0, 0, 0);">    </span>
				<span style="color: rgb(0, 128, 0);">/*</span>
				<span style="color: rgb(0, 128, 0);">
						<br />     * 将对象转化成java.sql.Blob <br />     * 要求 对象是序列化的<br />     </span>
				<span style="color: rgb(0, 128, 0);">*/</span>
				<span style="color: rgb(0, 0, 0);">
						<br />    </span>
				<span style="color: rgb(0, 0, 255);">public</span>
				<span style="color: rgb(0, 0, 0);"> java.sql.Blob ObjectToBlob(Object obj) </span>
				<span style="color: rgb(0, 0, 255);">throws</span>
				<span style="color: rgb(0, 0, 0);"> IOException{<br />        </span>
				<span style="color: rgb(0, 0, 255);">try</span>
				<span style="color: rgb(0, 0, 0);"> {<br />            ByteArrayOutputStream out </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">new</span>
				<span style="color: rgb(0, 0, 0);"> ByteArrayOutputStream();<br />            ObjectOutputStream outputStream </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">new</span>
				<span style="color: rgb(0, 0, 0);"> ObjectOutputStream(out);<br />            outputStream.writeObject(obj);<br />            </span>
				<span style="color: rgb(0, 0, 255);">byte</span>
				<span style="color: rgb(0, 0, 0);">[] bytes </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> out.toByteArray();<br />            outputStream.close();<br />            </span>
				<span style="color: rgb(0, 0, 255);">return</span>
				<span style="color: rgb(0, 0, 0);"> Hibernate.createBlob(bytes);<br />        } </span>
				<span style="color: rgb(0, 0, 255);">catch</span>
				<span style="color: rgb(0, 0, 0);"> (Exception e) {<br />            </span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);"> TODO: handle exception</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">            System.out.println(</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">ObjectToBlob</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">);<br />            </span>
				<span style="color: rgb(0, 0, 255);">return</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">null</span>
				<span style="color: rgb(0, 0, 0);">;<br />        }        <br />    }<br />    <br />    <br />    </span>
				<span style="color: rgb(0, 128, 0);">/*</span>
				<span style="color: rgb(0, 128, 0);">
						<br />     * 将java.sql.Blob 转化成 对象 相应对象<br />     * 要求 对象是序列化的<br />     </span>
				<span style="color: rgb(0, 128, 0);">*/</span>
				<span style="color: rgb(0, 0, 0);">    <br />    </span>
				<span style="color: rgb(0, 0, 255);">public</span>
				<span style="color: rgb(0, 0, 0);"> Object BlobToObject(java.sql.Blob desblob,Object obj) </span>
				<span style="color: rgb(0, 0, 255);">throws</span>
				<span style="color: rgb(0, 0, 0);"> IOException{<br />        </span>
				<span style="color: rgb(0, 0, 255);">try</span>
				<span style="color: rgb(0, 0, 0);"> {<br />            ObjectInputStream in </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">new</span>
				<span style="color: rgb(0, 0, 0);"> ObjectInputStream(desblob.getBinaryStream());<br />            obj </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);">  in.readObject();<br />            in.close();    <br />            </span>
				<span style="color: rgb(0, 0, 255);">return</span>
				<span style="color: rgb(0, 0, 0);"> obj;<br />        } </span>
				<span style="color: rgb(0, 0, 255);">catch</span>
				<span style="color: rgb(0, 0, 0);"> (Exception e) {<br />            </span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);"> TODO: handle exception</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">            System.out.println(</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">BlobToObject</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">);<br />            e.printStackTrace();<br />            </span>
				<span style="color: rgb(0, 0, 255);">return</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">null</span>
				<span style="color: rgb(0, 0, 0);">;<br />        }        <br />    }    <br />    <br />    <br /></span>
		</div>
		<br />
		<br />
<img src ="http://www.blogjava.net/Good-Game/aggbug/164051.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2007-11-29 17:35 <a href="http://www.blogjava.net/Good-Game/archive/2007/11/29/164051.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java基础</title><link>http://www.blogjava.net/Good-Game/archive/2007/10/22/155070.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Mon, 22 Oct 2007 10:34:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2007/10/22/155070.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/155070.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2007/10/22/155070.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/155070.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/155070.html</trackback:ping><description><![CDATA[1. <span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">接口里面的属性在默认状态下面都是</span><span style="font-size: 9pt;" lang="EN-US">public static<br /><br />2.     </span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">被声明为</span><span style="font-size: 9pt;" lang="EN-US">final</span><span style="font-size: 9pt; font-family: 宋体;">的变量必须在声明时给定初值，而在以后的引用中只能读取，不可修改。<br /><br /><br />3.   </span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">匿名的内部类是没有名字的内部类。不能</span><span style="font-size: 9pt;" lang="EN-US">extends(</span><span style="font-size: 9pt; font-family: 宋体;">继承</span><span style="font-size: 9pt;" lang="EN-US">) </span><span style="font-size: 9pt; font-family: 宋体;">其它类，但一个内部类可以作为一个接口，由另一个内部类实现。<br /><br /><br />4.  </span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt;"></span><span style="font-size: 9pt; font-family: 宋体;">静态内部类（</span><span style="font-size: 9pt;" lang="EN-US">Inner Class</span><span style="font-size: 9pt; font-family: 宋体;">）写成这样才可以 在内部 new 出 ： <font color="#0000ff">static final public class</font> XXXxx<br />              </span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;"></span><span style="font-size: 9pt;" lang="EN-US">1</span><span style="font-size: 9pt; font-family: 宋体;">.创建一个</span><span style="font-size: 9pt;" lang="EN-US">static</span><span style="font-size: 9pt; font-family: 宋体;">内部类的对象，不需要一个外部类对象<br />           <b></b></span><b><span style="font-size: 9pt;" lang="EN-US">2</span><span style="font-size: 9pt; font-family: 宋体;">不能从一个</span><span style="font-size: 9pt;" lang="EN-US">static</span><span style="font-size: 9pt; font-family: 宋体;">内部类的一个对象访问一个外部类对象<br /><br />5. <br /></span></b></span><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; font-family: 宋体;"></span><span style="font-size: 9pt;" lang="EN-US">        HashMap </span><span style="font-size: 9pt; font-family: 宋体;">类没有分类或者排序。它允许一个</span><span style="font-size: 9pt;" lang="EN-US"> null </span><span style="font-size: 9pt; font-family: 宋体;">键和多个</span><span style="font-size: 9pt;" lang="EN-US"> null </span><span style="font-size: 9pt; font-family: 宋体;">值。</span><span style="font-size: 9pt;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; font-family: 宋体;">　　</span><span style="font-size: 9pt;" lang="EN-US">Hashtable </span><span style="font-size: 9pt; font-family: 宋体;">类似于</span><span style="font-size: 9pt;" lang="EN-US"> HashMap</span><span style="font-size: 9pt; font-family: 宋体;">，但是不允许</span><span style="font-size: 9pt;" lang="EN-US"> null </span><span style="font-size: 9pt; font-family: 宋体;">键和</span><span style="font-size: 9pt;" lang="EN-US"> null </span><span style="font-size: 9pt; font-family: 宋体;">值。它也比</span><span style="font-size: 9pt;" lang="EN-US"> HashMap </span><span style="font-size: 9pt; font-family: 宋体;">慢，因为它是同步的。</span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br /><span style="font-size: 9pt; font-family: 宋体;"></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; font-family: 宋体;">6. GC</span><br /></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt;" lang="EN-US">        System.gc() <o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt;" lang="EN-US">        Runtime.getRuntime().gc() <br /></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt;" lang="EN-US"><br /></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt;" lang="EN-US">7</span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">.重写</span><span style="font-size: 9pt;" lang="EN-US">Overriding</span><span style="font-size: 9pt; font-family: 宋体;">和重载</span><span style="font-size: 9pt;" lang="EN-US">Overloading</span><span style="font-size: 9pt; font-family: 宋体;"></span></span><br /><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">    如果在子类中定义某方法与其父类有相同的名称和参数，我们说该方法被重写</span><span style="font-size: 9pt;" lang="EN-US"> (Overriding)</span><span style="font-size: 9pt; font-family: 宋体;">。</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">    </span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">如果在一个类中定义了多个同名的方法，它们或有不同的参数个数或有不同的参数类型，则称为方法的重载</span><span style="font-size: 9pt;" lang="EN-US">(Overloading)</span><span style="font-size: 9pt; font-family: 宋体;">。</span><span style="font-size: 9pt;" lang="EN-US">Overloaded</span><span style="font-size: 9pt; font-family: 宋体;">的方法是可以改变返回值的类型。</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br /><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;"></span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">8.</span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">抽象类是否可继承实体类</span><span style="font-size: 9pt;" lang="EN-US">(concrete class)</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt;" lang="EN-US">            </span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">抽象类是否可继承实体类，但前提是实体类必须有明确的构造函数</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br /><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;"></span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;">9.</span></span><span style="font-size: 9pt;" lang="EN-US">try {}</span><span style="font-size: 9pt; font-family: 宋体;">里有一个</span><span style="font-size: 9pt;" lang="EN-US">return</span><span style="font-size: 9pt; font-family: 宋体;">语句，那么紧跟在这个</span><span style="font-size: 9pt;" lang="EN-US">try</span><span style="font-size: 9pt; font-family: 宋体;">后的</span><span style="font-size: 9pt;" lang="EN-US">finally {}</span><span style="font-size: 9pt; font-family: 宋体;">里的</span><span style="font-size: 9pt;" lang="EN-US">code</span><span style="font-size: 9pt; font-family: 宋体;">会不会被执行，什么时候被执行，在</span><span style="font-size: 9pt;" lang="EN-US">return</span><span style="font-size: 9pt; font-family: 宋体;">前还是后</span><span style="font-size: 9pt;" lang="EN-US">? <o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; font-family: 宋体;">　　会执行，在</span><span style="font-size: 9pt;" lang="EN-US">return</span><span style="font-size: 9pt; font-family: 宋体;">前执行。</span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt;" lang="EN-US">        <br /></span></span></p><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;"></span><span style="font-size: 9pt; font-family: 宋体;">10.</span></span><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;"></span><span style="font-size: 9pt;" lang="EN-US">switch</span><span style="font-size: 9pt; font-family: 宋体;">（</span><span style="font-size: 9pt;" lang="EN-US">expr1</span><span style="font-size: 9pt; font-family: 宋体;">）中，</span><span style="font-size: 9pt;" lang="EN-US">expr1</span><span style="font-size: 9pt; font-family: 宋体;">是一个整数表达式。因此传递给</span><span style="font-size: 9pt;" lang="EN-US"> switch </span><span style="font-size: 9pt; font-family: 宋体;">和</span><span style="font-size: 9pt;" lang="EN-US"> case </span><span style="font-size: 9pt; font-family: 宋体;">语句的参数应该是</span><span style="font-size: 9pt;" lang="EN-US"> int</span><span style="font-size: 9pt; font-family: 宋体;">、</span><span style="font-size: 9pt;" lang="EN-US"> short</span><span style="font-size: 9pt; font-family: 宋体;">、</span><span style="font-size: 9pt;" lang="EN-US"> char </span><span style="font-size: 9pt; font-family: 宋体;">或者</span><span style="font-size: 9pt;" lang="EN-US"> byte</span><span style="font-size: 9pt; font-family: 宋体;">。</span><span style="font-size: 9pt;" lang="EN-US">long,string </span><span style="font-size: 9pt; font-family: 宋体;">都不能作用于</span><span style="font-size: 9pt;" lang="EN-US">swtich</span><span style="font-size: 9pt; font-family: 宋体;">。</span></span><br /><span id="ArticleContent1_ArticleContent1_lblContent"><span style="font-size: 9pt; font-family: 宋体;"><br /><br /></span></span><img src ="http://www.blogjava.net/Good-Game/aggbug/155070.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2007-10-22 18:34 <a href="http://www.blogjava.net/Good-Game/archive/2007/10/22/155070.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>eclipes javadoc 使用 </title><link>http://www.blogjava.net/Good-Game/archive/2007/10/22/155033.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Mon, 22 Oct 2007 08:47:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2007/10/22/155033.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/155033.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2007/10/22/155033.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/155033.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/155033.html</trackback:ping><description><![CDATA[1。项目中 -&gt;Exprot.. -&gt; @javadoc 就可以了<br />2。javadoc 命令学习<br />    @author 作者<br />    <span id="zoom" class="a14c">@see </span>另请参见<br />        （1）、@see "string" 为"string"添加文本项，不产生链接。<br />        （2）、@see &lt;a href="URL#Value"&gt;Label&lt;/a&gt; 使用HTML标记产生链接<br />        （3）、@see package.class#member Label 使用Java语言的名字package.class #member产生链接。
<p style="text-indent: 2em;">@version 版<br />    @since 从以下版本开<br />    @param 参数说明<br /></p><p style="text-indent: 2em;">/** */中的开头是注解 <br /></p><dl><dt>   /** <br />   */  的就近原则 在那个上面就为那个注解</dt></dl><br />参照：http://java.ccidnet.com/art/3743/20031203/519697_1.html<br /><br />/** class description<br />*/
<p style="text-indent: 2em;"><br />3、Variable Description:描述变量的意义和取值含义。<br />	   /** var variable description<br />*/<br /><br />4、Method Description:标明每个方法的输入、输出参数和返回值类型，说明特殊变量取值的含义。相关类文档链接。<br /><br />		/** method description<br />		* @param 			var 				signification <b><font color="#0000ff">方法参数说明</font></b><br />		* @exception    		exception 		class name <b><font color="#0000ff">throws 说明</font></b><br />		* @return 		return_value 		return signification<font color="#0000ff"><b> return 说明</b></font><br />		*/<br /><br />5、Association Description:关联类文档描述，在注释当中需要参引其它文档描述的地方，可在相应的注释当中如下插入：<br />		/** method description<br /><br />		* @param 			var 					signification<br />		* @exception 		exception 			class name<br />		* @return 		return_value 			return signification<br />		* @see 			package.class#member	label<br />*/<br /><br />6、包描述文件：概括描述包的功能和设计概要。为每个包创建一个描述文件，命名为package.html，与包的java文件放在一起。
</p><p style="text-indent: 2em;"><br /></p><br /><dl><dt>    <br /></dt></dl><dl><dt><br /></dt></dl><img src ="http://www.blogjava.net/Good-Game/aggbug/155033.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2007-10-22 16:47 <a href="http://www.blogjava.net/Good-Game/archive/2007/10/22/155033.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>重构 eclips 快键</title><link>http://www.blogjava.net/Good-Game/archive/2007/10/15/152890.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Mon, 15 Oct 2007 02:21:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2007/10/15/152890.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/152890.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2007/10/15/152890.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/152890.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/152890.html</trackback:ping><description><![CDATA[下面 ( alt+shift+T ) 中都可以找到 <br />1.改名 :  ( alt+shift+R )<br />2.类移动:( alt+shift+V )<br />3.方法上移父类,下移子类 (alt+shift+T) + U/D<br />4.方法接口化  (alt+shift+T) +T<br />5.部分代码提升为方法 alt+shift+M<br />6.局部变量提升为类变量 alt+shift+F<br /><br />.............<br /><br />***************************************************************<br /><br />Ctrl+M:   工作区最大化/最小化   <br />   Alt+/:      智能提示   <br />   F3:               察看声明   <br />   Crtl+1:   修正错误   <br />      <br />   Shift+Alt+T:   重构   <br />   Shift+Alt+M:   提取函数   <br />   Shift+Alt+R:   重命名   <br />   Shift+Alt+C:   更改函数标记   <br />      <br />   Ctrl+Shitf+F:   格式化代码   <br /><img src ="http://www.blogjava.net/Good-Game/aggbug/152890.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2007-10-15 10:21 <a href="http://www.blogjava.net/Good-Game/archive/2007/10/15/152890.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java 文件加载  (参考 Hibernate 源码 ) </title><link>http://www.blogjava.net/Good-Game/archive/2007/10/10/151745.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Wed, 10 Oct 2007 06:50:00 GMT</pubDate><guid>http://www.blogjava.net/Good-Game/archive/2007/10/10/151745.html</guid><wfw:comment>http://www.blogjava.net/Good-Game/comments/151745.html</wfw:comment><comments>http://www.blogjava.net/Good-Game/archive/2007/10/10/151745.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/Good-Game/comments/commentRss/151745.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Good-Game/services/trackbacks/151745.html</trackback:ping><description><![CDATA[在WEB开发中<br />测试 在 C/S  而 实际运行 B/S 造成配置文件 在硬编码时总是改 。<br />但看 hibernate 的配置文件 确可以很好工作 ，没办法读源码 <br />在框架中 发现 ConfigHelper类起到了作用 。<br />结合自己开发需求，写出了自己的 带查询文件功能类 <br />扩展的主要部分在 <b><font color="#0000ff">findFile</font></b>方法 这用了一下 简单的数据结构有兴趣的可以看看 <br /><br /> <br /><font color="#ffa500"><b>测试：</b><b><br /></b><font color="#000000"><font color="#ffa500">文件skynet.xml</font><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml version="1.0" encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">xml-body</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">man </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">='1'&gt;<br />        </span><span style="color: rgb(255, 0, 0);">&lt;name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">刘凯毅</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">avg</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">24</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">avg</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">man</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">man </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">='2'&gt;<br />        </span><span style="color: rgb(255, 0, 0);">&lt;name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">heha</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">avg</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">25</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">avg</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">man</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">xml-body</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span></div><br /><font color="#ffa500">测试类</font><br /></font><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> test.config;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.apache.commons.jxpath.JXPathContext;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.apache.commons.jxpath.XMLDocumentContainer;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> junit.framework.TestCase;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> SkynetConfigTest </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> TestCase {<br /><br />    </span><span style="color: rgb(0, 0, 255);">protected</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setUp() </span><span style="color: rgb(0, 0, 255);">throws</span><span style="color: rgb(0, 0, 0);"> Exception {<br />        </span><span style="color: rgb(0, 0, 255);">super</span><span style="color: rgb(0, 0, 0);">.setUp();<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> testConfigFile(){<br />        System.out.println(<br />                </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">find file in System user.dir -&gt; skynet.xml  </span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">                SkynetConfig.getResourceAsFile(System.getProperty(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user.dir</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) , <br />                        </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">skynet.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).getPath()<br />        );<br />        System.out.println(<br />                </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">find file in System java.class.path -&gt; skynet.xml </span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            SkynetConfig.getResourceAsFile(System.getProperty(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java.class.path</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) , <br />                    </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">skynet.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).getPath() <br />        );<br />    }<br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> testConfigURL(){<br />            JXPathContext jx </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> JXPathContext.newContext(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XMLDocumentContainer( <br />                    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> in System user.dir,java.class.path find  url:skynet</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">                    SkynetConfig.getResourceAsURL(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">skynet.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)   <br />                ));<br />            System.out.println( jx.getValue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">//man[avg='24']/@id</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) );<br />            System.out.println( jx.getValue(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">//man[avg='24']/name</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) );<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> testConfigStream(){<br />        System.out.println( SkynetConfig.getResourceAsStream(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">skynet.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) );<br />    }<br />}<br /><br /></span></div><br />结果：<br /><font color="#000000">E:\src3\rlzy15\lmisWeb\WEB-INF\classes\test\config\skynet.xml<br />E:\src3\rlzy15\lmisWeb\WEB-INF\classes\test\config\skynet.xml<br />1<br />刘凯毅<br />java.io.FileInputStream@1551d7f<br /><br /><br /></font></font><font><font color="#ffa500"><span style="color: rgb(0, 0, 0);">SkynetConfig 类</span></font></font><br /><font color="#ffa500"><font color="#000000"><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> test.config;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.File;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.FileInputStream;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.InputStream;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.net.URL;<br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.apache.commons.jxpath.JXPathContext;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.apache.commons.jxpath.XMLDocumentContainer;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.hibernate.util.ConfigHelper;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> SkynetConfig {<br />    <br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">final</span><span style="color: rgb(0, 0, 0);"> URL getResourceAsURL(</span><span style="color: rgb(0, 0, 255);">final</span><span style="color: rgb(0, 0, 0);"> String path) {<br />        URL url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /><br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> First, try to locate this resource through the current<br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> context classloader.</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        ClassLoader contextClassLoader </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Thread.currentThread().getContextClassLoader();<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (contextClassLoader</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">) {<br />            url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> contextClassLoader.getResource(path);<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (url </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> url;<br /><br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Next, try to locate this resource through this class's classloader</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ConfigHelper.</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">.getClassLoader().getResource(path);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (url </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> url;<br />        <br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Next, try to locate this resource through the system classloader</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ClassLoader.getSystemClassLoader().getResource(path);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(url </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> url;<br />        <br />        File ff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getResourceAsFile(System.getProperty(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user.dir</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) ,path);<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(ff</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />            ff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getResourceAsFile(System.getProperty(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java.class.path</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) , path);<br />        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />            url </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> URL(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">file:/</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">ff.getPath());<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (Exception e) {e.printStackTrace();}<br />        <br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> url;<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> InputStream getResourceAsStream(</span><span style="color: rgb(0, 0, 255);">final</span><span style="color: rgb(0, 0, 0);"> String resource) {<br />        String stripped </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> resource.startsWith(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"> <br />                resource.substring(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) : resource;<br />        InputStream stream </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">; <br />        ClassLoader classLoader </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Thread.currentThread().getContextClassLoader();<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (classLoader</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">) {<br />            stream </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> classLoader.getResourceAsStream( stripped );<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> ( stream </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> ) {<br />            SkynetConfig.</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">.getResourceAsStream( resource );<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> ( stream </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> ) {<br />            stream </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> SkynetConfig.</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">.getClassLoader().getResourceAsStream( stripped );<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> ( stream </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> ) {<br />            File ff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getResourceAsFile(System.getProperty(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user.dir</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) ,resource);<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(ff</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />                ff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> getResourceAsFile(System.getProperty(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java.class.path</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) , resource);<br />            </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />                stream </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileInputStream(ff);<br />                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(stream</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />                    </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Exception( resource </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> not found</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> );<br />            } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (Exception e) {e.printStackTrace();}<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> stream;<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> File getResourceAsFile(String str,String findff){<br />        String[] sfd </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> str.split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">sfd.length;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">){<br />            File file </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> File(sfd[i]);<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( file.isDirectory()){<br />                File[] cfs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> file.listFiles();<br />                </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> j</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;j</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">cfs.length;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">){<br />                    File ff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> findFile(cfs[j],findff);<br />                    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(ff</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 255);">continue</span><span style="color: rgb(0, 0, 0);">;<br />                    </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> ff;<br />                    <br />                }<br />            }<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> ;<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> File findFile(File file,String findff){<br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(file.isFile() </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> file.exists() </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> isFileEqu(file,findff)  ) </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> file ;<br />        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( file.isDirectory() ){<br />            File[] cfs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> file.listFiles();<br />            </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">cfs.length;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">){<br />                File ff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> findFile(cfs[i],findff);<br />                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(ff</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 255);">continue</span><span style="color: rgb(0, 0, 0);">;<br />                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( isFileEqu(ff,findff) ){<br />                    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> ff;<br />                }<br />            }<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> ;<br />    }<br />    <br />    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> isFileEqu(File ff,String findff){<br />        String path </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ff.getPath().trim() ;<br />        String findfft </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> findff.trim() ;<br />        <br />        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( path.lastIndexOf( findfft )</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br />        <br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br />    }<br /><br />}<br /></span></div><br /></font></font><font color="#ff9900"><b><font><span style="color: rgb(0, 0, 0);"></span></font></b></font><font color="#ffa500"><font color="#000000"><br /></font><br /></font><img src ="http://www.blogjava.net/Good-Game/aggbug/151745.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Good-Game/" target="_blank">G_G</a> 2007-10-10 14:50 <a href="http://www.blogjava.net/Good-Game/archive/2007/10/10/151745.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>