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

package org.apache.camel.component.msmq.native_support;

public class MsmqQueue {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  protected MsmqQueue(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

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

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      msmq_native_supportJNI.delete_MsmqQueue(swigCPtr);
    }
    swigCPtr = 0;
  }

  public MsmqQueue() {
    this(msmq_native_supportJNI.new_MsmqQueue(), true);
  }

  public void open(String szMSMQQueuePath, int openmode) {
    msmq_native_supportJNI.MsmqQueue_open(swigCPtr, this, szMSMQQueuePath, openmode);
  }

  public void sendMessage(MsmqMessage msg) {
    msmq_native_supportJNI.MsmqQueue_sendMessage(swigCPtr, this, MsmqMessage.getCPtr(msg), msg);
  }

  public boolean receiveMessage(MsmqMessage msg, int timeout) {
    return msmq_native_supportJNI.MsmqQueue_receiveMessage(swigCPtr, this, MsmqMessage.getCPtr(msg), msg, timeout);
  }

  public void close() {
    msmq_native_supportJNI.MsmqQueue_close(swigCPtr, this);
  }

  public boolean isOpen() {
    return msmq_native_supportJNI.MsmqQueue_isOpen(swigCPtr, this);
  }

  public static void createQueue(String pathName) {
    msmq_native_supportJNI.MsmqQueue_createQueue(pathName);
  }

  public static void deleteQueue(String formatPathName) {
    msmq_native_supportJNI.MsmqQueue_deleteQueue(formatPathName);
  }

}
