package org.dbxml.core.corba.db;

/**
 *	Generated from IDL definition of interface "DocumentSet"
 *	@author JacORB IDL compiler 
 */

public class _DocumentSetStub
	extends org.omg.CORBA.portable.ObjectImpl
	implements org.dbxml.core.corba.db.DocumentSet
{
	private String[] ids = {"IDL:org/dbxml/core/corba/db/DocumentSet:1.0","IDL:org/dbxml/core/corba/db/ServantManagement:1.0","IDL:omg.org/CORBA/Object:1.0"};
	public String[] _ids()
	{
		return ids;
	}

	public final static java.lang.Class _opsClass = org.dbxml.core.corba.db.DocumentSetOperations.class;
	public org.dbxml.core.corba.db.EncodedBuffer getNextDocument(long stamp) throws org.dbxml.core.corba.db.APIException
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "getNextDocument", true);
				_os.write_longlong(stamp);
				_is = _invoke(_os);
				org.dbxml.core.corba.db.EncodedBuffer _result = org.dbxml.core.corba.db.EncodedBufferHelper.read(_is);
				return _result;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				if( _id.equals("IDL:org/dbxml/core/corba/db/APIException:1.0"))
				{
					throw org.dbxml.core.corba.db.APIExceptionHelper.read(_ax.getInputStream());
				}
				else 
					throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "getNextDocument", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DocumentSetOperations _localServant = (DocumentSetOperations)_so.servant;
			org.dbxml.core.corba.db.EncodedBuffer _result;			try
			{
			_result = _localServant.getNextDocument(stamp);
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return _result;
		}

		}

	}

	public void remove()
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "remove", true);
				_is = _invoke(_os);
				return;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "remove", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DocumentSetOperations _localServant = (DocumentSetOperations)_so.servant;
			try
			{
			_localServant.remove();
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return;
		}

		}

	}

	public boolean hasMoreDocuments() throws org.dbxml.core.corba.db.APIException
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "hasMoreDocuments", true);
				_is = _invoke(_os);
				boolean _result = _is.read_boolean();
				return _result;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				if( _id.equals("IDL:org/dbxml/core/corba/db/APIException:1.0"))
				{
					throw org.dbxml.core.corba.db.APIExceptionHelper.read(_ax.getInputStream());
				}
				else 
					throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "hasMoreDocuments", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DocumentSetOperations _localServant = (DocumentSetOperations)_so.servant;
			boolean _result;			try
			{
			_result = _localServant.hasMoreDocuments();
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return _result;
		}

		}

	}

}
