<?xml version="1.0" encoding="gb2312"?>

<!-- RSS generated by oioj.net on 4/16/2004 ; 感谢LeXRus提供 RSS 2.0 文档; 此文件可自由使用，但请保留此行信息 --> 
<!-- Source download URL: http://blogger.org.cn/blog/rss2.asp       -->
<rss version="2.0">

<channel>
<title>nobdy</title>
<link>http://blogger.org.cn/blog/blog.asp?name=nobdy</link>
<description>nobdy的博客</description>
<copyright>blogger.org.cn</copyright>
<generator>W3CHINA Blog</generator>
<webMaster>webmaster@blogger.org.cn</webMaster>
<item>
<title><![CDATA[在 oracle 中实现 anto increase]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=nobdy&amp;id=38708</link>
<author>nobdy</author>
<pubDate>2008/8/9 16:29:50</pubDate>
<description><![CDATA[<P>目标(举例子说明)：<BR>&nbsp; 创建表<BR>&nbsp;&nbsp;&nbsp; CREATE TABLE INC_TEST(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ID NUMBER(6),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NAME VARCHAR2(125)<BR>&nbsp;&nbsp;&nbsp; );</P>
<P><BR>希望在插入新的数据且没有提供 id 值时，会将 id 值设置为一个在表的数据中没有用过的值；<BR>而插入新的数据时如果有提供 id 值，则使用所提供的 id 值。</P>
<P><BR>例如执行<BR>&nbsp; 1) INSERT INTO INC_TEST(NAME) VALUES('nobdy');<BR>时，假如表内数据为空，则会加入一条数据为：(ID: 1, NAME: nobdy)<BR>然后再执行<BR>&nbsp; 2) INSERT INTO INC_TEST(NAME) VALUES('admin');<BR>后，则会增加一条数据：(ID: 2, NAME: admin)<BR>接着再执行<BR>&nbsp; 3) INSERT INTO INC_TEST(ID, NAME) VALUES(10, 'test');<BR>后，则会增加数据：(ID: 10, NAME: test)<BR>最后执行<BR>&nbsp; 4) INSERT INTO INC_TEST(NAME) VALUES('coremail');<BR>后，增加一条数据为：(ID: 11, NAME: coremail)</P>
<P>&nbsp;</P>
<P>在 google 搜索了一下，发现网上所提供的方法都大同小异，即在插入数据时也不管用户有没有提供值就将其设置为自增的值，这样用户设置的值就丢失了。比如在执行上面例子中的 3) 时，插入的数据变成了(ID: 3, NAME: test)。</P>
<P>经过一番尝试，发现用一个 sequence 和一个 trigger 可以解决这个问题, 所有的代码如下所示：<BR>&shy;<BR>DROP TABLE INC_TEST;<BR>&shy;<BR>CREATE TABLE INC_TEST(<BR>&nbsp; ID NUMBER(6),<BR>&nbsp; NAME VARCHAR2(125)<BR>);<BR>DROP SEQUENCE INC_TEST_SEQ;<BR>CREATE SEQUENCE INC_TEST_SEQ INCREMENT BY 1 START WITH 1 ORDER;<BR>CREATE OR REPLACE TRIGGER INC_INC_TEST<BR>BEFORE INSERT ON INC_TEST<BR>FOR EACH ROW<BR>DECLARE<BR>&nbsp; CURRENT_VAL NUMBER:=0;<BR>BEGIN<BR>&nbsp; IF :NEW.ID IS NULL THEN<BR>&nbsp;&nbsp;&nbsp; SELECT INC_TEST_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;<BR>&nbsp; ELSE<BR>&nbsp;&nbsp;&nbsp; LOOP<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXIT WHEN (CURRENT_VAL &gt;= :NEW.ID);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT INC_TEST_SEQ.NEXTVAL INTO CURRENT_VAL FROM DUAL;<BR>&nbsp;&nbsp;&nbsp; END LOOP;<BR>&nbsp; END IF;<BR>END;<BR>/<BR>INSERT INTO INC_TEST(NAME) VALUES('nobdy');<BR>INSERT INTO INC_TEST(NAME) VALUES('admin');<BR>INSERT INTO INC_TEST(ID, NAME) VALUES(10, 'test');<BR>INSERT INTO INC_TEST(NAME) VALUES('coremail');<BR>INSERT INTO INC_TEST(ID, NAME) VALUES(5, 'mailtech');<BR>INSERT INTO INC_TEST(NAME) VALUES('simon'); </P>]]></description>
</item><item>
<title><![CDATA[浪漫而不伤感－－辛巴达七海传奇片末经典对白。。。]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=nobdy&amp;id=27299</link>
<author>nobdy</author>
<pubDate>2007/8/16 12:10:54</pubDate>
<description><![CDATA[<A><FONT color=#593861>　</FONT></A>
<P><FONT color=#593861>Oh... Rat!</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>RAT:<BR>What?</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>(chuckling)</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>MARINA:<BR>Excuse me, Captain.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>You need to replace<BR>these rig joints pretty soon.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>The mizzen ropes<BR>need the support.</FONT></P>
<P><BR><FONT color=#593861>&nbsp;</FONT></P>
<P><FONT color=#593861>These joints<BR>were from the Jasmine Sea.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>That's halfway around the world.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><BR><FONT color=#593861>Then we'd better get started.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><BR><FONT color=#593861>Well, you know,</FONT></P>
<P><FONT color=#593861>that means going through<BR>the Hydra's lair.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>- Mm-hmm.<BR>- The Minotaur's haven.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>- Mm-hmm.<BR>- The Cyclops' den.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>- Mm-hmm.<BR>- Under the Swansea Bridge.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>- Mm-hmm.<BR>- Through the China Seas.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>That's a very long voyage.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>And it's very, very dangerous.</FONT></P>
<P><BR><FONT color=#593861>Don't worry.</FONT></P>
<P><FONT color=#593861></FONT>&nbsp;</P>
<P><FONT color=#593861>I'll protect you.</FONT></P>]]></description>
</item><item>
<title><![CDATA[我修改后的 IE 调试工具firebug lite]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=nobdy&amp;id=21787</link>
<author>nobdy</author>
<pubDate>2007/1/15 20:56:25</pubDate>
<description><![CDATA[&nbsp; 在进行web客户端开发时，你有没有试过用google搜索“javascript 调试工具”“javascript调试方法”之类的语句，来尝试找到比较方便快捷的javascript调试途径？如果你有这样做的话，想必你将会看到诸如以下几个选择： 
<P>&nbsp; 1. Venkman，这是我看到的最多网页描述并推荐的调试器，应该是因为它出现得比较早的原因。需要在mozilla浏览器中使用，也可以在firefox中安装Venkman扩展程序来使用</P>
<P>&nbsp; 2. firebug，这是我本人目前正在用的调试工具。国外和国内都有不少人对此firefox的扩展情有独钟，我个人也觉得它是目前最优秀的js调试工具。就我写这一篇文章为止，它的版本是1.0 beta8。当然，firebug只能在firefox中使用。</P>
<P>&nbsp; 3. 用IE调试，自己加alert()模仿断点。另外把IE选项里的禁止调试的勾子去掉，去错的时候，浏览器就会问你要不要调试，点“是”，就会弹出Visual调试工具，可以到出错的断点,并且观察相应的变量值。</P>
<P>&nbsp; 第三个方法因为我没有试过，所以就不做评论了，但看来至少是要安装了Visual调试工具才能用得了啦</P>
<P>&nbsp; 因为我只是一个java，javascript程序员，自参加工作以来到现在已经有一年多，大部分时间只是跟js打交道，一直没有用c++和c了，.net就根本没碰过，所以如果我在提到C系列语言方面时犯了一些甚至常规性的错误，请见谅^_^!由于目前没有打算进一步学习或使用C、C++等，所以为了节省硬盘空间和系统资源，我的机器上根本就没有装Visual系列的IDE或工具，因此第三种方法似乎就并不适合我了。</P>
<P>&nbsp; 但是如果有些情况非要在IE中调试怎么办？比如要弄清楚某些只在IE出现的bug产生的原因，但在firefox或mozilla中调试又帮不上忙，alert并不是解决所有问题的最好方法。对于此，<A href="http://www.getfirebug.com/">www.getfirebug.com</A>&nbsp;给出了一个初始的IE调试工具 firebug lite，目前是1.0的beta1版本，专门用于在非firefox浏览器上测试web页面；但可惜的是，也许是它的作者还没有对它过多的完善，在很多复杂的javascript应用中恐怕并不是就能方便地直接拿来就用，所以为了提高其可用性，我利用工作之余对它的源代码做了一些修改，主要的改进是增加了可动态设置多个window下（这里的所说的window其实是指frame或iframe中的window）能使用同一个debug对象console，所有log都在同一个窗口输出，支持测试含有多个frame或iframe的javascript应用程序，另外还做了一些bug fix。我会给出修改之后的代码，其中还包含了我添加的一些简单的demo，如果大家发现了其中的一些错误或者有什么好的建议，请告诉我，我会很感谢大家的支持；另外我也不知道我这一做法是不是违反某些许可证的规定，如果有的话，也请告知我，谢谢。</P>
<P>附录：</P>
<P>1. 我修改后的firebug lite js调试工具源代码下载：<IMG src="images/file/zip.gif" border=0><A href="uploadfile/200711523313683.RAR" target=_blank>firebug lite beta1.rar</A></P>
<P>2. Venkman相关网站：<A href="http://www.mozilla.org/projects/venkman/">http://www.mozilla.org/projects/venkman/</A></P>
<P>3. firebug相关网站：<A href="http://www.getfirebug.com/">http://www.getfirebug.com/</A></P>
<P>4. firebug lite相关网站：<A href="http://www.getfirebug.com/lite.html">http://www.getfirebug.com/lite.html</A></P>
<P>5. debug对象console的使用说明见：<A href="http://www.getfirebug.com/docs.html">http://www.getfirebug.com/docs.html</A></P>]]></description>
</item><item>
<title><![CDATA[让我们学会如何快乐的工作]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=nobdy&amp;id=15887</link>
<author>nobdy</author>
<pubDate>2006/6/26 22:10:44</pubDate>
<description><![CDATA[<P>引自：<A href="http://www.sinid.com/2005/03/21/153/">http://www.sinid.com/2005/03/21/153/</A></P>
<P>密码遗失的个人网志<BR>This is my new weblog , a new beginning!<BR>HomeAbout MeIdcGuestbookArchivesLinks<BR>My Flickr Photograph<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>&nbsp;</P>
<P><BR>? 我们拿什么来改变中国？&nbsp;&nbsp;&nbsp; 对于改变中国这个讨论组的理解 ? </P>
<P><BR>让我们学会如何快乐的工作</P>
<P><BR>　　一头老驴，掉到了一个废弃的陷阱里，很深，根本爬不上来。主人看它是老驴，懒得去救它了，让它在那里自生自灭。那头驴一开始也放弃了求生的希望，每天还不断地有人往陷阱里面倒垃圾。按理说老驴应该很生气，应该天天去抱怨，自己倒霉掉到了陷阱里，它的主人不要它，就算死也不让它死得舒服点，每天还有那么多垃圾扔在它旁边。<BR>　　可是有一天，它决定改变自己的态度，它每天都把垃圾踩到自己的脚下，从垃圾中找到残羹来维持自己的生命，而不是被垃圾所淹没。终于有一天，它重新回到了地面上。</P>
<P>　　快乐工作提示：<BR>　　无论现实多么不如人意，我们也可以慢慢积累。很多时候，决定一切的是态度，有了正确的态度，就可以将压力转化为动力，踏上成功的舞台。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; －－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</P>
<P>　　有个旅客在沙漠里走着，忽然后面出现了一群饿狼，追着他来要群起而噬。他大吃一惊，拼命狂奔，为生命而奋斗。当饿狼就要追上他时，他见到前面有口不知有多深的井，不顾一切地跳了下去。<BR>　　谁料那口井不但没有水，还有很多毒蛇，见到有食物送上门来，昂首吐舌，热切引项以待。他大惊失神下，胡乱伸手想去抓到点什么可以救命的东西，想不到竟天从人愿，给他抓到了一棵在井中间横伸出来的小树，把他稳在半空处。<BR>　　于是乎上有饿狼，下有毒蛇，不过那人虽陷身在进退两难的绝境，但暂时还是安全的。就在他松了一口气的时刻，奇怪的异响传入他的耳内。他骇然循声望去，魂飞魄散地发觉有一群大老鼠正以尖利的牙齿咬着树根，这救命的树已是时日无多了。<BR>　　就在这生死一瞬的时刻，他看到了眼前树叶上有一滴蜜糖，于是他忘记了上面的饿狼，下面的毒蛇，也忘掉了快要给老鼠咬断的小树，闭上眼睛，伸出舌头，全心全意去品尝那滴蜜糖。</P>
<P>　　快乐工作提示：<BR>　　初看这个故事，觉得这个故事的意义在于让大家领悟“享受生活每一刻”。然而仔细想来，从另一层更为积极的意义上面来讲，在生活中，我们会遇到很多的困难，有些困难属于过去，有些困难属于未来，我们当下的任务就是解决每一个现在可以解决的问题，争取获得每一个我们现在可以获得的机会。</P>
<P>&nbsp; －－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</P>
<P>　　两个青年一同开山，一个把石块砸成石子运到路边，卖给建房的人；一个则直接把石块运到码头，卖给杭州的花鸟商人。因为这儿的石头是奇形怪状的，他认为卖重量不如卖造型。3年后，他成为村上第一个盖起瓦房的人。<BR>　　他在自己的学习笔记上面写下一句话：要寻找与他人不同的优势。<BR>　　后来，不许开山，只许种树，于是这儿成了果园。每到秋天，漫山遍野的鸭梨招来八方客商，他们把堆积如山的梨子成筐成筐地运往北京和上海，然后再发往韩国和日本。因为这儿的梨，汁浓肉脆，口味纯正无比。就在村上的人为鸭梨带来的小康日子欢呼雀跃时，曾卖过石头的那果农卖掉果树，开始种柳。因为他发现，来这儿的客商不愁挑不到好梨子，只愁买不到盛梨子的筐，5年后，他成为第一个在城里买房的人。<BR>　　他又在自己的学习笔记上面写下一句话：要先于他人挖掘市场需求。<BR>　　再后来，一条铁路从这儿贯穿南北，这儿的人上车后，可以北到北京，南抵九龙。小村对外开放，果农也由单一的卖果开始到谈论果品加工及市场开发。就在一些人开始集资办厂的时候，那个村民在他的地头砌了一垛3米高、百米长的墙。这垛墙面向铁路，背依翠柳，两旁是一望无际的万亩梨园。坐火车经过这儿的人，在欣赏盛开的梨花时，会突然看到四个大字：可口可乐。据说这是五百里山川中惟一的一个广告，那垛墙的主人凭这垛墙，第一个走出了小村，因为他每年有4万元的额外收入。<BR>　　他再次在学习笔记上面写下一句话：如果能够排除竞争，你必然能够成为最大的赢家。</P>
<P>　　快乐工作提示：<BR>　　与其说他是一个天才经营者，不如说他是一个善于学习和总结的人。商业世界中，与其说是大鱼吃小鱼，快鱼吃慢鱼，不如说是聪明鱼吃愚笨鱼。<BR>　　而聪明往往来源于不断的总结、学习和创新。<BR>　　工作能够有所学，有所长进，自然更容易做到快乐工作。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; －－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</P>
<P>　　一个老人在高速行驶的火车上，不小心把刚买的新鞋从窗口掉了一只，周围的人倍感惋惜，不料老人立即把第二只鞋也从窗口扔了下去。这举动更让人大吃一惊。<BR>　　老人解释说：“这一只鞋无论多么昂贵，对我而言已经没有用了，如果有谁能捡到一双鞋子，说不定他还能穿呢！”</P>
<P>　　快乐工作提示：<BR>　　在工作中，有时为他人做嫁衣也特有一份成就感，并且一定会为你赢得更多的朋友。这自然使你的工作快乐得多。<BR>　　这也是“双赢思维”的一种体现。希望别人为自己做些什么的同时也想想自己能够为别人做些什么吧！建立有效的人际关系往往能够为你带来巨大的能量。</P>
<P>&nbsp;&nbsp;&nbsp; －－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</P>
<P>　　 一个年纪很大的木匠就要退休了，他告诉他的老板：他想要离开建筑业，然后跟妻子及家人享受一下轻松自在的生活。虽然他也会惦记这段时间里，还算不错的薪水，不过他还是觉得需要退休了，生活上没有这笔钱，也是过得去的！<BR>　　老板实在有点舍不得这样好的木匠离去，所以希望他能在离开前，再盖一栋具有个人风格的房子来。木匠虽然答应了，不过可以发现这一次他并没有很用心地盖房子。他草草地用了劣质的材料，就把这间屋子盖好了。<BR>　　落成时，老板来了，顺便也检查了一下房子，然后把大门的钥匙交给这个木匠说：“这间就是你的房子了，这是我送给你的一个礼物！”<BR>　　木匠实在是太惊讶了！也有点丢脸！因为如果他知道这间房子是他自己的，他一定会用最好的建材，用最精致的技术来把它盖好。然而，现在他却为自己造成了一个无法弥补的遗憾。&nbsp;&nbsp;&nbsp; </P>
<P>　　快乐工作提示：<BR>　　聪明人任何时候都会把他所服务的公司当作自己的公司一般。这当然不是自欺欺人，而是聪明人知道，只有具备这样一种主人翁精神，他才能够最大限度地从工作中学习，才能够最大限度地受益，才能够最大限度地做到快乐工作。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; －－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</P>
<P>　　一位父亲下班回家很晚了，他很累并有点烦，发现5岁的儿子靠在门旁等他。“爸，我可以问你一个问题吗？”<BR>　　“什么问题？”“爸，你一小时可以赚多少钱？”“这与你无关，你为什么要问这个问题？”父亲生气地问。<BR>　　“我只是想知道，请告诉我，你一小时赚多少钱？”小孩哀求道。“假如你一定要知道的话，我一小时赚20美金。”<BR>　　“哦，”小孩低下了头，接着又说，“爸，可以借我10美金吗？”父亲发怒了：“如果你只是借钱去买那些无聊的玩具的话，给我回到你的房间，并躺在床上好好想想为什么你会那么自私。我每天长时间辛苦地工作着，没时间和你玩小孩子的游戏。”<BR>　　小孩安静地回到自己的房间并关上门。<BR>　　父亲坐下来还在生气。过了一会儿，他平静了下来。开始想，也许他对孩子太凶了——或许孩子真的想买什么有用的东西，再说他平时很少要过钱。<BR>　　父亲走进小孩的房间：“你睡了吗，孩子？”“还没有，爸，我还醒着。”小孩回答。<BR>　　“我刚刚可能对你太凶了，”父亲说，“我将今天的气都爆发出来了——这是你要的10美金。”“爸，谢谢你。”小孩子欢快地从枕头底下拿出一些零碎的钞票来，慢慢地数着。<BR>　　“为什么你已经有钱了还要呢？”父亲生气地问。<BR>　　“因为这之前还不够，但现在足够了。”小孩回答，“爸，现在我有20美金了，我可以向你买一个小时的时间吗？明天请你早一点回家——我想和你一起吃晚餐。” </P>
<P>　　快乐工作提示：<BR>　　无论工作令你有多烦恼和困苦，都不能够将气恼转移到家人的身上，这不仅是拿别人的错误惩罚自己，更是伤害自己最亲近的人的愚蠢表现。在关注工作与成就的同时也关注心情与家人,这会让你的心更平衡,工作也显得更有意义。</P>
<P>&nbsp;&nbsp;&nbsp; －－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</P>
<P>　　有一支淘金队伍在沙漠中行走，大家都步履沉重，痛苦不堪，只有一个人快乐的走着。<BR>　　别人问：“你为何如此的惬意？”他笑着说：“因为我带的东西最少。” </P>
<P>　　快乐工作提示：<BR>　　原来快乐如此简单，只要放弃一些自己难以承担的负累，少一些苛求，我们就可以做到知足常乐了。 </P>
<P>&nbsp;</P>
<P>This entry was posted on Monday, March 21st, 2005 at 5:36 pm and is filed under 网络文摘. You can follow any responses to this entry through the RSS 2.0 feed. You can also bookmark this on del.icio.us, or check the cosmos, or trackback from your own site. </P>
<P>No Comments ? <BR>No comments yet.</P>
<P>Leave a comment<BR>You must be logged in to post a comment.</P>
<P>? 我们拿什么来改变中国？&nbsp;&nbsp;&nbsp; 对于改变中国这个讨论组的理解 ?</P>
<P>TAGS:&nbsp; 生活 网络 感悟 工作 阅读 空间 WebSite 博客 设计 Blog 免费 学习 Flickr 越野骆驼 搜索 Google 邮箱 照片 RSS 域名 摄影 励志 试用 模板 游戏 旅行 Yahoo 电影 合租 WordPress Wargame Gmail Fotolog DVD Group Google Talk SEO Website Ricoh MSN Live Mail Hotmail 网络.工作 情人节 数码相机 咖啡 创业 关键词 服务器 源码 门户 Baidu 网络广告 网站 程序 Design </P>
<P>Login　Admin　RSS　Comments RSS　My Fotolog　My Delicious　Google Analytics　Google Calendar　My Favoor</P>
<P>除非特别声明，本站内容和作品都按照创作共用方式授权。你可以转载、发表但必须基于下列条件：<BR>1、注明作者名字和出处；2、非商业用途；3、保持一致。<BR>? 2000-2006 Sinid.COM All Rights Reserved . Creative Commons 2.5 . Code by WordPress . Stat by VeryStat<BR></P>]]></description>
</item><item>
<title><![CDATA[javascript版本的HashMap的使用方法]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=nobdy&amp;id=12670</link>
<author>nobdy</author>
<pubDate>2006/3/18 17:54:22</pubDate>
<description><![CDATA[<P><A class=black-s>虽然在网上已有javascript版本的HashMap的实现代码，但是并没有给出具体的使用方法，于是在这里给出其简单的使用过程</A>。</P>
<P>&nbsp; 一、HashMap.js的代码：</P>
<P>/**<BR>&nbsp;* used like java.lang.HashMap<BR>&nbsp;*/</P>
<P><BR>function HashMap() {<BR>&nbsp; private:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.len = 8;<BR>&nbsp; this.table = new Array();<BR>&nbsp; this.length = 0;<BR>&nbsp; this.hash = hash;<BR>&nbsp; function hash(x) {<BR>&nbsp;&nbsp;&nbsp; var h = x.hashCode();<BR>&nbsp;&nbsp;&nbsp; h += ~(h &lt;&lt; 9);<BR>&nbsp;&nbsp;&nbsp; h ^= (h &gt;&gt;&gt; 14);<BR>&nbsp;&nbsp;&nbsp; h += (h &lt;&lt; 4);<BR>&nbsp;&nbsp;&nbsp; h ^= (h &gt;&gt;&gt; 10);<BR>&nbsp;&nbsp;&nbsp; return h;<BR>&nbsp; }</P>
<P>&nbsp; this.rehash = rehash;<BR>&nbsp; function rehash() {</P>
<P>&nbsp;&nbsp;&nbsp; var oldTable = this.table;</P>
<P>&nbsp;&nbsp;&nbsp; this.table = new Array();</P>
<P>&nbsp;&nbsp;&nbsp; //transfer<BR>&nbsp;&nbsp;&nbsp; for (var i = 0; i &lt; oldTable.length; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var e = oldTable[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e != null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oldTable[i] = null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var next = e.next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var j = this.indexFor(e.hash);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.next = this.table[j];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.table[j] = e;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e = next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } while (e != null);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; //alert("rehash to :"+this.len);<BR>&nbsp; }</P>
<P><BR>&nbsp; this.indexFor = indexFor;<BR>&nbsp; function indexFor(h) {</P>
<P>&nbsp;&nbsp;&nbsp; var index = h &amp; (this.len - 1);<BR>&nbsp;&nbsp;&nbsp; return index;<BR>&nbsp; }</P>
<P>&nbsp; function Entry(h, k, v, n) {</P>
<P>&nbsp;&nbsp;&nbsp; this.value = v;<BR>&nbsp;&nbsp;&nbsp; this.next = n;<BR>&nbsp;&nbsp;&nbsp; this.key = k;<BR>&nbsp;&nbsp;&nbsp; this.hash = h;</P>
<P>&nbsp;&nbsp;&nbsp; this.getKey = getKey;<BR>&nbsp;&nbsp;&nbsp; function getKey() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.key;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; this.getValue = getValue;<BR>&nbsp;&nbsp;&nbsp; function getValue() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.value;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; this.setValue = setValue;<BR>&nbsp;&nbsp;&nbsp; function setValue(newValue) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var oldValue = this.value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.value = newValue;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return oldValue;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; this.equals = equals;<BR>&nbsp;&nbsp;&nbsp; function equals(o) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var e = o;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var k1 = this.getKey();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var k2 = e.getKey();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var v1 = this.getValue();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var v2 = e.getValue();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (k1.equals(k2) &amp;&amp; v1.equals(v2));<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; this.hashCode = hashCode;<BR>&nbsp;&nbsp;&nbsp; function hashCode() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.key.hashCode() ^ this.value.hashCode();<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; this.toString = toString;<BR>&nbsp;&nbsp;&nbsp; function toString() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.getKey() + "=" + this.getValue();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }</P>
<P><BR>&nbsp; function HashIterator(table, index, ne) {</P>
<P>&nbsp;&nbsp;&nbsp; this.table = table;<BR>&nbsp;&nbsp;&nbsp; this.ne = ne;<BR>&nbsp;&nbsp;&nbsp; this.index = index;<BR>&nbsp;&nbsp;&nbsp; this.current = null;</P>
<P>&nbsp;&nbsp;&nbsp; this.hasNext = hasNext;<BR>&nbsp;&nbsp;&nbsp; function hasNext() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.ne != null;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; this.next = next;<BR>&nbsp;&nbsp;&nbsp; function next() {</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var e = this.ne;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e == null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw "No such Element";</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var n = e.next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var t = this.table;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var i = this.index;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (n == null &amp;&amp; i &gt; 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n = t[--i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.index = i;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.ne = n;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.current = e;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.current;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }</P>
<P><BR>&nbsp; public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.size = size;<BR>&nbsp; function size() {<BR>&nbsp;&nbsp;&nbsp; return this.length;<BR>&nbsp; }</P>
<P><BR>&nbsp; this.isEmpty = isEmpty;<BR>&nbsp; function isEmpty() {<BR>&nbsp;&nbsp;&nbsp; return this.length == 0;<BR>&nbsp; }</P>
<P>&nbsp; this.get = get;<BR>&nbsp; function get(key) {<BR>&nbsp;&nbsp;&nbsp; var hash = this.hash(key);<BR>&nbsp;&nbsp;&nbsp; var i = this.indexFor(hash);</P>
<P>&nbsp;&nbsp;&nbsp; var e = this.table[i];</P>
<P>&nbsp;&nbsp;&nbsp; while (true) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e == null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.hash == hash &amp;&amp; key.equals(e.key))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return e.value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e = e.next;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp; }</P>
<P>&nbsp; this.containsKey = containsKey;<BR>&nbsp; function containsKey(key) {<BR>&nbsp;&nbsp;&nbsp; var hash = this.hash(key);<BR>&nbsp;&nbsp;&nbsp; var i = this.indexFor(hash);<BR>&nbsp;&nbsp;&nbsp; var e = this.table[i];</P>
<P>&nbsp;&nbsp;&nbsp; while (e != null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.hash == hash &amp;&amp; key.equals(e.key))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e = e.next;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return false;<BR>&nbsp; }</P>
<P><BR>&nbsp; this.put = put;<BR>&nbsp; function put(key, value) {<BR>&nbsp;&nbsp;&nbsp; var hash = this.hash(key);<BR>&nbsp;&nbsp;&nbsp; var i = this.indexFor(hash);</P>
<P><BR>&nbsp;&nbsp;&nbsp; for (var e = this.table[i]; e != null; e = e.next) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.hash == hash &amp;&amp; key.equals(e.key)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var oldValue = e.value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.value = value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return oldValue;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; this.addEntry(hash, key, value, i);</P>
<P>&nbsp;&nbsp;&nbsp; var r = Math.ceil(this.length * 1.5);</P>
<P>&nbsp;&nbsp;&nbsp; if (r &gt; this.len) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.len = this.len &lt;&lt; 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.rehash();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return null;<BR>&nbsp; }</P>
<P>&nbsp; this.putAll = putAll;<BR>&nbsp; function putAll(map) {<BR>&nbsp;&nbsp;&nbsp; var mod = false;<BR>&nbsp;&nbsp;&nbsp; for (var it = map.iterator(); it.hasNext();) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var e = it.next();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (this.put(e.getKey(), e.getValue())) mod = true;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }</P>
<P><BR>&nbsp; this.remove = remove;<BR>&nbsp; function remove(key) {<BR>&nbsp;&nbsp;&nbsp; var e = this.removeEntryForKey(key);</P>
<P>&nbsp;&nbsp;&nbsp; return (e == null ? null : e.value);<BR>&nbsp; }</P>
<P>&nbsp; this.removeEntryForKey = removeEntryForKey;<BR>&nbsp; function removeEntryForKey(key) {<BR>&nbsp;&nbsp;&nbsp; var hash = this.hash(key);<BR>&nbsp;&nbsp;&nbsp; var i = this.indexFor(hash);</P>
<P>&nbsp;&nbsp;&nbsp; var prev = this.table[i];<BR>&nbsp;&nbsp;&nbsp; var e = prev;</P>
<P>&nbsp;&nbsp;&nbsp; while (e != null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var next = e.next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.hash == hash &amp;&amp; key.equals(e.key)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.length--;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (prev.equals(e))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.table[i] = next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prev.next = next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return e;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prev = e;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e = next;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return e;<BR>&nbsp; }</P>
<P>&nbsp; this.clear = clear;<BR>&nbsp; function clear() {<BR>&nbsp;&nbsp;&nbsp; for (var i = 0; i &lt; this.table.length; i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.table[i] = null;<BR>&nbsp;&nbsp;&nbsp; this.length = 0;<BR>&nbsp; }</P>
<P>&nbsp; this.containsValue = containsValue;<BR>&nbsp; function containsValue(value) {<BR>&nbsp;&nbsp;&nbsp; if (value == null) return false;</P>
<P>&nbsp;&nbsp;&nbsp; var tab = this.table;<BR>&nbsp;&nbsp;&nbsp; for (var i = 0; i &lt; tab.length; i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (var e = tab[i]; e != null; e = e.next)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (value.equals(e.value))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<BR>&nbsp;&nbsp;&nbsp; return false;<BR>&nbsp; }</P>
<P><BR>&nbsp; this.addEntry = addEntry;<BR>&nbsp; function addEntry(hash, key, value, bucketIndex) {<BR>&nbsp;&nbsp;&nbsp; this.table[bucketIndex] = new Entry(hash, key, value, this.table[bucketIndex]);<BR>&nbsp;&nbsp;&nbsp; this.length++;<BR>&nbsp; }</P>
<P><BR>&nbsp; this.iterator = iterator;<BR>&nbsp; function iterator() {<BR>&nbsp;&nbsp;&nbsp; var i = this.table.length;</P>
<P>&nbsp;&nbsp;&nbsp; var next = null;<BR>&nbsp;&nbsp;&nbsp; while (i &gt; 0 &amp;&amp; next == null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next = this.table[--i];<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; return new HashIterator(this.table, i, next);<BR>&nbsp; }</P>
<P>&nbsp; this.hashCode = hashCode;<BR>&nbsp; function hashCode() {<BR>&nbsp;&nbsp;&nbsp; var h = 0;<BR>&nbsp;&nbsp;&nbsp; for (var it = this.iterator(); it.hasNext();) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; h += it.next().hashCode();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return h;<BR>&nbsp; }<BR>&nbsp; this.equals = equals;<BR>&nbsp; function equals(map) {<BR>&nbsp;&nbsp;&nbsp; if (map.size() != this.size()) return false;</P>
<P>&nbsp;&nbsp;&nbsp; for (var it = this.iterator(); it.hasNext();) {</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var e = it.next();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var key = e.getKey();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var value = e.getValue();</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!value.equals(map.get(key))) return false</P>
<P>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return true;<BR>&nbsp; }<BR>}</P>
<P>&nbsp; 二、JavaString.js的代码：</P>
<P>/**<BR>&nbsp;use as java.lang.String for java programmer!<BR>&nbsp;becasuse String is a Object of JavaScirpt,we named it as JavaString!<BR>&nbsp;String is used most commonly in JavaScript<BR>&nbsp;we can use JavaString in ArrayList,HashMap,HashSet etc!<BR>&nbsp;*/<BR>function testJavaString() {<BR>&nbsp; alert("JavaStrint test begin:");<BR>&nbsp; try {<BR>&nbsp;&nbsp;&nbsp; var javaStr = new JavaString("Hello World");</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.length() == 11);</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.charAt(2) == 'l');</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.equals(new JavaString("Hello World")));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.equalsIgnoreCase("hello world"));</P>
<P><BR>&nbsp;&nbsp;&nbsp; assert(javaStr.compareTo("Hello") &gt; 0);<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.compareTo("MX") &lt; 0);<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.compareTo("Hello World") == 0);</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.startsWith("Hello "));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.endsWith("orld"));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.indexOf("o") == 4);</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.lastIndexOf("o") == 7);</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.concat(" WSG").equals(new JavaString("Hello World WSG")));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.replace("o", "").equals(new JavaString("Hell World")));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.replaceAll("o", "").equals(new JavaString("Hell Wrld")));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.matches("Hell.+"));</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.split(" ").length == 2);<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.split("o")[1] == " W");<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.toCharArray().length == 11);<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.toCharArray()[4] == "o");</P>
<P>&nbsp;&nbsp;&nbsp; assert(javaStr.toString() == "Hello World");<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.toUpperCase().equals(new JavaString("HELLO WORLD")));<BR>&nbsp;&nbsp;&nbsp; assert(javaStr.toLowerCase().equals(new JavaString("hello world")));</P>
<P>&nbsp; }<BR>&nbsp; catch(e) {<BR>&nbsp;&nbsp;&nbsp; alert(e);<BR>&nbsp; }<BR>&nbsp; alert("JavaString test end");<BR>}</P>
<P>function JavaString(val) {<BR>&nbsp; private:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.value = val;</P>
<P>&nbsp; public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.length = length;<BR>&nbsp; function length() {<BR>&nbsp;&nbsp;&nbsp; return this.value.length;<BR>&nbsp; }<BR>&nbsp; this.charAt = charAt;<BR>&nbsp; function charAt(index) {<BR>&nbsp;&nbsp;&nbsp; return this.value.charAt(index);<BR>&nbsp; }</P>
<P>&nbsp; this.equals = equals;<BR>&nbsp; function equals(str) {<BR>&nbsp;&nbsp;&nbsp; return this.value == str.value;<BR>&nbsp; }</P>
<P>&nbsp; this.equalsIgnoreCase = equalsIgnoreCase;<BR>&nbsp; function equalsIgnoreCase(str) {<BR>&nbsp;&nbsp;&nbsp; return this.value.toUpperCase() == str.toUpperCase();<BR>&nbsp; }</P>
<P>&nbsp; this.compareTo = compareTo;<BR>&nbsp; function compareTo(str) {<BR>&nbsp;&nbsp;&nbsp; if (this.value == str.value) return 0;<BR>&nbsp;&nbsp;&nbsp; else if (this.value &gt; str.value) return 1;<BR>&nbsp;&nbsp;&nbsp; else return -1;<BR>&nbsp; }</P>
<P>&nbsp; this.compareToIgnoreCase = compareToIgnoreCase;<BR>&nbsp; function compareToIgnoreCase(str) {<BR>&nbsp;&nbsp;&nbsp; var a = this.value.toUpperCase();<BR>&nbsp;&nbsp;&nbsp; var b = str.toUpperCase();<BR>&nbsp;&nbsp;&nbsp; if (a == b) return 0;<BR>&nbsp;&nbsp;&nbsp; else if (a &gt; b) return 1;<BR>&nbsp;&nbsp;&nbsp; else return -1;<BR>&nbsp; }</P>
<P>&nbsp; this.startsWith = startsWith;<BR>&nbsp; function startsWith(prefix) {<BR>&nbsp;&nbsp;&nbsp; return this.value.substring(0, prefix.length) == prefix;<BR>&nbsp; }</P>
<P>&nbsp; this.endsWith = endsWith;<BR>&nbsp; function endsWith(suffix) {<BR>&nbsp;&nbsp;&nbsp; return this.value.substring(this.value.length - suffix.length) == suffix;<BR>&nbsp; }</P>
<P>&nbsp; this.hashCode = hashCode;<BR>&nbsp; function hashCode() {<BR>&nbsp;&nbsp;&nbsp; var h = 0;<BR>&nbsp;&nbsp;&nbsp; for (var i = 0; i &lt; this.value.length; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; h = 31 * h + this.value.charCodeAt(i);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return h;<BR>&nbsp; }</P>
<P>&nbsp; this.indexOf = indexOf;<BR>&nbsp; function indexOf(ch) {<BR>&nbsp;&nbsp;&nbsp; return this.value.indexOf(ch);<BR>&nbsp; }</P>
<P>&nbsp; this.lastIndexOf = lastIndexOf;<BR>&nbsp; function lastIndexOf(ch) {<BR>&nbsp;&nbsp;&nbsp; return this.value.lastIndexOf(ch);<BR>&nbsp; }</P>
<P><BR>&nbsp; this.substring = substring;<BR>&nbsp; function substring() {<BR>&nbsp;&nbsp;&nbsp; var args = substring.arguments;<BR>&nbsp;&nbsp;&nbsp; var begin = args[0];</P>
<P>&nbsp;&nbsp;&nbsp; if (args.length &gt; 1) return new JavaString(this.value.substring(begin, args[1]));<BR>&nbsp;&nbsp;&nbsp; else return new JavaString(this.value.substring(begin));<BR>&nbsp; }</P>
<P><BR>&nbsp; this.concat = concat;<BR>&nbsp; function concat(str) {<BR>&nbsp;&nbsp;&nbsp; return new JavaString(this.value + str);<BR>&nbsp; }</P>
<P>&nbsp; this.replace = replace;<BR>&nbsp; function replace(oldStr, newStr) {<BR>&nbsp;&nbsp;&nbsp; return new JavaString(this.value.replace(oldStr, newStr));<BR>&nbsp; }</P>
<P><BR>&nbsp; this.matches = matches;<BR>&nbsp; function matches(regex) {<BR>&nbsp;&nbsp;&nbsp; return this.value.match(regex) != null;<BR>&nbsp; }</P>
<P>&nbsp; this.replaceFirst = replaceFirst;<BR>&nbsp; function replaceFirst(regex, replacement) {<BR>&nbsp;&nbsp;&nbsp; return new JavaString(this.value.replace(regex, replacement));<BR>&nbsp; }</P>
<P>&nbsp; this.replaceAll = replaceAll;<BR>&nbsp; function replaceAll(regex, replacement) {<BR>&nbsp;&nbsp;&nbsp; var va = this.value;<BR>&nbsp;&nbsp;&nbsp; var temp = va.replace(regex, replacement);<BR>&nbsp;&nbsp;&nbsp; while (temp != va) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va = temp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp = va.replace(regex, replacement);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return new JavaString(va);<BR>&nbsp; }</P>
<P><BR>&nbsp; this.split = split;<BR>&nbsp; function split(sep) {<BR>&nbsp;&nbsp;&nbsp; return this.value.split(sep);<BR>&nbsp; }</P>
<P>&nbsp; this.toLowerCase = toLowerCase;<BR>&nbsp; function toLowerCase() {<BR>&nbsp;&nbsp;&nbsp; return new JavaString(this.value.toLowerCase());<BR>&nbsp; }</P>
<P>&nbsp; this.toUpperCase = toUpperCase;<BR>&nbsp; function toUpperCase() {<BR>&nbsp;&nbsp;&nbsp; return new JavaString(this.value.toUpperCase());<BR>&nbsp; }</P>
<P>&nbsp; this.toCharArray = toCharArray;<BR>&nbsp; function toCharArray() {<BR>&nbsp;&nbsp;&nbsp; var charArr = new Array();<BR>&nbsp;&nbsp;&nbsp; for (var i = 0; i &lt; this.value.length; i++) charArr[i] = this.value.charAt(i);<BR>&nbsp;&nbsp;&nbsp; return charArr;<BR>&nbsp; }</P>
<P>&nbsp; this.toString = toString;<BR>&nbsp; function toString() {<BR>&nbsp;&nbsp;&nbsp; return this.value;<BR>&nbsp; }</P>
<P>}<BR></P>
<P>&nbsp; 三、使用例子（MyHtml.html的内容）：</P>
<P><BR>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;<BR>&lt;html&gt;<BR>&nbsp; &lt;head&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;MyHtml.html&lt;/title&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;meta http-equiv="description" content="this is my page"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript" src="JavaString.js"&gt;&lt;/script&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript" src="HashMap.js"&gt;&lt;/script&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &lt;!--&lt;link rel="stylesheet" type="text/css" href="./styles.css"&gt;--&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; &lt;/head&gt;</P>
<P>&nbsp; &lt;body&gt;<BR>&nbsp; This is my HTML page. &lt;br&gt;<BR>&nbsp; &lt;SCRIPT type="text/javascript"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;!--<BR>&nbsp;&nbsp;&nbsp; function Person(i, n) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var id = "";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var name = "";</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id = i;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (n) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name = n;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getId() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function setId(parmId) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id = parmId;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getName() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return name;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function setName(parmName) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name = parmName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.getId = getId;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setId = setId;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.getName = getName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setName = setName;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; function useHashMap() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var hm = new HashMap();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var id1 = new JavaString("id1");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var simon = new Person();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; simon.setId(1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; simon.setName("Simon");</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var id2 = new JavaString("id2");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var john = new Person(2, "John");</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (hm.isEmpty()) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("empty");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("not empty");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hm.put(id1, simon);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hm.put(id2, john);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("after put\n&nbsp;&nbsp;&nbsp; person1: id = " + hm.get(id1).getId() +<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "; name = " + hm.get(id1).getName() + "\n&nbsp;&nbsp;&nbsp; person2: id = " +<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hm.get(id2).getId() + "; name = " + hm.get(id2).getName());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch(e) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; useHashMap();<BR>&nbsp;&nbsp;&nbsp; // --&gt;<BR>&nbsp; &lt;/SCRIPT&gt;<BR>&nbsp; &lt;/body&gt;<BR>&lt;/html&gt;<BR></P>
<P>&nbsp; 四、总结：</P>
<P>&nbsp; 在使用HashMap.js时，key对象必须有自己的hashCode函数，否则无法使用HashMap.js。</P>
<P>&nbsp;</P>]]></description>
</item>
</channel>
</rss>