class CommandApdu {

	public byte[] toBytes() {
		int length = 4; // CLA, INS, P1, P2
		if (mData != null && mData.length != 0) {
			length += 1; // LC
			length += mData.length; // DATA
		}
		if (mLeUsed) {
			length += 1; // LE
		}

		byte[] apdu = new byte[length];

		int index = 0;
		apdu[index] = (byte) mCla;
		index++;
		apdu[index] = (byte) mIns;
		index++;
		apdu[index] = (byte) mP1;
		index++;
		apdu[index] = (byte) mP2;
		index++;
		if (mData != null && mData.length != 0) {
			apdu[index] = (byte) mLc;
			index++;
			System.arraycopy(mData, 0, apdu, index, mData.length);
			index += mData.length;
		}
		if (mLeUsed) {
			apdu[index] += (byte) mLe; // LE
		}

		return apdu;
	}

	public  CommandApdu(final CommandEnum pEnum, final byte[] data, final int le);
	public  CommandApdu(final CommandEnum pEnum, final int p1, final int p2, final int le);
	public  CommandApdu(final CommandEnum pEnum, final int p1, final int p2);
	public  CommandApdu(final CommandEnum pEnum, final int p1, final int p2, final byte[] data, final int le);

}