﻿<?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-SupernaturalPlace</title><link>http://www.blogjava.net/zhanjh/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 03 May 2026 17:16:20 GMT</lastBuildDate><pubDate>Sun, 03 May 2026 17:16:20 GMT</pubDate><ttl>60</ttl><item><title>关于java变量的引用（reference）</title><link>http://www.blogjava.net/zhanjh/archive/2008/03/04/183755.html</link><dc:creator>zhan</dc:creator><author>zhan</author><pubDate>Tue, 04 Mar 2008 09:33:00 GMT</pubDate><guid>http://www.blogjava.net/zhanjh/archive/2008/03/04/183755.html</guid><wfw:comment>http://www.blogjava.net/zhanjh/comments/183755.html</wfw:comment><comments>http://www.blogjava.net/zhanjh/archive/2008/03/04/183755.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/zhanjh/comments/commentRss/183755.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhanjh/services/trackbacks/183755.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #008080;">&nbsp;1</span>&nbsp;<span style="color: #0000ff;">package</span><span style="color: #000000;">&nbsp;cn.com.gentek.imatrix.test;<br />
</span><span style="color: #008080;">&nbsp;2</span>&nbsp;<span style="color: #000000;"><br />
</span><span style="color: #008080;">&nbsp;3</span>&nbsp;<span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;tesRef&nbsp;{<br />
</span><span style="color: #008080;">&nbsp;4</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;DataItem&nbsp;item1;<br />
</span><span style="color: #008080;">&nbsp;5</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;DataItem&nbsp;item2;<br />
</span><span style="color: #008080;">&nbsp;6</span>&nbsp;<span style="color: #000000;"><br />
</span><span style="color: #008080;">&nbsp;7</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;tesRef()&nbsp;{<br />
</span><span style="color: #008080;">&nbsp;8</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item1&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;DataItem();<br />
</span><span style="color: #008080;">&nbsp;9</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item2&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;item1;<br />
</span><span style="color: #008080;">10</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080;">11</span>&nbsp;<span style="color: #000000;"><br />
</span><span style="color: #008080;">12</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;newItem1()&nbsp;{<br />
</span><span style="color: #008080;">13</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item1&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;DataItem();<br />
</span><span style="color: #008080;">14</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080;">15</span>&nbsp;<span style="color: #000000;"><br />
</span><span style="color: #008080;">16</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;print()&nbsp;{<br />
</span><span style="color: #008080;">17</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">item1:&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;item1.toString());<br />
</span><span style="color: #008080;">18</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">item2:&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;item2.toString());<br />
</span><span style="color: #008080;">19</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080;">20</span>&nbsp;<span style="color: #000000;"><br />
</span><span style="color: #008080;">21</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">static</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;main(String[]&nbsp;args)&nbsp;{<br />
</span><span style="color: #008080;">22</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tesRef&nbsp;tr&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;tesRef();<br />
</span><span style="color: #008080;">23</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tr.print();<br />
</span><span style="color: #008080;">24</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tr.newItem1();<br />
</span><span style="color: #008080;">25</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tr.print();<br />
</span><span style="color: #008080;">26</span>&nbsp;<span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080;">27</span>&nbsp;<span style="color: #000000;">}<br />
</span><span style="color: #008080;">28</span>&nbsp;</div>
<br />
<br />
&nbsp;&nbsp;&nbsp; 以上一段很简单的代码，很容易看懂。它的运行结果如下：<br />
item1: cn.com.gentek.imatrix.test.DataItem@c17164<br />
item2: cn.com.gentek.imatrix.test.DataItem@c17164<br />
item1: cn.com.gentek.imatrix.test.DataItem@1fb8ee3<br />
item2: cn.com.gentek.imatrix.test.DataItem@c17164<br />
<br />
&nbsp;&nbsp;&nbsp; toString()的结果格式为类名@对象的16进制Hash表示。这里我们可以如此理解，是一个指向DataItem类实例化时，在内存中开辟的一块空间的地址标识。<br />
&nbsp;&nbsp;&nbsp; 在调用函数<span style="color: #000000;">tr.newItem1()（24行）之前，</span>item1和item2所指向的内存空间是相同的。所以在改变item1的同时item2的值势必更这一起改变，同理改变item2的内容，item1的内容也会做出相同的改变。<span style="color: #000000;">item1.toString()和</span><span style="color: #000000;">item2.toString()的结果正可以说明这一点。这也说明了，item1和item2存储的都是一个内存地址。<br />
&nbsp;&nbsp;&nbsp; 当调用</span><span style="color: #000000;">tr.newItem1()，重新实例化item1，之后item1指向的另一块内存空间，而item2保持不变，指向最初那块内存空间。此时，item1和和item2的内容将是毫不相关的。</span><br />
<br />
<img src ="http://www.blogjava.net/zhanjh/aggbug/183755.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhanjh/" target="_blank">zhan</a> 2008-03-04 17:33 <a href="http://www.blogjava.net/zhanjh/archive/2008/03/04/183755.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSF web编程:通过enum数组生成 &lt;h:selectOneMenu&gt; 下拉选择列表</title><link>http://www.blogjava.net/zhanjh/archive/2008/03/03/183493.html</link><dc:creator>zhan</dc:creator><author>zhan</author><pubDate>Mon, 03 Mar 2008 08:15:00 GMT</pubDate><guid>http://www.blogjava.net/zhanjh/archive/2008/03/03/183493.html</guid><wfw:comment>http://www.blogjava.net/zhanjh/comments/183493.html</wfw:comment><comments>http://www.blogjava.net/zhanjh/archive/2008/03/03/183493.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/zhanjh/comments/commentRss/183493.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhanjh/services/trackbacks/183493.html</trackback:ping><description><![CDATA[<p style="margin-left: 18pt; text-align: left; text-indent: -18pt;" align="left"><span><span>1.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span>HTML<span style="font-family: 宋体;">代码</span></p>
<p style="margin-left: 18pt; text-align: left; text-indent: 0cm;" align="left"><span style="font-family: 宋体;">最终实现的效果代码，如下所示：</span></p>
<p style="text-align: left; text-indent: 17.85pt;" align="left">&lt;select&gt;</p>
<p style="margin-left: 18pt; text-align: left;" align="left"><span>&lt;option
selected="selected"
value="Monitor"&gt;Monitor&lt;/option&gt;</span></p>
<p style="margin-left: 18pt; text-align: left;" align="left"><span>&lt;option
value="VCR"&gt;VCR&lt;/option&gt;</span></p>
<p style="margin-left: 18pt; text-align: left;" align="left"><span>&lt;option value="Standard
Device"&gt;Standard Device&lt;/option&gt;</span></p>
<p style="margin-left: 18pt; text-align: left;" align="left"><span>&lt;option value="Smart
Device"&gt;Smart Device&lt;/option&gt;</span></p>
<p style="margin-left: 18pt; text-align: left;" align="left"><span>&lt;option
value="Trunk"&gt;Trunk&lt;/option&gt;</span></p>
<p style="margin-left: 18pt; text-align: left;" align="left"><span>&lt;option value="Standby
VCR"&gt;Standby VCR&lt;/option&gt;</span></p>
<p style="margin-left: 18pt; text-align: left; text-indent: 0cm;" align="left">&lt;/select&gt;</p>
<p style="margin-left: 18pt; text-align: left; text-indent: -18pt;" align="left"><span><span>2.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span>enum<span style="font-family: 宋体;">代码</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">public</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">enum</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> DeviceType {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(100, 100, 100);">@XmlEnumValue</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Monitor"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">)</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">MONITOR</span></em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Monitor"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">),</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">VCR</span></em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"VCR"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">),</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(100, 100, 100);">@XmlEnumValue</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Standard Device"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">)</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">STANDARD_DEVICE</span></em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Standard Device"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">),</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(100, 100, 100);">@XmlEnumValue</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Smart Device"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">)</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">SMART_DEVICE</span></em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Smart Device"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">),</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(100, 100, 100);">@XmlEnumValue</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Trunk"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">)</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">TRUNK</span></em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Trunk"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">),</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(100, 100, 100);">@XmlEnumValue</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Standby VCR"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">)</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">STANDBY_VCR</span></em><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);">"Standby VCR"</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">);</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">private</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">final</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> String </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">value</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; DeviceType(String v) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">value</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> = v;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">public</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> String value() {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">return</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">value</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">public</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">static</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> DeviceType fromValue(String v)
{</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">for</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> (DeviceType c: DeviceType.<em>values</em>()) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">if</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> (c.</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">value</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">.equals(v)) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">return</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> c;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">throw</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">new</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> IllegalArgumentException(v);</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">}</span></p>
<p style="margin-left: 18pt; text-align: left; text-indent: -18pt;" align="left"><span><span>3.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span>JSF<span style="font-family: 宋体;">标签：</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt;">&lt;h:selectOneMenu
value="<strong>#{voutputType.DEVICETYPE}</strong>"
converter="<strong>voutputDeviceTypeConverter</strong>"&gt;</span></p>
<p style="margin-left: 21pt; text-align: left;" align="left"><span style="font-size: 10pt;">&lt;f:selectItems value="<strong>#{voutput.deviceTypeList}</strong>"/&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt;">&lt;/h:selectOneMenu&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-family: 宋体;">主要有三个部分组成</span></p>
<p style="margin-left: 39pt; text-align: left; text-indent: -18pt;" align="left"><strong><span><span>(a)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></strong><strong><span>value="#{voutputType.DEVICETYPE}"
</span></strong></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">由</span>javabean<strong> ,voutputType</strong><span style="font-family: 宋体;">中的</span><strong>DEVICETYPE</strong><span style="font-family: 宋体;">属性，确定</span>html<span style="font-family: 宋体;">代码中</span><span>&lt;option selected="selected"
value="Monitor"&gt;</span><span style="font-family: 宋体;">项的值</span><span style="font-family: 宋体;">。</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><strong>voutputType</strong><span style="font-family: 宋体;">配置信息在</span>"WebRoot"WEB-INF"faces-config.xml<span style="font-family: 宋体;">：</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean-name</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">voutputType</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean-name</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean-class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cn.com.gentek.imatrix.xml.jaxb.voutput.ObjVOutputType</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean-class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean-scope</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">session</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean-scope</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">managed-bean</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体;">其中</span><strong>DEVICETYPE</strong><span style="font-family: 宋体;">属性对应的变量是枚举</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">DeviceType</span><span style="font-size: 10pt; font-family: 宋体; color: black;">的一个实例。</span></p>
<p style="margin-left: 39pt; text-align: left; text-indent: -18pt;" align="left"><strong><span><span>(b)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;
</span></span></span></strong><strong>converter="voutputDeviceTypeConverter"</strong></p>
<p style="margin-left: 39pt; text-align: left; text-indent: 0cm;" align="left"><span style="font-family: 宋体;">类型转换器，在在</span>"WebRoot"WEB-INF"faces-config.xml<span style="font-family: 宋体;">配置如下：</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">converter</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">converter-id</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">voutputDeviceTypeConverter</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">converter-id</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">converter-class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cn.com.gentek.imatrix.ui.VoutDeviceTypeConverter</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">converter-class</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&lt;/</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);">converter</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;">&gt;</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">cn.com.gentek.imatrix.ui.VoutDeviceTypeConverter</span><span style="font-size: 10pt; font-family: 宋体; color: black;">代码如下：</span></p>
<p style="text-align: left;" align="left"><span style="font-family: 宋体;">（实现</span>&lt; select&gt;<span style="font-family: 宋体;">中</span>&lt;option&gt;<span style="font-family: 宋体;">的</span>String<span style="font-family: 宋体;">类型值，与</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">DeviceType</span><span style="font-size: 10pt; font-family: 宋体; color: black;">类型之间的转换）</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">public</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">class</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> VoutDeviceTypeConverter </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">implements</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> Converter {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">public</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> Object
getAsObject(FacesContext context, UIComponent component,</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: black;">String value) {</span></span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeviceType result = </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">null</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">if</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> (value == </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">null</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> || value.length() &lt; 1) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">null</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">else</span></strong></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = DeviceType.<em>fromValue</em>(value);</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">return</span></strong><u><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;">result</span></u><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">public</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> String
getAsString(FacesContext context, UIComponent component,</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> <span style="color: black;">Object value) {</span></span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String result = </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">null</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">if</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> (value != </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">null</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">if</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> (value </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">instanceof</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> DeviceType)
{</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeviceType temp =
(DeviceType) value;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = temp.value();</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">return</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> result;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">}</span></p>
<p style="margin-left: 39pt; text-align: left; text-indent: -18pt;" align="left"><strong><span><span>(c)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span></strong><strong>&nbsp;&lt;f:selectItems value="#{voutput.deviceTypeList}"/&gt;</strong><strong><span style="font-family: 宋体;">（重点）</span></strong></p>
<p style="margin-left: 21pt; text-align: left;" align="left"><span style="font-family: 宋体;">由于</span><strong>deviceTypeList</strong><span style="font-family: 宋体;">对应变量必须是</span><span style="background: silver none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">SelectItem</span><span style="font-size: 10pt; font-family: 宋体; color: black;">（</span><span style="background: silver none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">javax.faces.model.SelectItem</span><span style="font-size: 10pt; font-family: 宋体; color: black;">）列表，所以有必要将</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">DeviceType</span><span style="font-size: 10pt; font-family: 宋体; color: black;">类型实例的值和对应</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">String</span><span style="font-size: 10pt; font-family: 宋体; color: black;">类型值，封装在一个</span><span style="background: silver none repeat scroll 0% 50%; font-size: 10pt; font-family: &quot;Courier New&quot;; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">SelectItem</span><span style="font-size: 10pt; font-family: 宋体; color: black;">实例中。实现代码如下：</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">ArrayList&lt;SelectItem&gt; deviceTypeList = </span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">new</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> ArrayList&lt;SelectItem&gt;();</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">for</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> (</span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">int</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> i = 0; i &lt; DeviceType.<em>values</em>().</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 192);">length</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">; i++) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; deviceTypeList.add(</span><strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);">new</span></strong><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">
SelectItem(DeviceType.<em>values</em>()[i],</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeviceType.<em>values</em>()[i].value()));</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">}</span></p>
<img src ="http://www.blogjava.net/zhanjh/aggbug/183493.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhanjh/" target="_blank">zhan</a> 2008-03-03 16:15 <a href="http://www.blogjava.net/zhanjh/archive/2008/03/03/183493.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSF web编程中的JavaBean路径访问问题</title><link>http://www.blogjava.net/zhanjh/archive/2008/02/29/183003.html</link><dc:creator>zhan</dc:creator><author>zhan</author><pubDate>Fri, 29 Feb 2008 09:36:00 GMT</pubDate><guid>http://www.blogjava.net/zhanjh/archive/2008/02/29/183003.html</guid><wfw:comment>http://www.blogjava.net/zhanjh/comments/183003.html</wfw:comment><comments>http://www.blogjava.net/zhanjh/archive/2008/02/29/183003.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/zhanjh/comments/commentRss/183003.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhanjh/services/trackbacks/183003.html</trackback:ping><description><![CDATA[<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">使用</span>JSF<span style="font-family: 宋体;">编写</span>web<span style="font-family: 宋体;">程序的时候，</span>JavaBean<span style="font-family: 宋体;">无法直接通过相对路径来访问文件。经过一天的研究主要发现两类解决方案，一是，通过</span>FacesContext<span style="font-family: 宋体;">，二是，通过</span>ClassLoader<span style="font-family: 宋体;">。</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">下面通过实例来说明。</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">首先是介绍</span>web<span style="font-family: 宋体;">程序目录的大致结构：</span></p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left"><span>D:"......"Tomcat
6.0"webapps"imatrixb&nbsp;------&gt; </span><span style="font-family: 宋体;">程序的更目录</span></p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --META-INF</p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --WEB-INF</p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---------------classess</p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---------------------------cn</p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----------------------------------com</p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------------------------------------------&#8230;&#8230;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----------&gt;class
</span><span style="font-family: 宋体;">文件</span></p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---------------------------XmlData</p>
<p style="margin-left: 21pt; text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---------------------------------path-config.xml&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: 宋体;">（</span>1<span style="font-family: 宋体;">）</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------------- path-config.xml&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: 宋体;">（</span>2<span style="font-family: 宋体;">）</span></p>
<p style="margin-left: 42pt; text-align: left; text-indent: 21pt;" align="left">&#8230;&#8230;.</p>
<p style="margin-left: 42pt; text-align: left; text-indent: 21pt;" align="left">Index.jsp</p>
<p style="text-align: left; text-indent: 21pt;" align="left"><strong><span style="font-family: 宋体;">一：</span>FacesContext</strong></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">获得（</span>2<span style="font-family: 宋体;">）号</span>path-config.xml<span style="font-family: 宋体;">文件信息</span>,</p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">代码如下：</span></p>
<p style="text-align: left;" align="left"><span>String partPath=&#8221;/
WEB-INF/ path-config.xml&#8221;;</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left">1. getRealPath():</p>
<p style="text-align: left;" align="left"><span>FacesContext
context = FacesContext.getCurrentInstance(); <br />
HttpServletRequest rst = (HttpServletRequest)context.getExternalContext().getRequest();
<br />
String fullPath=rst.getRealPath(xmlfile); // </span><span style="font-family: 宋体;">获得</span>xml<span style="font-family: 宋体;">文件的系统路径，</span>xmlfile<span style="font-family: 宋体;">为相对路径</span></p>
<p style="text-align: left;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: 宋体;">采用这个方法存在一些隐患：比方说对一个打包的应用来说，是没有</span>RealPath<span style="font-family: 宋体;">的概念的，调用</span>getRealPath<span style="font-family: 宋体;">只会简单地返回</span>null<span style="font-family: 宋体;">。</span></p>
<p style="text-align: left;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> getResourceAsStream():</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">FacesContext context =
FacesContext.<em>getCurrentInstance</em>();</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">InputStream xmlStream =
context.getExternalContext()</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .getResourceAsStream(</span>xmlfile<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">);</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: 宋体; color: black;">用于只读的形式。</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: 宋体; color: black;">二：</span>ClassLoader</strong></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">获得（</span>1<span style="font-family: 宋体;">）号</span>path-config.xml<span style="font-family: 宋体;">文件信息</span>,</p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 宋体;">代码如下：</span></p>
<p style="text-align: left;" align="left"><span>String partPath
=&#8221;/XmlData/path-config.xml&#8221;;</span></p>
<p style="text-align: left;" align="left"><span>String
fullPath=this.getClass().getClassLoader().getResource(partPath).getPath();</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left">//<span style="font-family: 宋体;">使用的时候还是存在一些问题，无法正常使用，暂时没有发现解决的办法</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">InputStream xmlStream=</span>this.getClass().getClassLoader().getResourceAsStream(partPath);</p>
<p style="text-align: left;" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<span style="font-family: 宋体;">用于只读的形式下，通过测试能够正常的使用</span></p>
<img src ="http://www.blogjava.net/zhanjh/aggbug/183003.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhanjh/" target="_blank">zhan</a> 2008-02-29 17:36 <a href="http://www.blogjava.net/zhanjh/archive/2008/02/29/183003.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Xml数据配置的Web程序重构(2)--反射</title><link>http://www.blogjava.net/zhanjh/archive/2008/02/26/182265.html</link><dc:creator>zhan</dc:creator><author>zhan</author><pubDate>Tue, 26 Feb 2008 09:09:00 GMT</pubDate><guid>http://www.blogjava.net/zhanjh/archive/2008/02/26/182265.html</guid><wfw:comment>http://www.blogjava.net/zhanjh/comments/182265.html</wfw:comment><comments>http://www.blogjava.net/zhanjh/archive/2008/02/26/182265.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhanjh/comments/commentRss/182265.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhanjh/services/trackbacks/182265.html</trackback:ping><description><![CDATA[<p style="text-align: left;" align="left"><strong><span style="font-family: &quot;Courier New&quot;;">1.2 </span></strong><strong><span style="font-family: 宋体;">反射</span></strong></p>
<p style="text-align: left;" align="left"><strong><span style="font-family: &quot;Courier New&quot;;">1.2.1 </span></strong><strong><span style="font-family: 宋体;">学习笔记</span></strong></p>
<p style="text-align: left;" align="left"><span style="font-family: 宋体;">参考资料：</span><span style="font-family: &quot;Courier New&quot;;">Java 2 </span><span style="font-family: 宋体;">核心技术</span><span style="font-family: 宋体;">卷</span><span style="font-family: &quot;Courier New&quot;;">I</span><span style="font-family: 宋体;">：基础知识（第</span><span style="font-family: &quot;Courier New&quot;;">7</span><span style="font-family: 宋体;">版）</span><span style="font-family: &quot;Courier New&quot;;"> 5.5 </span><span style="font-family: 宋体;">反射</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-family: &quot;Courier New&quot;;">(1) Class</span></strong><strong><span style="font-family: 宋体;">类</span></strong></p>
<p style="text-align: left;" align="left"><span style="font-family: &quot;Courier New&quot;;">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体;">在程序运行期间，</span><span style="font-family: &quot;Courier New&quot;;">Java</span><span style="font-family: 宋体;">运行时系统始终为所有对象的维护一个被称为运行时的类型标识。这个信息保存着每一个对象所有属性的类足迹。虚拟机利用运行信息选择相应的方法执行。</span></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-size: 10pt; font-family: 宋体;">获取</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">Class</span><span style="font-size: 10pt; font-family: 宋体;">类对象的三种方法</span></p>
<p style="margin-left: 32.25pt; text-align: left; text-indent: -18pt;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span>(a)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">getClass()</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Employee e;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Class cl=e.getClass();</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(cl.getName()+&#8220;
&nbsp;&#8221; +e.getName());</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;Result:</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Employee Harry</span></p>
<p style="margin-left: 32.25pt; text-align: left; text-indent: -18pt;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span>(b)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;
</span></span></span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">forName()</span></p>
<p style="margin-left: 32.25pt; text-align: left;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">String className= &#8220;java.util.Date &#8221;;</span></p>
<p style="margin-left: 32.25pt; text-align: left;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">Class cl=Class.forName(className);</span></p>
<p style="margin-left: 32.25pt; text-align: left; text-indent: -18pt;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><span>(c)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;
</span></span></span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">.class</span></p>
<p style="margin-left: 14.25pt; text-align: left;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;&nbsp;Class cl1=Date.class;</span></p>
<p style="margin-left: 14.3pt; text-align: left; text-indent: 5.25pt;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;Class cl2=int.class;</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">(2) </span></strong><strong><span style="font-family: 宋体;">反射的分析能力</span></strong></p>
<p style="text-align: left;" align="left"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">&nbsp;</span><span style="font-family: 宋体;">示例：</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">Employee.java:</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">public</span></strong><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">class</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> Employee {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">private</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> String </span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0;">name</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">private</span></strong><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">int</span></strong><span style="background: silver none repeat scroll 0% 50%; font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">age</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">public</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> String getName() {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">return</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0;">name</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">public</span></strong><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">void</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> setName(String name) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">this</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">.</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0;">name</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> = name;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">public</span></strong><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">int</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> getSalary() {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">return</span></strong><span style="background: silver none repeat scroll 0% 50%; font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">age</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">public</span></strong><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">void</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> setSalary(</span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">int</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> salary) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">this</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">.</span><span style="background: silver none repeat scroll 0% 50%; font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">age</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> = salary;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">public</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> Employee(String name, </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">int</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> salary) {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">this</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">.</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0;">name</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> = name;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: #7f0055;">this</span></strong><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">.</span><span style="background: silver none repeat scroll 0% 50%; font-size: 9pt; font-family: &quot;Courier New&quot;; color: #0000c0; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">age</span><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;"> = salary;</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">}</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 9pt; font-family: &quot;Courier New&quot;; color: black;">Test.java</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">import</span></strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;"> java.lang.reflect.Field;</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">public</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">class</span></strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;"> test {</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">public</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">static</span></strong><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">void</span></strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;"> main(String[] args) </span><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">throws</span></strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;"> SecurityException,</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NoSuchFieldException,
IllegalArgumentException,</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IllegalAccessException
{</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><u><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: blue;">Employee</span></u><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;"> zhanjh = </span><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">new</span></strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;"> Employee(</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #2a00ff;">"zhan jh"</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">, 1000);</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Class&lt;?&gt;
cl = zhanjh.getClass();</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Field
f = cl.getDeclaredField(</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #2a00ff;">"name"</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">); </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">// </span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">返回名称为</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">&#8220;name&#8221;</span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">的私有或公有成员（域）</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f.setAccessible(</span><strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #7f0055;">true</span></strong><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">); </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">// </span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">非常重要，否则无法调用</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">f.get(zhanjh)</span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">方法</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object
v = f.get(zhanjh);</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">// </span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">返回</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">zhanjh</span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">对象中</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;"> name</span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">成员（域）的值</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.</span><em><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #0000c0;">out</span></em><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">.println(v.toString());</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: black;">}</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">/*</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">&nbsp;* </span><span style="font-size: 10pt; font-family: 宋体; color: #3f7f5f;">运行结果：</span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;"> zhan jh</span></p>
<p style="text-align: left;" align="left"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; color: #3f7f5f;">&nbsp;*/</span></p>
<img src ="http://www.blogjava.net/zhanjh/aggbug/182265.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhanjh/" target="_blank">zhan</a> 2008-02-26 17:09 <a href="http://www.blogjava.net/zhanjh/archive/2008/02/26/182265.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Xml数据配置的Web程序重构(1)---Jaxb</title><link>http://www.blogjava.net/zhanjh/archive/2008/02/25/182046.html</link><dc:creator>zhan</dc:creator><author>zhan</author><pubDate>Mon, 25 Feb 2008 09:09:00 GMT</pubDate><guid>http://www.blogjava.net/zhanjh/archive/2008/02/25/182046.html</guid><wfw:comment>http://www.blogjava.net/zhanjh/comments/182046.html</wfw:comment><comments>http://www.blogjava.net/zhanjh/archive/2008/02/25/182046.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhanjh/comments/commentRss/182046.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhanjh/services/trackbacks/182046.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 从去年12月份还是学习Java到现在已经将近3个月了，现在已经很有必要对以前所学的知识进行一次系统的复习。而重新复习最好的办法就是将最近刚完成，但不完善的Xml数据配置的Web程序，进行一次重构。其中需要重新复习的知识主要内容如下：1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;&nbsp;<a href='http://www.blogjava.net/zhanjh/archive/2008/02/25/182046.html'>阅读全文</a><img src ="http://www.blogjava.net/zhanjh/aggbug/182046.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhanjh/" target="_blank">zhan</a> 2008-02-25 17:09 <a href="http://www.blogjava.net/zhanjh/archive/2008/02/25/182046.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>interfaces</title><link>http://www.blogjava.net/zhanjh/archive/2007/12/26/170672.html</link><dc:creator>zhan</dc:creator><author>zhan</author><pubDate>Wed, 26 Dec 2007 11:07:00 GMT</pubDate><guid>http://www.blogjava.net/zhanjh/archive/2007/12/26/170672.html</guid><wfw:comment>http://www.blogjava.net/zhanjh/comments/170672.html</wfw:comment><comments>http://www.blogjava.net/zhanjh/archive/2007/12/26/170672.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhanjh/comments/commentRss/170672.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhanjh/services/trackbacks/170672.html</trackback:ping><description><![CDATA[interfaces<br />
<br />
上午完成thinking Java中关于Interfaces章节的内容。下面是该章节中关于"Interfaces and factories"的例子<br />
package com.zhanjh.thinkingjava.interfaces;<br />
<br />
interface Service{<br />
&nbsp;&nbsp;&nbsp; void method1();<br />
&nbsp;&nbsp;&nbsp; void method2();<br />
}<br />
<br />
interface ServiceFactory{<br />
&nbsp;&nbsp;&nbsp; Service getService();<br />
}<br />
<br />
class Implementation1 implements Service{<br />
&nbsp;&nbsp;&nbsp; public Implementation1() {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // TODO Auto-generated constructor stub<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; public void method1(){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Implementation1 method1");<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; public void method2(){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Implementation1 method2");<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br />
class Implementation1Factory implements ServiceFactory{<br />
&nbsp;&nbsp;&nbsp; public Service getService(){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return new Implementation1();<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br />
class Implementation2 implements Service{<br />
&nbsp;&nbsp;&nbsp; public Implementation2() {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // TODO Auto-generated constructor stub<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; public void method1(){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Implementation2 method1");<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; public void method2(){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Implementation2 method2");<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br />
class Implementation2Factory implements ServiceFactory{<br />
&nbsp;&nbsp;&nbsp; public Service getService(){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return new Implementation2();<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
<br />
public class Factories{<br />
&nbsp;&nbsp;&nbsp; public static void serviceConsumer(ServiceFactory fact){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Service s=fact.getService();<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.method1();<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.method2();<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; public static void main(String[] args){<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; serviceConsumer(new Implementation1Factory());<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; serviceConsumer(new Implementation2Factory());<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
总结：abstract class和interface是Java语言中对于抽象类定义进行支持的两种机制，abstract class和interface之间在对于抽象类定义的支持方面具有很大的相似性。目前我对他们区分的方法大致如下：<br />
1）interface可以多重实现，而abstract class只能单一继承<br />
2）abstract class不一定只有抽象的方法（abstract method），它也可以包含具体的方法（concrete method）。而interface不能包含方法的实现（implementation）。所以在程序设计的时候，能用inteface的时候尽量不要用abstract class。<br />
<br />
下午<br />
&nbsp;&nbsp;&nbsp;&nbsp; 查找关于EJB的资料，没头绪。<br />
&nbsp;&nbsp;&nbsp;&nbsp; jaxb入门学习。<br />
&nbsp;&nbsp;&nbsp;&nbsp; xjc（将xsd文件转换为Java的小工具）工具的使用。可以创建一个bat文件处理下面的命令：<br />
&nbsp;&nbsp;&nbsp; xjc -d "D:"eclipse"workspace"JaxbTest"src" -p "edu.jlu.xml" "D:"eclipse"workspace"JaxbTest"schema"messages.xsd"<br />
其中D:"eclipse"workspace"JaxbTest"src为原文件的目录，edu.jlu.xml为生成Java类的包名，D:" eclipse"workspace"JaxbTest"schema"messages.xsd为xml schema文件的路径。<br />
<br />
<img src ="http://www.blogjava.net/zhanjh/aggbug/170672.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhanjh/" target="_blank">zhan</a> 2007-12-26 19:07 <a href="http://www.blogjava.net/zhanjh/archive/2007/12/26/170672.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>