import java.lang.reflect.*;
import java.net.URL;
import gw.*;

public class Ex2_1
{
    public static double TIMEOUT = 2.0;
    private GWPort proxy;

    Ex2_1(String gateway)
    {
        try {
            URL portURL = new URL("http://restsoap:AIIT@" + gateway + "/gw/soap");
            GWServiceLocator locator = new GWServiceLocator();
            proxy = locator.getGWPort(portURL);
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(2);
        }
    }

    public void get(String name, String addr)
    {
        GW__MetaData_Result[] results;

        try {
            // TODO begin: complete the following segment of code:
            // results = <fill-in-your-code>;
            // for (int i = 0; i < results.length; i++) {
            //     System.out.println( 
            //        "Mote " + <fill-in-your-code> +
            //        " Name " + <fill-in-your-code> 
            //     ); 
            // }
            // TODO end
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(2);
        }
    }

    public static void main(String [] args)
    {
        if (args.length != 1 && args.length != 2) {
            System.out.println("Usage: java Ex2_1 gateway [mote]");
            System.exit(3);
        }
        String gateway = args[0];
        String attrName = "name";
        String mote;
        if (args.length == 1)
            mote = "ffffffffffffffff";
        else
            mote = args[1];
        Ex2_1 get = new Ex2_1(gateway);
        get.get(attrName, mote);
    }
}