package org.dbxml.core.corba.db;

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

public abstract class DatabasePOA
	extends org.omg.PortableServer.Servant
	implements org.omg.CORBA.portable.InvokeHandler, org.dbxml.core.corba.db.DatabaseOperations
{
	static private final java.util.Hashtable m_opsHash = new java.util.Hashtable();
	static
	{
		m_opsHash.put ( "getDatabaseManager", new java.lang.Integer(0));
		m_opsHash.put ( "remove", new java.lang.Integer(1));
		m_opsHash.put ( "getCollection", new java.lang.Integer(2));
		m_opsHash.put ( "listCollections", new java.lang.Integer(3));
		m_opsHash.put ( "getName", new java.lang.Integer(4));
	}
	private String[] ids = {"IDL:org/dbxml/core/corba/db/Database:1.0","IDL:org/dbxml/core/corba/db/ServantManagement:1.0","IDL:omg.org/CORBA/Object:1.0"};
	public org.dbxml.core.corba.db.Database _this()
	{
		return org.dbxml.core.corba.db.DatabaseHelper.narrow(_this_object());
	}
	public org.dbxml.core.corba.db.Database _this(org.omg.CORBA.ORB orb)
	{
		return org.dbxml.core.corba.db.DatabaseHelper.narrow(_this_object(orb));
	}
	public org.omg.CORBA.portable.OutputStream _invoke(String method, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.ResponseHandler handler)
		throws org.omg.CORBA.SystemException
	{
		org.omg.CORBA.portable.OutputStream _out = null;
		// do something
		// quick lookup of operation
		java.lang.Integer opsIndex = (java.lang.Integer)m_opsHash.get ( method );
		if ( null == opsIndex )
			throw new org.omg.CORBA.BAD_OPERATION(method + " not found");
		switch ( opsIndex.intValue() )
		{
			case 0: // getDatabaseManager
			{
			try
			{
				_out = handler.createReply();
				org.dbxml.core.corba.db.DatabaseManagerHelper.write(_out,getDatabaseManager());
			}
			catch(org.dbxml.core.corba.db.APIException _ex0)
			{
				_out = handler.createExceptionReply();
				org.dbxml.core.corba.db.APIExceptionHelper.write(_out, _ex0);
			}
				break;
			}
			case 1: // remove
			{
				_out = handler.createReply();
				remove();
				break;
			}
			case 2: // getCollection
			{
			try
			{
				java.lang.String _arg0=org.dbxml.core.corba.db.NameHelper.read(_input);
				_out = handler.createReply();
				org.dbxml.core.corba.db.CollectionHelper.write(_out,getCollection(_arg0));
			}
			catch(org.dbxml.core.corba.db.APIException _ex0)
			{
				_out = handler.createExceptionReply();
				org.dbxml.core.corba.db.APIExceptionHelper.write(_out, _ex0);
			}
				break;
			}
			case 3: // listCollections
			{
			try
			{
				_out = handler.createReply();
				org.dbxml.core.corba.db.NamesHelper.write(_out,listCollections());
			}
			catch(org.dbxml.core.corba.db.APIException _ex0)
			{
				_out = handler.createExceptionReply();
				org.dbxml.core.corba.db.APIExceptionHelper.write(_out, _ex0);
			}
				break;
			}
			case 4: // getName
			{
			try
			{
				_out = handler.createReply();
				_out.write_string(getName());
			}
			catch(org.dbxml.core.corba.db.APIException _ex0)
			{
				_out = handler.createExceptionReply();
				org.dbxml.core.corba.db.APIExceptionHelper.write(_out, _ex0);
			}
				break;
			}
		}
		return _out;
	}

	public String[] _all_interfaces(org.omg.PortableServer.POA poa, byte[] obj_id)
	{
		return ids;
	}
}
