Android Open Source - Android_NFC_FelicaEdit Read Response






From Project

Back to project page Android_NFC_FelicaEdit.

License

The source code is released under:

Apache License

If you think the Android project Android_NFC_FelicaEdit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.// w w  w .  jav a  2s .c om
 */

/*
 * Changes
 * * 2010/2/5: k_morishita
 * ** net.kazzz.felica.command.ReadResponse ???????????????
 */

package jp.co.yumemi.nfc;

import java.util.Arrays;

import jp.co.yumemi.nfc.FelicaTag.CommandResponse;
import jp.co.yumemi.rd.misc.Util;

/**
 * Read ????????????????????????????????????????
 * 
 * @author Kazzz
 * @date 2011/01/22
 * @since Android API Level 9
 *
 */

public class ReadResponse extends CommandResponse {
    final int statusFlag1; 
    final int statusFlag2;
    final int blockCount;
    final byte[] blockData; 
    /**
     * ???????
     * 
     * @param data ????????????????????????????
     */
    public ReadResponse(CommandResponse response) {
        super(response);
        this.statusFlag1 = this.data[0];
        this.statusFlag2 = this.data[1];
        if ( this.getStatusFlag1() == 0 ) {
            this.blockCount  = this.data[2];
            this.blockData = Arrays.copyOfRange(this.data, 3, data.length);
        } else {
            this.blockCount  = 0;
            this.blockData = null;
        }
    }
    
    /**
     * statusFlag1??????????????
     * @return int statusFlag1???????????
     */
    public int getStatusFlag1() {
        return this.statusFlag1;
    }

    /**
     * statusFlag2??????????????
     * @return int statusFlag2???????????
     */
    public int getStatusFlag2() {
        return this.statusFlag2;
    }

    /**
     * blockData??????????????
     * @return byte[] blockData???????????
     */
    public byte[] getBlockData() {
        return this.blockData;
    }

    /**
     * blockCount??????????????
     * @return int blockCount???????????
     */
    public int getBlockCount() {
        return this.blockCount;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("FeliCa ??????????? \n");
        sb.append(" ??????? : " + Util.getHexString(this.responseCode) +  "\n");
        sb.append(" ???? : " + Util.getHexString(this.length) + "\n");
        if ( this.idm != null )
            sb.append(" " + this.idm.toString() + "\n");
        sb.append(" ????????1 : " + Util.getHexString((byte)(this.statusFlag1 & 0xff)) +  "\n");
        sb.append(" ????????2 : " + Util.getHexString((byte)(this.statusFlag2 & 0xff)) +  "\n");
        if ( this.blockData != null )
            sb.append(" ???????:  " + Util.getHexString(this.blockData) + "\n");
        return sb.toString();
    }
}




Java Source Code List

jp.co.yumemi.nfc.FelicaTag.java
jp.co.yumemi.nfc.NFCUtil.java
jp.co.yumemi.nfc.NfcException.java
jp.co.yumemi.nfc.NfcTag.java
jp.co.yumemi.nfc.PollingResponse.java
jp.co.yumemi.nfc.ReadResponse.java
jp.co.yumemi.nfc.TagFactory.java
jp.co.yumemi.rd.felicaedit.EditBlock.java
jp.co.yumemi.rd.felicaedit.FelicaEdit.java
jp.co.yumemi.rd.felicaedit.ServiceList.java
jp.co.yumemi.rd.felicaedit.SystemList.java
jp.co.yumemi.rd.misc.SimpleAlert.java
jp.co.yumemi.rd.misc.Util.java