?? query.java
字號:
package com.kelefa.cmpp;
import java.io.IOException;
import java.io.DataOutputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.io.DataInputStream;
import com.kelefa.cmpp.result.Result;
import com.kelefa.cmpp.result.QueryResult;
public final class Query
{
public static final int QUERY_LEN = 8 + 1 + 10 + 8;
/** 時間YYYYMMDD(精確至日) len: 8 */
String time;
/**
* 查詢類別
* 0:總數查詢
* 1:按業務類型查詢
*/
byte type;
/**
* 查詢碼
* 當Query_Type為0時,此項無效;
* 當Query_Type為1時,此項填寫業務類型Service_Id.
* len: 10
*/
byte[] code;
/** 保留 len:8 */
String reserve = "00000000";
public Query()
{
}
public void execute( ConnDesc conn )
throws IOException
{
Header header = new Header();
header.pk_len = QUERY_LEN + Header.HEADER_LEN;
DataOutputStream out = new DataOutputStream( conn.sock.getOutputStream() );
header.pk_cmd = Const.CMPPE_QUERY;
header.pk_seq = conn.getSeq();
header.send( out );
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
time = sdf.format(Calendar.getInstance().getTime());
out.writeBytes(time);
out.write(type);
out.write(code);
out.writeBytes(reserve);
}
public static Result respond(DataInputStream in,Header header)
throws IOException
{
QueryResult queryResult = new QueryResult();
queryResult.read( in );
return queryResult;
}
public void setCode(String code)
{
this.code = new byte[10];
if ( code == null || code.length() == 0 )
return;
byte[] tem = code.getBytes();
System.arraycopy( tem, 0, this.code, 0, Math.min( tem.length, 10 ) );
}
public void setType( byte type )
{
this.type = type;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -