// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) braces deadcode fieldsfirst 
// Source File Name:   GoogleAPIDemo.java
// Class Version:      45.3

package com.google.soap.search;

import java.io.PrintStream;

// Referenced classes of package com.google.soap.search:
//            GoogleSearch, GoogleSearchResult, GoogleSearchFault

// flag ACC_SUPER is set
public class GoogleAPIDemo
{
    // Constants:          147
    // Interfaces:         0
    // Fields:             1
    // Methods:            4
    // Class Attributes:   1


    private static Class class$Lcom$google$soap$search$GoogleAPIDemo; /* synthetic field */

    // Decompiling method: main  Signature: ([Ljava/lang/String;)V
    // Max stack: 5, #locals: 7, #params: 1
    // Code length: 281 bytes, Code offset: 1817
    // Exception table: 1 entries
    //           start  110 end 256 handler 259 type GoogleSearchFault
    // Line Number Table found: 32 entries
    // Parameter  0 added: Name args Type [Ljava/lang/String; At 0 281 Range 0 280 Init 0
    // RetValue   7 added: Name <returnValue> Type V At 0 281 Range 0 280 Init 0 fixed
    // LocalVar   1 added: Name s Type Ljava/lang/String; At 12 95 Range 12 106 Init 12
    // LocalVar   2 added: Name s1 Type Ljava/lang/String; At 16 202 Range 16 217 Init 16
    // LocalVar   3 added: Name s2 Type Ljava/lang/String; At 20 217 Range 20 236 Init 20
    // LocalVar   4 added: Name googlesearch Type Lcom/google/soap/search/GoogleSearch; At 102 134 Range 102 235 Init 102
    // LocalVar   5 added: Name googlesearchresult Type Lcom/google/soap/search/GoogleSearchResult; At 130 23 Range 130 152 Init 130
    // LocalVar   5 added: Name abyte0 Type [B At 193 8 Range 193 200 Init 193
    // LocalVar   6 added: Name s3 Type Ljava/lang/String; At 204 7 Range 204 210 Init 204
    // LocalVar   5 added: Name s4 Type Ljava/lang/String; At 240 7 Range 240 246 Init 240
    // LocalVar   5 added: Name googlesearchfault Type Lcom/google/soap/search/GoogleSearchFault; At 259 15 Range 259 273 Init 259
    public static void main(String args[])
    {
        if(args.length != 3)
        {
            printUsageAndExit();
        }
        String s = args[0];
        String s1 = args[1];
        String s2 = args[2];
        System.out.println("Parameters:");
        System.out.println("Client key = " + s);
        System.out.println("Directive  = " + s1);
        System.out.println("Args       = " + s2);
        GoogleSearch googlesearch = new GoogleSearch();
        googlesearch.setKey(s);
        try
        {
            if(s1.equalsIgnoreCase("search"))
            {
                googlesearch.setQueryString(s2);
                GoogleSearchResult googlesearchresult = googlesearch.doSearch();
                System.out.println("Google Search Results:");
                System.out.println("======================");
                System.out.println(googlesearchresult.toString());
            } else
            if(s1.equalsIgnoreCase("cached"))
            {
                System.out.println("Cached page:");
                System.out.println("============");
                byte abyte0[] = googlesearch.doGetCachedPage(s2);
                String s4 = new String(abyte0);
                System.out.println(s4);
            } else
            if(s1.equalsIgnoreCase("spell"))
            {
                System.out.println("Spelling suggestion:");
                String s3 = googlesearch.doSpellingSuggestion(s2);
                System.out.println(s3);
            } else
            {
                printUsageAndExit();
            }
        }
        catch(GoogleSearchFault googlesearchfault)
        {
            System.out.println("The call to the Google Web APIs failed:");
            System.out.println(googlesearchfault.toString());
        }
        return;
    }

    // Decompiling method: printUsageAndExit  Signature: ()V
    // Max stack: 5, #locals: 0, #params: 0
    // Code length: 63 bytes, Code offset: 2268
    // Line Number Table found: 3 entries
    // RetValue   0 added: Name <returnValue> Type V At 0 63 Range 0 62 Init 0 fixed
    private static void printUsageAndExit()
    {
        System.err.println("Usage: java " + (class$Lcom$google$soap$search$GoogleAPIDemo == null ? (class$Lcom$google$soap$search$GoogleAPIDemo = class$("com.google.soap.search.GoogleAPIDemo")) : class$Lcom$google$soap$search$GoogleAPIDemo).getName() + " <client-key>" + " (search <query> | cached <url> | spell <phrase>)");
        System.exit(1);
        return;
    }

    // Decompiling method: class$  Signature: (Ljava/lang/String;)Ljava/lang/Class;
    // Max stack: 3, #locals: 2, #params: 1
    // Code length: 18 bytes, Code offset: 2383
    // Exception table: 1 entries
    //           start  0 end 5 handler 5 type ClassNotFoundException
    // Parameter  0 added: Name s Type Ljava/lang/String; At 0 18 Range 0 17 Init 0
    // RetValue   2 added: Name <returnValue> Type Ljava/lang/Class; At 0 18 Range 0 17 Init 0 fixed
    // LocalVar   1 added: Name classnotfoundexception Type Ljava/lang/ClassNotFoundException; At 5 6 Range 5 10 Init 5
    static Class class$(String s)
    {
        try
        {
            return Class.forName(s);
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            throw new NoClassDefFoundError(classnotfoundexception.getMessage());
        }
    }

    // Decompiling method: <init>  Signature: ()V
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 5 bytes, Code offset: 2435
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Lcom/google/soap/search/GoogleAPIDemo; At 0 5 Range 0 4 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 5 Range 0 4 Init 0 fixed
    public GoogleAPIDemo()
    {
        super();
        return;
    }
}
