package InventorySystem;
public class InventoryClient extends org.omg.CORBA.portable.ObjectImpl implements InventorySystem.Inventory {
  protected InventorySystem.Inventory _wrapper = null;
  public InventorySystem.Inventory _this() {
    return this;
  }
  public java.lang.String[] _ids() {
    return __ids;
  }
  private static java.lang.String[] __ids = {
    "IDL:InventorySystem/Inventory:1.0"
  };
  public void addCatalogItem(
    InventorySystem.CatalogItem inItem
  ) {
    org.omg.CORBA.portable.OutputStream _output;
    org.omg.CORBA.portable.InputStream _input;
    while(true) {
      _output = this._request("addCatalogItem", true);
      InventorySystem.CatalogItemHelper.write(_output, inItem);
      try {
        _input = this._invoke(_output, null);
      }
      catch(org.omg.CORBA.TRANSIENT _exception) {
        continue;
      }
      break;
    }
  }
  public boolean inInventory(
    InventorySystem.CatalogItem inItem
  ) {
    org.omg.CORBA.portable.OutputStream _output;
    org.omg.CORBA.portable.InputStream _input;
    boolean _result;
    while(true) {
      _output = this._request("inInventory", true);
      InventorySystem.CatalogItemHelper.write(_output, inItem);
      try {
        _input = this._invoke(_output, null);
        _result = _input.read_boolean();
      }
      catch(org.omg.CORBA.TRANSIENT _exception) {
        continue;
      }
      break;
    }
    return _result;
  }
  public InventorySystem.CatalogItem[] getCatalogItems() {
    org.omg.CORBA.portable.OutputStream _output;
    org.omg.CORBA.portable.InputStream _input;
    InventorySystem.CatalogItem[] _result;
    while(true) {
      _output = this._request("getCatalogItems", true);
      try {
        _input = this._invoke(_output, null);
        _result = InventorySystem.CatalogItemArrayHelper.read(_input);
      }
      catch(org.omg.CORBA.TRANSIENT _exception) {
        continue;
      }
      break;
    }
    return _result;
  }
  public int getQuantityInInventory(
    InventorySystem.CatalogItem inItem
  ) {
    org.omg.CORBA.portable.OutputStream _output;
    org.omg.CORBA.portable.InputStream _input;
    int _result;
    while(true) {
      _output = this._request("getQuantityInInventory", true);
      InventorySystem.CatalogItemHelper.write(_output, inItem);
      try {
        _input = this._invoke(_output, null);
        _result = _input.read_long();
      }
      catch(org.omg.CORBA.TRANSIENT _exception) {
        continue;
      }
      break;
    }
    return _result;
  }
  public InventorySystem.CatalogItem[] catalogItemsArray() {
    org.omg.CORBA.portable.OutputStream _output;
    org.omg.CORBA.portable.InputStream _input;
    InventorySystem.CatalogItem[] _result;
    while(true) {
      _output = this._request("_get_catalogItemsArray", true);
      try {
        _input = this._invoke(_output, null);
        _result = InventorySystem.CatalogItemArrayHelper.read(_input);
      }
      catch(org.omg.CORBA.TRANSIENT _exception) {
        continue;
      }
      break;
    }
    return _result;
  }

  public static void main(String args[]) {
     // Initialize the ORB.
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);

    // Locate an Inventory Object and bind to it.
    Inventory inventory = InventoryHelper.bind(orb, "Inventory");

    InventorySystem.CatalogItem[] rtnItems = 
      inventory.getCatalogItems();

    CatalogItem item = null;

    for(int i=0, len=rtnItems.length; i<len; i++) {
      System.out.println("CatalogItem = " + rtnItems[i]);
    }
  }
}
