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

📄 msgqueryrsp.java

📁 同步接收web services请求
💻 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 + -