?? msgqueryrsp.java
字號:
/**
*
*/
package com.aceway.vas.sjcraw.cbgp201.crm.rwm;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import com.aceway.vas.sjcraw.cbgp201.Msg;
import com.aceway.vas.sjcraw.cbgp201.common.DataFormat;
/**
* @標題: 華為彩鈴平臺接口規范
* @說明: 6.2.10.1.4 查詢個人鈴音庫操作
* @版權: Copyright(c) 2007
* @公司: 北京漢銘信通科技有限公司
* @部門: 增值業務部
* @作者: 武達
* @Jun 6, 2007
*/
public class MsgQueryRsp extends Msg {
/*
Startnum 4 Integer 起始記錄數
Curnum 4 Integer 本次返回記錄數
Allnum 4 Integer 記錄總數
RingID(1) 12 String 鈴音ID
Price(1) 4 Integer 鈴音價格
RingName(1) 40 String 鈴音名稱
Author(1) 20 String 鈴音作者或歌手
Supplier(1) 20 String 鈴音提供者
ValidDate(1) 10 String 鈴音的有效期截止日期
*/
private final int LEN_PRE_RING = 106;
private class Ring{
public String ringId;
public int price;
public String ringName;
public String author;
public String supplier;
public String validDate;
}
private int startnum;
private int curnum;
private int allnum;
private Map<Integer,Ring> map = new HashMap<Integer,Ring>();
public MsgQueryRsp(byte[] bytes){
super(bytes);
ByteBuffer buff = super.getBodyBuffer();
this.startnum = buff.getInt();
this.curnum = buff.getInt();
this.allnum = buff.getInt();
buff = buff.slice();
byte[] msgRing = new byte[buff.capacity()];
if (msgRing.length%LEN_PRE_RING == 0 && msgRing.length/LEN_PRE_RING==curnum){
buff.get(msgRing);
buff.flip();
for (int i=0; i<curnum; i++){
byte[] temp = new byte[LEN_PRE_RING];
System.arraycopy(msgRing, i*LEN_PRE_RING, temp, 0, temp.length);
Ring ring = new Ring();
try {
ring.ringId = new String(temp, 0, 12, "gbk");
ring.price = DataFormat.byte2int(temp, 12);
ring.ringName = new String(temp, 16, 40, "gbk");
ring.author = new String(temp, 56, 20, "gbk");
ring.supplier = new String(temp, 76, 20, "gbk");
ring.validDate = new String(temp, 96, 10, "gbk");
this.map.put(i, ring);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
else{
System.err.print("消息體不正確");
return;
}
}
public int getAllnum() {
return this.allnum;
}
public int getCurnum() {
return this.curnum;
}
public int getStartnum() {
return this.startnum;
}
public String getAuthor(int positon) {
Ring ring = map.get(Integer.valueOf(positon));
return ring.author;
}
public int getPrice(int positon) {
Ring ring = map.get(Integer.valueOf(positon));
return ring.price;
}
public String getRingId(int positon) {
Ring ring = map.get(Integer.valueOf(positon));
return ring.ringId;
}
public String getRingName(int positon) {
Ring ring = map.get(Integer.valueOf(positon));
return ring.ringName;
}
public String getSupplier(int positon) {
Ring ring = map.get(Integer.valueOf(positon));
return ring.supplier;
}
public String getValidDate(int positon) {
Ring ring = map.get(Integer.valueOf(positon));
return ring.validDate;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -