# Class ApduResponse

java.lang.Object
com.codename1.nfc.ApduResponse

public final class ApduResponse extends java.lang.Object
Helpers for working with the ISO 7816 status word (SW1/SW2) trailer at the end of every APDU response. Pair with `IsoDep` (reader mode) and `HostCardEmulationService` (card mode).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static byte[]`
  `body(byte[] apdu)`
  Slice helper -- returns the payload preceding the 2-byte SW trailer, or an empty array when the response is exactly 2 bytes.
  `static boolean`
  `isSuccess(byte[] apdu)`
  `true` when the trailing two bytes of `apdu` are `90 00`.
  `static int`
  `statusWord(byte[] apdu)`
  16-bit status word from the last two bytes of `apdu`.
  `static byte[]`
  `sw(int sw1, int sw2)`
  Returns a 2-byte status-word array for the given SW1/SW2 pair.
  `static byte[]`
  `swClaNotSupported()`
  SW = `6E 00` -- CLA not supported.
  `static byte[]`
  `swFileNotFound()`
  SW = `6A 82` -- file or AID not found.
  `static byte[]`
  `swInsNotSupported()`
  SW = `6D 00` -- INS not supported.
  `static byte[]`
  `swSecurityNotSatisfied()`
  SW = `69 82` -- security condition not satisfied.
  `static byte[]`
  `swSuccess()`
  SW = `90 00` -- command succeeded.
  `static byte[]`
  `swUnknownError()`
  SW = `6F 00` -- unknown / generic failure.
  `static byte[]`
  `swWrongLength()`
  SW = `67 00` -- wrong length / Lc.
  `static byte[]`
  `withStatus(byte[] body, byte[] sw)`
  Appends `sw` to the end of `body` and returns the combined APDU response.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### swSuccess

    public static byte[] swSuccess()
    SW = `90 00` -- command succeeded.

  - ### swFileNotFound

    public static byte[] swFileNotFound()
    SW = `6A 82` -- file or AID not found. Returned from an HCE service's `SELECT` when the requested AID is not the one it registered.

  - ### swInsNotSupported

    public static byte[] swInsNotSupported()
    SW = `6D 00` -- INS not supported. Returned from an HCE service for any APDU whose instruction byte is not handled.

  - ### swClaNotSupported

    public static byte[] swClaNotSupported()
    SW = `6E 00` -- CLA not supported.

  - ### swWrongLength

    public static byte[] swWrongLength()
    SW = `67 00` -- wrong length / Lc.

  - ### swSecurityNotSatisfied

    public static byte[] swSecurityNotSatisfied()
    SW = `69 82` -- security condition not satisfied.

  - ### swUnknownError

    public static byte[] swUnknownError()
    SW = `6F 00` -- unknown / generic failure.

  - ### isSuccess

    public static boolean isSuccess(byte[] apdu)
    `true` when the trailing two bytes of `apdu` are `90 00`.

  - ### body

    public static byte[] body(byte[] apdu)
    Slice helper -- returns the payload preceding the 2-byte SW trailer, or an empty array when the response is exactly 2 bytes.

  - ### statusWord

    public static int statusWord(byte[] apdu)
    16-bit status word from the last two bytes of `apdu`. Returns `0` for inputs shorter than 2 bytes.

  - ### sw

    public static byte[] sw(int sw1, int sw2)
    Returns a 2-byte status-word array for the given SW1/SW2 pair.

  - ### withStatus

    public static byte[] withStatus(byte[] body, byte[] sw)
    Appends `sw` to the end of `body` and returns the combined APDU response. Helper for `HostCardEmulationService` implementations.