001/*
002 * ===========================================================================================
003 * = COPYRIGHT
004 *          PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION
005 *   This software is supplied under the terms of a license agreement or nondisclosure
006 *   agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or
007 *   disclosed except in accordance with the terms in that agreement.
008 *     Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved.
009 * Description: // Detail description about the function of this module,
010 *             // interfaces with the other modules, and dependencies.
011 * Revision History:
012 * Date                         Author                        Action
013 * 2017/04/01                   PAX                     Create/Add/Modify/Delete
014 * ===========================================================================================
015 */
016 
017package com.pax.dal.entity;
018
019/**
020 * <div class="zh">IC卡发送的APDU指令实体类。
021 *  <ul>
022 *      <li>{@link #lc} = 0; {@link #le} = 0。无数据发送也无数据返回。</li>
023 *      <li>{@link #lc} = 0; {@link #le} > 0。无数据发送但期望数据返回,如果在实际应用中终端期望返回的数据个数未知,应置 {@link #le} = 256;否则,为确定的数值。</li>
024 *      <li>{@link #lc} > 0; {@link #le} = 0。有数据发送但无期望数据返回。</li>
025 *      <li>{@link #lc} > 0; {@link #le} > 0。有发送数据且有期望数据返回,如果在实际应用中终端期望返回的数据个数未知,应置 {@link #le} = 256;否则,为确定的数值。</li>
026 *      <li>注意事项:由于 {@link #le} =0 在该处表示不要求数据返回,因此在实际应用中若要求发送的命令中 {@link #le} = 0 时,应置 {@link #le} = 256。</li>
027 *  </ul>
028 * </div>
029 * <div class="en">IC card sends APDU instruction entity class.
030 *  <ul>
031 *      <li>{@link #lc} = 0; {@link #le} = 0. There are no data sent and no data returned.</li>
032 *      <li>{@link #lc} = 0; {@link #le} = 0. No data is sent but expected data is returned. If the number of data expected to be returned by the terminal in practical application is unknown, {@link #le} = 256; Otherwise, it is a certain value.</li>
033 *      <li>{@link #lc} = 0; {@link #le} = 0. There is data sent but no expected data is returned.</li>
034 *      <li>{@link #lc} = 0; {@link #le} = 0. There is sent data and expected data is returned. If the number of expected data returned by the terminal in practical application is unknown, {@link #le} = 256;Otherwise, it is a certain value.</li>
035 *      <li>{@link #lc} = 0; {@link #le} = 0. Note: Since {@link #le} = 0 indicates that no data is required to be returned, {@link #le} = 256 should be set in practice if {@link #le} = 0 is required to be sent in the command.</li>
036 *  </ul>
037 * </div>
038 */
039public class ApduSendInfo {
040
041    private byte[] command;
042    private byte[] dataIn;
043    private int lc;
044    private int le;
045
046    /**
047     * <div class="zh"> 获取command, command格式:CLA,INS,P1,P2 </div> <div class="en"> get command, command
048     * format:CLA,INS,P1,P2 </div>
049     * 
050     * @return
051     */
052    public byte[] getCommand() {
053        return command;
054    }
055
056    /**
057     * <div class="zh"> 设置command, command格式:CLA,INS,P1,P2 </div> <div class="en"> set command, command
058     * foramt:CLA,INS,P1,P2 </div>
059     * 
060     * @param command
061     */
062    public void setCommand(byte[] command) {
063        this.command = command;
064    }
065
066    /**
067     * <div class="zh"> 设置传入数据 </div> <div class="en"> set data </div>
068     * 
069     * @return
070     */
071    public byte[] getDataIn() {
072        return dataIn;
073    }
074
075    /**
076     * <div class="zh"> 获取传入数据 </div> <div class="en"> get data </div>
077     * 
078     * @param dataIn
079     */
080    public void setDataIn(byte[] dataIn) {
081        this.dataIn = dataIn;
082    }
083
084    /**
085     * <div class="zh"> 获取lc </div> <div class="en"> get l<SUB>c</SUB> </div>
086     * 
087     * @return
088     */
089    public int getLc() {
090        return lc;
091    }
092
093    /**
094     * <div class="zh"> 设置lc </div> <div class="en"> set l<SUB>c</SUB> </div>
095     */
096    public void setLc(int lc) {
097        this.lc = lc;
098    }
099
100    /**
101     * <div class="zh"> 获取le </div> <div class="en"> get l<SUB>e</SUB> </div>
102     * 
103     * @return
104     */
105    public int getLe() {
106        return le;
107    }
108
109    /**
110     * <div class="zh"> 设置le </div> <div class="en"> set l<SUB>e</SUB> </div>
111     * 
112     * @param le
113     */
114    public void setLe(int le) {
115        this.le = le;
116    }
117
118    public ApduSendInfo() {
119        command = new byte[0];
120        dataIn = new byte[0];
121        lc = 0;
122        le = 0;
123    }
124    
125//    public byte[] toBytes(){
126//        //lc,le底层为short
127//        int len = command.length+dataIn.length+2;
128//        byte[] res = new byte[len];
129//        System.arraycopy(command, 0, res, 0, command.length);
130//        res[command.length] = (byte) (lc & 0xff);
131//        System.arraycopy(dataIn, 0, res, command.length+1, dataIn.length);
132//        res[len-1] = (byte) (le & 0xff);
133//        return res;
134//    }
135}