📄 smssettings.java
字号:
/**
//文档生成日期:2005.11.3
//
//(1)概述:
//类名称:SMSSettings
//类说明:
// 提供存储和读取RMS中关于本应用所需要的几个参数的功能
*
//所在子系统: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.model;
import javax.microedition.rms.RecordStoreException;
import com.ultrapower.common.CommandResources;
import com.ultrapower.facade.RmsFacade;
/**********************************************************
//SMSSettings
//
//Class Description:
// 提供存储和读取RMS中关于本应用所需要的几个参数的功能
//
//Author:
// zhengyun@ultrapower 2005.11.3
//
**********************************************************/
public class SMSSettings {
private static SMSSettings m_settings;
/**
* Singleton pattern is used to return
* only one instance of SMSSettings
*/
public static synchronized SMSSettings getInstance(){
if( m_settings == null ) {
System.out.println("!-- SMSSettings::getInstance --!\n");
m_settings = new SMSSettings();
try
{
m_settings.load();
System.out.println("选择从RMS中读取设置");
}
catch(Exception exc)
{
m_settings.InitDefaultSettings();
System.out.println("从RMS中无法读取,改为默认数值");
}
}
return m_settings;
}
/** "短信发送时必须指定这个端口号" */
protected char[] m_sSMSPort;
///////////////////////////////////////////////////////////////////
//
/**
* @return 短信发送时必须指定这个端口号.
*/
public char[] getSMSPort()
{
return m_sSMSPort;
}
///////////////////////////////////////////////////////////////////
//
/**
* set "短信发送时必须指定这个端口号".
* @param 短信发送时必须指定这个端口号.
*/
public void setSMSPort(char[] value)
{
m_sSMSPort = value;
}
/////////////////////////////////////////////////////////////
/**
* 将当前用户设置的各项参数写入到RMS中.
*/
public void save()
{
RmsFacade.setChars(CommandResources.RMS_KEY_SMSPORT,
m_sSMSPort);
}
public void save(String port)
{
m_sSMSPort = port.toCharArray();
RmsFacade.setChars(CommandResources.RMS_KEY_SMSPORT,
m_sSMSPort);
}
/**
* 直接从RMS将各项参数提取出来
*/
public void load()
throws RecordStoreException
{
m_sSMSPort = RmsFacade.getChars(CommandResources.RMS_KEY_SMSPORT);
if(m_sSMSPort.length > 0)
System.out.println("有数据:" + m_sSMSPort);
else
{
// 说明没有RMS记录,可能是第一次运行本应用
throw new RecordStoreException();
}
}
/**
* Initializes this videoim
*/
public void InitDefaultSettings()
{
m_sSMSPort =
CommandResources.getChars(CommandResources.TXT_T_DEFAULT_SMS_PORT);
// 将默认的数值写入RMS
save();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -