?? msgupload.java
字號:
/**
*
*/
package com.aceway.vas.sjcraw.cbgp201;
import java.nio.ByteBuffer;
import java.util.Date;
import com.aceway.vas.sjcraw.cbgp201.common.DataFormat;
import com.aceway.vas.sjcraw.cbgp201.common.MsgInfo;
/**
* @標題: 華為彩鈴平臺接口規范
* @說明:
* @版權: Copyright(c) 2007
* @公司: 北京漢銘信通科技有限公司
* @部門: 增值業務部
* @作者: 武達
* @Jun 5, 2007
*/
public class MsgUpload extends Msg {
private int uploadType;
private String accountId;
private String ringId;
private String fileName;
private String path;
private String ipAddress;
private String ftpUser;
private String ftpPwd;
private int price;
private String validDate;
// 以下4個為可選
private String ringName;
private String author;
private String supplier;
private int uploadOpType;
private static int operCode = MsgInfo.CRBT_UPLOAD;
private static int lenBody = MsgInfo.LEN_UPLOAD;
public MsgUpload(String seqNo, String linkId, int uploadType, String accountId, String ringId,
String fileName, String path,String ipAddress,String ftpUser,
String ftpPwd,int price,Date validateDate,String ringName,
String author,String supplier, int uploadOpType){
/*
* UploadType 1 Integer 上傳鈴音的用戶類型 AccountID 21 String 上傳鈴音的用戶ID
* 如果是SP上傳,則該字段表示上傳鈴音的類型(RingLibCode) RingID 12 String 鈴音ID Filename 40
* String 鈴音文件名 Path 40 String 鈴音文件存放路徑 IPAddress 16 String Ftp服務器地址
* FTPUser 10 String 登錄SP(或SPMS)的FTP服務器的用戶名 FTPPwd 10 String
* 登錄SP(或SPMS)的FTP服務器的密碼 Price 4 Integer 鈴音價格 ValidDate 10 Date
* 鈴音的有效期截止日期 -------------以下是可先參數 RingName 40 String 鈴音名稱 Author 20
* String 鈴音作者或歌手 Supplier 20 String 鈴音提供者 UploadOpType 1 Integer
* 鈴音上傳的操作類型
*
*/
this.uploadType = uploadType;
this.accountId = DataFormat.makeString(accountId, 21);
this.ringId = DataFormat.makeString(ringId, 12);
this.fileName = DataFormat.makeString(fileName, 40);
this.path = DataFormat.makeString(path, 40);
this.ipAddress = DataFormat.makeString(ipAddress, 16);
this.ftpUser = DataFormat.makeString(ftpUser, 10);
this.ftpPwd = DataFormat.makeString(ftpPwd, 10);
this.price = price;
this.validDate = super.dateFormat.format(validDate);
/*
* UploadOpType 鈴音上傳的操作類型 1 鈴音上傳; 2 鈴音替換
*
*/
if (uploadOpType==1 || uploadOpType==2){
if (ringName !=null && !ringName.equals("")){
this.ringName = DataFormat.makeString(ringName, 40);
}else{
this.ringName = DataFormat.makeTempStr(40);
}
if (author!=null && !author.equals("")){
this.author = DataFormat.makeString(author, 20);
}else{
this.author = DataFormat.makeTempStr(20);
}
if (supplier!= null && !supplier.equals("")){
this.supplier = DataFormat.makeString(supplier, 20);
}else {
this.supplier = DataFormat.makeTempStr(20);
}
this.uploadOpType = uploadOpType;
this.lenBody +=81;
} else if (supplier !=null && !supplier.equals("")){
this.supplier = supplier;
if (ringName !=null && !ringName.equals("")){
this.ringName = DataFormat.makeString(ringName, 40);
}else{
this.ringName = DataFormat.makeTempStr(40);
}
if (author!=null && !author.equals("")){
this.author = DataFormat.makeString(author, 20);
}else{
this.author = DataFormat.makeTempStr(20);
}
this.lenBody+=80;
} else if (author!=null && !author.equals("")){
this.author=author;
if (ringName !=null && !ringName.equals("")){
this.ringName = DataFormat.makeString(ringName, 40);
}else{
this.ringName = DataFormat.makeTempStr(40);
}
this.lenBody+=60;
}else if (ringName !=null && !ringName.equals("")){
this.ringName = ringName;
this.lenBody+=40;
}
super.setCommandLength(lenBody);
super.setMsgHead(operCode, "0", seqNo, linkId);
ByteBuffer buff = ByteBuffer.allocate(lenBody);
buff.putInt(this.uploadType);
buff.put(this.accountId.getBytes());
buff.put(this.ringId.getBytes());
buff.put(this.fileName.getBytes());
buff.put(this.path.getBytes());
buff.put(this.ipAddress.getBytes());
buff.put(this.ftpUser.getBytes());
buff.put(this.ftpPwd.getBytes());
buff.putInt(this.price);
buff.put(this.validDate.getBytes());
if (lenBody==245){
buff.put(this.ringName.getBytes());
buff.put(this.author.getBytes());
buff.put(this.supplier.getBytes());
buff.putInt(this.uploadOpType);
} else if (lenBody == 244){
buff.put(this.ringName.getBytes());
buff.put(this.author.getBytes());
buff.put(this.supplier.getBytes());
} else if (lenBody == 224){
buff.put(this.ringName.getBytes());
buff.put(this.author.getBytes());
} else if (lenBody == 204){
buff.put(this.ringName.getBytes());
}
buff.flip();
super.setMsgBody(buff.array());
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public String getAccountId() {
return this.accountId.trim();
}
public String getAuthor() {
return this.author.trim();
}
public String getFileName() {
return this.fileName.trim();
}
public String getFtpPwd() {
return this.ftpPwd.trim();
}
public String getFtpUser() {
return this.ftpUser.trim();
}
public String getIpAddress() {
return this.ipAddress.trim();
}
public String getPath() {
return this.path.trim();
}
public int getPrice() {
return this.price;
}
public String getRingId() {
return this.ringId.trim();
}
public String getRingName() {
return this.ringName.trim();
}
public String getSupplier() {
return this.supplier.trim();
}
public int getUploadOpType() {
return this.uploadOpType;
}
public int getUploadType() {
return this.uploadType;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -