⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandresources.java

📁 通俗的讲
💻 JAVA
字号:
// Copyright (c) 2005 Sony Ericsson Mobile Communications AB
//
// This software is provided "AS IS," without a warranty of any kind. 
// ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, 
// INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A 
// PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. 
//
// THIS SOFTWARE IS COMPLEMENTARY OF JAYWAY AB (www.jayway.se)

/*///////////////////////////////////////////////////////////////////////////////
//文档生成日期:2005.11.3
//
//(1)概述:
//类名称:CommandResources
//类说明:
//	提供各种资源的统一入口,比如图片、字符串。
  
//所在子系统:MIMESMSnotifyPushRegistry
//
//系统总描述:
	    本工程发送一个MIME头的短信给目标手机。MIME头中指明了对方应该如何处理。
	    对方手机收到后,触发注册了PushRegistry的MIDlet应用,并解析短信,
	    按照指明的命令操作。


	 子系统描述:
		发送一个MIME头的短信给目标手机.

//(2)历史记录:
//创建人: 郑昀(2005.11.3)
//联系我: Google Talk >> zhengyun@gmail.com
//Blogs:    http://blog.csdn.net/zhengyun_ustc/以及http://www.cnblogs.com/zhengyun_ustc

//(3)版权声明:
//我这个版本的MIMESMSnotifyPushRegistry,
//j2me客户端代码仅仅允许您借鉴,但不得用于商业用途,除非得到郑昀本人的授权。本人保留所有权利。

////////////////////////////////////////////////////////////////////*/
package com.ultrapower.common;

import java.io.InputStream;
import java.util.Hashtable;

import javax.microedition.lcdui.Image;

/**
 * Primitive resource mapper.
 * 
 * @author Peter Andersson & zhengyun
 */
public class CommandResources
{	
  // Text keys
  private static int TXTID = 0;
  // text / page titles
  public static final int TXT_T_APP            = TXTID++;
    // RMS Name.,这一个是为了存储本应用的相关设置
  public static final int TXT_RMS_APP_STORENAME    = TXTID++;
  
  /*
   * 各个界面的标题文字
   */
  public static final int TXT_T_SENDMMS	  = TXTID++;
  public static final int TXT_T_SETTINGS       = TXTID++;
  public static final int TXT_T_ABOUT          = TXTID++;
  
  /*
   * 功能菜单的菜单选项文字
   */
  public static final int TXT_C_SENDMMS   	  = TXTID++;
  public static final int TXT_C_SETTINGS       = TXTID++;
  public static final int TXT_C_OK             = TXTID++;
  public static final int TXT_C_CANCEL         = TXTID++;
  public static final int TXT_C_BACK           = TXTID++;
  public static final int TXT_C_SAVESETTINGS   = TXTID++;
  public static final int TXT_C_QUIT           = TXTID++;
  
  /*
   * 关于我关于这个程序的说明性文字
   */
  public static final int TXT_ABOUT            = TXTID++;
  
  /*
   * 报告发送短信的正在进行中的信息文字
   */
  public static final int TXT_T_SEND_PROGRESS  = TXTID++;
  
  /*
   * 报告发送短信的成功或错误的信息文字
   */
  public static final int TXT_SENDERROR_TITLE  = TXTID++;
  public static final int TXT_SENDERROR_MSG    = TXTID++;
  public static final int TXT_SENDSUCC_TITLE   = TXTID++;
  public static final int TXT_SENDSUCC_MSG     = TXTID++;
  
  /*
   * 提供默认的短信端口号
   */
  public static final int TXT_T_DEFAULT_SMS_PORT  = TXTID++;
  /*
   * 提供默认的短信协议号
   */
  public static final int TXT_T_DEFAULT_SMS_PORTOCOL  = TXTID++;
  
    /*
   * 在这个程序的RMS存储的项目的key.
   */
  public static final int RMS_KEY_SMSPORT			  	 = 0;

  // Image keys
  private static final int OFFSET_IMG          = 100;
  public static final int IMG_ABOUT   	      = 100;
  public static final int IMG_COMMAND   	      = 101;
  public static final int IMG_EXIT    	      = 102;
  public static final int IMG_SETTING	          = 103;
  public static final int IMG_LOGO	          = 104;
  
  // Text data
  protected static final char[][] TEXTBUF = {
    "MIMESend".toCharArray(),
    
    /*
     * RMS Name
     */
    "sendmmsRMS".toCharArray(),
    
	  /*
	   * 各个界面的标题文字
	   */
    "消息发送".toCharArray(),
	"设置".toCharArray(),
    "关于".toCharArray(),
        
    
	  /*
	   * 功能菜单的菜单选项文字
	   */
    "发送消息".toCharArray(),
	"设置".toCharArray(),
	"确定".toCharArray(),
	"取消".toCharArray(),
	"返回".toCharArray(),
	"保存当前设置".toCharArray(),
    "退出".toCharArray(),

	  /*
	   * 关于我关于这个程序的说明性文字
	   */
    ("MIMESend-手机JavaME利用WMA发送包含特定头的短信给指定手机号码的指定端口,由郑昀编写,为了演示WMA和PushRegistry联合使用方法,并非商业应用,保留郑昀所有权利。\n" +
		"应用于MIDP2.0的手机。\n" +
        "GoogleTalk>> zhengyun@gmail.com  \n" +
        "Blog>> http://zhengyun_ustc.cnblogs.com/ \n" +
        "Version>> 0.1.0 \n" +
        "Date>> 2005.11.3").toCharArray(),
    
	  /*
	   * 报告发送短信的正在进行中的信息文字
	   */
        "正在发送中...".toCharArray(),

	    /*
	   * 报告发送短信的成功或错误的信息文字
	   */
     "发送错误".toCharArray(),
     "发送时发生异常:".toCharArray(),
     
     "上次发送成功".toCharArray(),
     "WMA测试成功!!".toCharArray(),
     
     
     /*
   * 提供默认的短信端口号
   */
	 "8341".toCharArray(),
	 
	  /*
   * 提供默认的短信协议号
   */
	 "sms://".toCharArray(),
	 
  };
  
  /** Image cache */
  protected static Hashtable m_images = new Hashtable();
  
  // Image resource names
  protected static final String[] IMGNAME_MAP ={
	  "about.png",
	  "command.png",
	  "exit.png",
	  "setting.png",
	  "logo.png",
  };
  
  /**
   * Returns specified text as character array.
   * @param id  The id of the text.
   * @return    A text as char array.
   */
  public static char[] getChars(int id)
  {
    return TEXTBUF[id];
  }
  
  /**
   * Returns specified text as string.
   * @param id  The id of the text.
   * @return    A text as String.
   */  
  public static String getString(int id)
  {
    return new String(getChars(id));
  }
  
  /**
   * Returns specified image.
   * @param id  The id of the image.
   * @return    An image.
   */
  public static synchronized Image getImage(int id)
  {
    id -= OFFSET_IMG;
    Image img = (Image)m_images.get(new Integer(id));
    if (img == null)
    {
      try
      {
		  /*
		   * 注意原来这里写的是"/" +,始终无法加载图像;
		   * 所以我改为了"/res/" + 
		   */
        img = Image.createImage("/res/icons/" + IMGNAME_MAP[id]);
		System.out.println("get image:/res/icons/" + IMGNAME_MAP[id]);
        m_images.put(new Integer(id), img);
      }
      catch (Exception e)
      {
        System.out.println("Error getting resource img " + IMGNAME_MAP[id]
           + ">>" + e.getMessage());
        e.printStackTrace();
      }
    }
    return img;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -