#
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/170016
發(fā)表時(shí)間: 2008年03月11日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
對(duì)于手機(jī)理財(cái)JAcount,我在SE K750, SE P990,Philips768, Nokia2630上進(jìn)行過(guò)完整的測(cè)試,都沒(méi)有什么問(wèn)題.最近,在移動(dòng)那里一元購(gòu)機(jī)了一臺(tái)Nokia6070,原以為與Nokia2630一樣是S40的機(jī)器,應(yīng)該沒(méi)什么問(wèn)題,結(jié)果余額表和收支表重復(fù)算兩次后出現(xiàn)了"應(yīng)用程序錯(cuò)誤",詳情是Array Index out of bounds,我估計(jì)是內(nèi)存不足,于是在重新開(kāi)啟程序,打開(kāi)了第一次收支表后檢查了內(nèi)存,還有300多K,再次打開(kāi)收支表,又出錯(cuò)了,還未搞清楚是什么原因,真有點(diǎn)失敗的感覺(jué),前一段時(shí)間在聊天時(shí)借了別人的Nokia N73,結(jié)果安裝時(shí)候就死機(jī)了,還沒(méi)機(jī)會(huì)檢查是什么問(wèn)題,現(xiàn)在先弄好Nokia 6070的問(wèn)題吧.唉!兼容性!
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/170016
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/169545
發(fā)表時(shí)間: 2008年03月09日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
唉,有貼代碼騙糧票的嫌疑呢,至少大家可以在這里看到各種設(shè)備的規(guī)格方法了.
public static boolean isBlackBerry()
{
return checkPlatform( "RIM" );
}
public static boolean checkPlatform( final String key )
{
final String platform = System.getProperty( "microedition.platform" );
return platform != null && platform.toUpperCase().indexOf(
key.toUpperCase()
) > -1;
}
public static boolean checkUserAgent( final String key )
{
final String userAgent = Application.getManager().getProperty(
"user-agent"
);
return userAgent != null && userAgent.toUpperCase().indexOf(
key.toUpperCase()
) > -1;
}
public static boolean checkPlatform( final String[] keys )
{
final int length = keys.length;
for( int i = 0; i < length; i++ )
{
if( checkPlatform( keys[i] ) )
{
return true;
}
}
return false;
}
public static boolean isNokia()
{
return checkPlatform( "Nokia" );
}
public static boolean isEmulator()
{
return checkPlatform( new String[] { "j2me", "SunMicrosystems_wtk" } );
}
public static boolean isSonyEricsson()
{
return checkPlatform( "SonyEricsson" );
}
public static boolean isSonyEricssonJP7()
{
return isSonyEricsson() && checkPlatform( JP7 );
}
public static boolean isSymbian()
{
return checkUserAgent( "SymbianOS" );
}
public static boolean isSeries60()
{
return checkUserAgent( "Series60" );
}
public static boolean isSeries60_2nd()
{
return checkUserAgent( "Series60/2" );
}
public static boolean isSeries60_3rd()
{
return checkUserAgent( "Series60/3" );
}
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/169545
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/169280
發(fā)表時(shí)間: 2008年03月08日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
public void main(){
Integer nullInt = null;
tryChangeInteger(nullInt);
if(nullInt == null){
System.out.println("\nThe Object nullInt not be changed.");
}else{
System.out.println("\nThe Object nullInt now is " + nullInt);
}
}
private void tryChangeInteger(Integer theInt){
theInt = new Integer(100);
}
// 控制臺(tái)應(yīng)打印出什么呢?(The Object nullInt not be changed.)
//
// 關(guān)鍵要理解好Java的參數(shù)傳遞是傳值而不是傳引用,因而在tryChangeInteger方法
// 里得到的theInt不是main方法里的nullInt,而是nullInt的副本,nullInt值并沒(méi)有被改變。
// 再請(qǐng)看以下代碼
public void main() {
char[] initChars = new char[10];
initChars[0] = 'a';
tryChangeCharArray(initChars);
if(initChars[0] == 'a'){
System.out.println("\nThe Object initChars[0] not be changed.");
}else{
System.out.println("\nThe Object initChars[0] now is " + initChars[0]);
}
}
private void tryChangeCharArray(char[] theChars){
if(theChars != null && theChars.length > 0){
theChars[0] = 'b';
}
}
// 控制臺(tái)應(yīng)打印出什么呢?(The Object initChars[0] now is b")
// Why?
// 弄明白了這個(gè),JAVA引用基本就明白了。
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/169280
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/168955
發(fā)表時(shí)間: 2008年03月07日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
以下代碼由bm.core.tools.DeviceInfo.java抽出,詳見(jiàn)該文件
private void testFontListBug()
{
if( isNokia() )
{
// 就算是Nokia的設(shè)備也要進(jìn)行一下測(cè)試來(lái)確定是否有這個(gè)Bug
final Font font = Font.getFont(
Font.FACE_PROPORTIONAL,
Font.STYLE_PLAIN,
Font.SIZE_SMALL
);
final List list = new List( "", List.IMPLICIT );
for( int i = 0; i < 3; i++ )
{
list.append( "", null );
}
for( int i = 0; i < 3; i++ )
{
list.setFont( i, font );
}
list.deleteAll();
try
{
for( int i = 0; i < 4; i++ )
{
list.append( "", null );
}
listFontBug = false;
}
catch( Throwable e )
{
listFontBug = true;
}
}
else
{
// 除Nokia設(shè)備外,其它設(shè)備都假定它有這個(gè)Bug
// 不知道實(shí)際上是不是這樣呢?我估計(jì)大部分的手機(jī)都有這個(gè)問(wèn)題
// 不然他不會(huì)這么做
listFontBug = true;
}
}
那么這個(gè)Bug是什么呢?
我在bm.mvc.ListBrowserView中找到如下代碼:
if( !DeviceInfo.getDeviceInfo().hasListFontBug() )
{
final int itemCount = list.size();
for( int i = 0; i < itemCount; i++ )
{
list.setFont( i, Util.SMALL_FONT );
}
}
也就是說(shuō),有這個(gè)Bug的設(shè)備不能將List的項(xiàng)的字體更改為SMALL_FONT
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/168955
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/168522
發(fā)表時(shí)間: 2008年03月06日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
private void doShow()
{
// This delays minimze the chance that a Nokia 6670 or Nokia S60 3rd
// edition device (might apply to other nokias) freez when showing a
// view. The total delay of 600ms, with this distribution seems to
// make it stable on E70 and E61. The delay is only applied to Nokia
// phones at this moment
if( displayable != null )
{
final Display display = Application.getManager().getDisplay();
delay();
delay();
display.setCurrent( displayable );
if( !DeviceInfo.isNokia() && focusedItem != null )
{
delay();
delay();
display.setCurrentItem( focusedItem );
}
setCurrent( this );
delay();
delay();
}
}
private void delay()
{
if( delay )
{
// Under some strange circumstances the Nokia 6670 crashes whitout this delay
try
{
Thread.sleep( 100 );
}
catch( InterruptedException e )
{
}
}
}
是否的確是這樣?天啊,誰(shuí)可以使用以上環(huán)境的設(shè)備給我測(cè)試一下我的手機(jī)理財(cái)JAccount呢?
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/168522
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/168521
發(fā)表時(shí)間: 2008年03月06日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
如果你用Eclipse開(kāi)發(fā)java應(yīng)用的話,我強(qiáng)烈建議你安裝它,這樣,你隨時(shí)可解開(kāi)jar文件瀏其他人特別是SUN公司的源代碼了(SUN的JAR沒(méi)有經(jīng)過(guò)混淆),對(duì)于學(xué)習(xí)java是十分有益而高效的.
Eclipse/軟件更新/查找與安裝/新建遠(yuǎn)程站點(diǎn)/地址為:http://www.technoetic.com/eclipse/update
安裝完成后,要使用時(shí),在包資源管理器上列出你要查看的class,雙擊該文件,會(huì)出現(xiàn)錯(cuò)誤提示,不理它,再雙擊一次就可以在編輯器上出現(xiàn)源代碼了!超方便!
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/168521
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/168482
發(fā)表時(shí)間: 2008年03月05日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
一個(gè)簡(jiǎn)單的高速對(duì)象緩存
public class SimpleCache
{
private static long wideHits;
private static long wideMisses;
private Hashtable cache;
private Vector stamps;
private int maxSize;
private long hits;
private long misses;
// ...部分省略
// 構(gòu)建函數(shù),根據(jù)SIZE構(gòu)建Cache和命中表
public SimpleCache( final int size )
{
this.maxSize = size;
cache = new Hashtable( size );
stamps = new Vector( size );
}
// ...部分省略
public void add( final Object key, final Object object )
{
// 為什么不直接使用cache而要使用另一個(gè)引用?
final Hashtable cache = this.cache;
if( !cache.containsKey( key ) )
{
if( cache.size() == maxSize )
{
discard(); // 如果Cache超過(guò)容量,按策略丟棄過(guò)時(shí)的對(duì)象
}
// 在Cache中加入這個(gè)對(duì)象
cache.put( key, object );
// 相應(yīng)也插入命中表第一位
stamps.insertElementAt( key, 0 );
}
else
{
// 更新Cache
cache.put( key, object );
// 也算命中一次
touch( key );
}
}
// ...部分省略
public synchronized Object get( final Object key )
{
final Object o = cache.get( key );
if( o != null )
{
hits++;
wideHits++;
// 算命中一次
touch( key );
}
else
{
misses++;
wideMisses++;
}
return o;
}
// ...部分省略
// 總是丟棄最后一個(gè)對(duì)象,
private void discard()
{
final Object key = stamps.lastElement();
stamps.removeElement( key );
cache.remove( key );
}
// 每次從Cache取用某key對(duì)象,都將它插到第一位
// 這樣不常用的對(duì)象將很快會(huì)被推至最后一位
private void touch( final Object key )
{
stamps.removeElement( key );
stamps.insertElementAt( key, 0 );
}
}
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/168482
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/167866
發(fā)表時(shí)間: 2008年03月04日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
感謝Cavaj!在Eclipse在包資源管理器上查到RecordStore.class在midpapi10.jar中
將C:\WTK22\lib\midpapi10.jar解開(kāi),然后用Cavaj!反編譯RecordStore.class,得到了兩個(gè)類,果然有些料到,不僅有記錄鏈表,還有自由鏈表,自由空間重用與分裂...,用代碼說(shuō)話(個(gè)人做了一些修改和注釋)!
------------------------
寫在最后:原來(lái)研究它的目的是在利用J2me可選包FileConnection方式來(lái)實(shí)現(xiàn)手機(jī)理財(cái)JAccount
http://iwinyeah.javaeye.com/admin/categories/27410,但經(jīng)分析后,FileConnection沒(méi)有實(shí)現(xiàn)skip()方法,換言之,不能對(duì)文件進(jìn)行自由讀寫,因而該計(jì)劃也落了空.
在此也感謝無(wú)花
http://wuhua.javaeye.com/的提醒,的確,手機(jī)實(shí)現(xiàn)的FileConnection的安全檢查太多了,嚴(yán)重影響用戶體驗(yàn),不太合適用于這種方式的應(yīng)用.
新計(jì)劃是手機(jī)理財(cái)JAccount上增加備份與恢復(fù)功能(read和append方式是FileConnection所支持的)由于備份和恢復(fù)無(wú)須經(jīng)常地使用,用戶也可接受.
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/167866
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/167074
發(fā)表時(shí)間: 2008年03月03日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
有一個(gè)英語(yǔ)學(xué)習(xí)的圈子,我不想加入,看到有人要記單詞,我也把我的方法寫在下面:
個(gè)人經(jīng)驗(yàn):找一本7000單詞的字典,約100頁(yè)左右,每天反復(fù)記1頁(yè),未記好的用鉛筆打上標(biāo)記,第二天先復(fù)習(xí)以前打上標(biāo)記的單詞,已會(huì)的,將標(biāo)記刷掉,然后記新一頁(yè),如此堅(jiān)持,100天基本可記住7000單詞,然后加快速度,每天4頁(yè),再記一次,則功成矣!
看來(lái),弄一個(gè)手機(jī)記單詞的軟件也許不錯(cuò)呢,難度不大,如果真正有用,也許有一定市場(chǎng)呢,畢竟學(xué)生是消費(fèi)力很強(qiáng)的群體.
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/167074
網(wǎng)站:
JavaEye
作者:
iwinyeah
鏈接:
http://iwinyeah.javaeye.com/blog/167071
發(fā)表時(shí)間: 2008年03月03日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書(shū)面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
Event事件對(duì)象: 有如下屬性:
protected Integer type; // 事件類型,預(yù)定義了全局事件,改變語(yǔ)言事件和進(jìn)度事件
protected boolean consumed; // 事件是否已被處理
protected Hashtable attachments; // 以哈希表表示的與事件相關(guān)的對(duì)象附件
通過(guò)在靜態(tài)事件對(duì)象預(yù)先登記多個(gè)各種類型的事件監(jiān)聽(tīng)器,當(dāng)有事件發(fā)生時(shí),就可通過(guò)殂態(tài)事件對(duì)象將事件發(fā)送給事件監(jiān)聽(tīng)器進(jìn)行處理.事件監(jiān)聽(tīng)器收到事件后,可根據(jù)事件類型和附件作出響應(yīng),如果不想在它之后登記的監(jiān)聽(tīng)器再處理該事件,則將consumed設(shè)置為true.
代碼如下:
public static void dispatch( final Event event )
{
// 以下還未明白什么意義
// 如果是進(jìn)度事件并且當(dāng)前的線程已在后臺(tái)任務(wù)中登記則不處理?
if(
!event.type.equals( PROGRESS ) ||
!backgroundTasks.contains( Thread.currentThread() )
)
{
final Vector v = (Vector) listeners.get( event.type );
if( v != null )
{
final int count = v.size();
for( int i = 0; i < count && !event.consumed; i++ )
{
final EventListener listener = (EventListener) v.elementAt( i );
listener.handleEvent( event );
Thread.yield();
}
event.consumed = false;
}
}
}
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://iwinyeah.javaeye.com/blog/167071