/**
**
** MiddCor-C# DemoJava
**			CORBA Solution for .Net with C# Language mapping							 
**																			 
**				
** Copyright:
**			Middsol GmbH, Hamburg
**			Germany  2004
**			www.middsol.com
**			info@middsol.com	
**
*/

package Collections;


import java.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;
import java.util.*;


public class GreetingsImpl extends PortableRemoteObject implements Greetings{

	public GreetingsImpl() throws RemoteException {
		
             	super(); 
	}
	
	public java.util.Hashtable queryAddresses(  )
		throws RemoteException
	{
		System.out.println("\nMethod executed: Greetings.queryAddresses");		
		java.util.Hashtable oAddressList = new java.util.Hashtable();	

		oAddressList.put("Clark, John", new HomeAddr( "Clark", "John", "21079", "Hamburg"));
		oAddressList.put("Meier, Marie", new HomeAddr( "Meiser", "Marie", "223344", "Bremen")); 
		oAddressList.put("Berlin Touring Inc", new CompanyAddr( "Day & Nigth Berlin Touring Inc.", "12345", "Berlin"));
		oAddressList.put("theInteger", new java.lang.Integer(100));
		oAddressList.put("theByte", new java.lang.Byte((byte)2));
		oAddressList.put("theChar", new java.lang.Character((char)'A'));
		oAddressList.put("theShort", new java.lang.Short((short)123));
		oAddressList.put("theLong", new java.lang.Long((long)98));
		oAddressList.put("theBoolean", new java.lang.Boolean(true));
		oAddressList.put("theFloat", new java.lang.Float((float)1000));
		oAddressList.put("theDouble", new java.lang.Double((double)2000));
	
		return oAddressList;	
	}


	public java.util.ArrayList queryCustomers(  )
		throws RemoteException
	{
		System.out.println("\nMethod executed: Greetings.queryCustomers");		
		java.util.ArrayList oAddressList = new java.util.ArrayList();	

		oAddressList.add( new HomeAddr( "Clark", "John", "21079", "Hamburg")); 
		oAddressList.add( new HomeAddr( "Meiser", "Marie", "223344", "Bremen")); 
		oAddressList.add( new CompanyAddr( "Day & Nigth Berlin Touring Inc.", "12345", "Berlin"));
	
		return oAddressList;	
	}


	public void newAddressList( java.util.Hashtable a_oHash)
		throws RemoteException
	{
		System.out.println("\nMethod executed: Greetings.newAddressList");
		
		Enumeration e = a_oHash.keys();
		while( e.hasMoreElements()) {
			String alias = (String)e.nextElement();

			System.out.println("Key:" + alias);
			showValue( a_oHash.get( alias));
		}
	}



	private void showValue( Object oObj)
	{

		if( oObj instanceof HomeAddr)
		{
			System.out.println("---is HomeAddr---");
			HomeAddr oHomeAddr = (HomeAddr)oObj;
			System.out.println("--- theFirstName:" + oHomeAddr.theFirstName());
			System.out.println("--- theLastName :" + oHomeAddr.theLastName());
			System.out.println("--- theZipCode  :" + oHomeAddr.theZipCode());
			System.out.println("--- theCity     :" + oHomeAddr.theCity());
		}

		if( oObj instanceof CompanyAddr)
		{
			System.out.println("---is CompanyAddr---");
			CompanyAddr oCompanyAddr = (CompanyAddr)oObj;
			System.out.println("--- theName     :" + oCompanyAddr.theName());
			System.out.println("--- theZipCode  :" + oCompanyAddr.theZipCode());
			System.out.println("--- theCity     :" + oCompanyAddr.theCity());
			System.out.println("--- theCity     :" + oCompanyAddr.theCity());
		}
		if( oObj instanceof java.lang.Integer)
		{
			System.out.println("---is Integer ---");
			System.out.println("--- Value       :" + (java.lang.Integer)oObj);
		}
		if( oObj instanceof java.lang.Short)
		{
			System.out.println("---is Short ---");
			System.out.println("--- Value       :" + (java.lang.Short)oObj);
		}
		if( oObj instanceof java.lang.Character)
		{
			System.out.println("---is Character ---");
			System.out.println("--- Value       :" + (java.lang.Character)oObj);
		}
		if( oObj instanceof java.lang.Byte)
		{
			System.out.println("---is Byte ---");
			System.out.println("--- Value       :" + (java.lang.Byte)oObj);
		}
		if( oObj instanceof java.lang.Long)
		{
			System.out.println("---is lang ---");
			System.out.println("--- Value       :" + (java.lang.Long)oObj);
		}
		if( oObj instanceof java.lang.Float)
		{
			System.out.println("---is Float ---");
			System.out.println("--- Value       :" + (java.lang.Float)oObj);
		}
		if( oObj instanceof java.lang.Double)
		{
			System.out.println("---is double ---");
			System.out.println("--- Value       :" + (java.lang.Double)oObj);
		}
		if( oObj instanceof java.lang.Boolean)
		{
			System.out.println("---is double ---");
			System.out.println("--- Value       :" + (java.lang.Boolean)oObj);
		}
	}		

}

