Activity 11.3 - Running and modifying the search program

Topic

This activity accompanies the second case study in Unit 11, on the Google SOAP API.

As this API has now been withdrawn by Google, this activity remains here only for illustration.

Instructions

This project contains the code for the Google search program. Before modifying the program it would be worth your while executing the program in order to check that you do not have any firewall problems.

Before executing the program you will need to obtain a key and paste it into the program at the point indicated by the line

            search.setKey("Key needed here");     
This involves creating a Google account. Details of how to do this can be found at the create a Google account link

If you have problems finding this page, just use Google to search with the keywords "Google" "api" and "Java".

Once you have run the program, modify it so that when it finds the text corresponding to the regular expression not only the string "Found" is emitted but the string that has been found is displayed after "Found".

In order to do this you will need to use the getParen method (with argument 0) from the class RE, this will return the matched string; for example the code

            String foundString = searchPattern.getParen(0) 
will place in the variable foundString the substring that has been matched to the regular expression searchPattern.

Notes

If some classes are not found, you will need to add the jars containing the Google api and regular expressions classes:

Do the same for the other jar file, jakarta-regexp-1.4.jar.

All the classes that you need will then be made available to your project.