/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.35
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package be.portugal.eid;

/******************************************************************************//**
  * Base class for all the card types supported
  * PTEID_ReaderContext.getCard() will return such an object
  *********************************************************************************/
public class PTEID_Card extends PTEID_Object {
  private long swigCPtr;

  protected PTEID_Card(long cPtr, boolean cMemoryOwn) {
    super(pteidlibJava_WrapperJNI.SWIGPTEID_CardUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  protected static long getCPtr(PTEID_Card obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      pteidlibJava_WrapperJNI.delete_PTEID_Card(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }
	/** Return the type of the card */
  public PTEID_CardType getType() throws java.lang.Exception {
    return PTEID_CardType.swigToEnum(pteidlibJava_WrapperJNI.PTEID_Card_getType(swigCPtr, this));
  }

 	/**
	 * Get a document from the card.
	 * Throws PTEID_ExDocTypeUnknown exception if the document doesn't exist
	 */
  public PTEID_XMLDoc getDocument(PTEID_DocumentType type) throws java.lang.Exception {
    return new PTEID_XMLDoc(pteidlibJava_WrapperJNI.PTEID_Card_getDocument(swigCPtr, this, type.swigValue()), false);
  }

 	/**
	 * Get the raw data file from the card.
	 * Throws PTEID_ExFileTypeUnknown exception if the document doesn't exist
	 */
  public PTEID_ByteArray getRawData(PTEID_RawDataType type) throws java.lang.Exception {
    return new PTEID_ByteArray(pteidlibJava_WrapperJNI.PTEID_Card_getRawData(swigCPtr, this, type.swigValue()), false);
  }

 	/**
	 * Send an APDU command to the card and get the result
	 * @param cmd the apdu command
	 * @return PTEID_ByteArray containing the result
	 */
  public PTEID_ByteArray sendAPDU(PTEID_ByteArray cmd) throws java.lang.Exception {
    return new PTEID_ByteArray(pteidlibJava_WrapperJNI.PTEID_Card_sendAPDU(swigCPtr, this, PTEID_ByteArray.getCPtr(cmd), cmd), true);
  }

 	/**
	 * Read a file from the card
	 * @param fileID the path of the file
	 * @param ulOffset the offset in the file to start reading
	 * @param ulMaxLength the maximum number of bytes to read
	 * @return A PTEID_ByteArray with the content of the file
	 */
  public PTEID_ByteArray readFile(String fileID, long ulOffset, long ulMaxLength) throws java.lang.Exception {
    return new PTEID_ByteArray(pteidlibJava_WrapperJNI.PTEID_Card_readFile__SWIG_0(swigCPtr, this, fileID, ulOffset, ulMaxLength), true);
  }

 	/**
	 * Read a file from the card
	 * @param fileID the path of the file
	 * @param ulOffset the offset in the file start reading
	 * @return A PTEID_ByteArray with the content of the file
	 */
  public PTEID_ByteArray readFile(String fileID, long ulOffset) throws java.lang.Exception {
    return new PTEID_ByteArray(pteidlibJava_WrapperJNI.PTEID_Card_readFile__SWIG_1(swigCPtr, this, fileID, ulOffset), true);
  }

 	/**
	 * Read a file from the card
	 * @param fileID the path of the file
	 * @return A PTEID_ByteArray with the content of the file
	 */
  public PTEID_ByteArray readFile(String fileID) throws java.lang.Exception {
    return new PTEID_ByteArray(pteidlibJava_WrapperJNI.PTEID_Card_readFile__SWIG_2(swigCPtr, this, fileID), true);
  }

 	/**
	 * Write to a file on the card
	 * @param fileID the path of the file
	 * @param oData contents the bytes to write
	 * @param ulOffset the offset to begin writing
	 */
  public boolean writeFile(String fileID, PTEID_ByteArray oData, long ulOffset) throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Card_writeFile__SWIG_0(swigCPtr, this, fileID, PTEID_ByteArray.getCPtr(oData), oData, ulOffset);
  }

 	/**
	 * Write to a file on the card
	 * @param fileID the path of the file
	 * @param oData contents the bytes to write
	 */
  public boolean writeFile(String fileID, PTEID_ByteArray oData) throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_Card_writeFile__SWIG_1(swigCPtr, this, fileID, PTEID_ByteArray.getCPtr(oData), oData);
  }

}
