/* -*-Java-*- ******************************************************************************** * * File: CollectionPlug.java * RCS: $Header: /u/testbed/CVSROOT/dldev/doc/Visigenic/InfoBus/StreetRouterProxy/CollectionPlug.Street,v 1.1 1998/05/19 23:23:30 paepcke Exp $ * Description: Mediates Between InfoBus Protocol Engine and Service Interface * Author: Gerard Rodriguez, Stanford University * Created: Wed Jan 15 10:10:21 1998 * Modified: Thu Apr 16 13:13:19 1998 (Andreas Paepcke) paepcke@SNUGGLES * Language: Java * Package: N/A * Status: Experimental (Do Not Distribute) * * (c) Copyright 1998, Stanford University, all rights reserved. * ******************************************************************************** * * Revisions: * * Wed Apr 15 10:11:17 1998 (Andreas Paepcke) paepcke@SNUGGLES * Rewrote to match our new, cleaned-up specification. ******************************************************************************** */ /** CollectionPlug mediates between the DLIOP protocol engine (DLIOPwrapper.java), and StreetRouterServer, which knows how to interact with the street router program MapQuest via the Web. The methods in this class are called by the DLIOPwrapper. The collection plug establishes a connection with MapQuest, submits queries, stores the results, and returns them to DLIOPWrapper as requested.

Note that this street routing example is somewhat degenerate, because the result of each search (i.e. each request for a route) always returns a single result, namely the string with the driving directions. So some of the features, such as sequential access to subsequent documents in a result set that normally would be used in a collection plug are not really exercised in this example. However, we have included the corresponding code anyway (loops that only run for one iteration, etc.), so this should still work well as an example.

Further documentation: About DLIOP, see http://www-diglib.stanford.edu/cgi-bin/WP/get/SIDL-WP-1997-0054 For an explanation of what collection plugs do, see: **** */ import java.io.*; import java.awt.*; import java.net.*; import java.lang.*; public class CollectionPlug { private String TheQuery; private String content; private int numDocs; // number of docs found as result of a search private int theDocCursor; // next new doc to hand to the wrapper if he asks private int docs_stored; //num of docs pulled from service and cached here. //The names we choose for properties is important. Right now, in order to //make this proxy compatible with the rest of services in InfoBus, the //name of each property should be included in the USMarc.java file. This //is because the InfoBus uses a derivative of USMARC as a lingua franca. private static String[] supportedProps = new String[1]; private String[] requestedProps = new String[supportedProps.length]; // Object that knows how to talk to MapQuest: private StreetRouterServer routerinstance; // Class constructor public CollectionPlug () { supportedProps[0] = "Content"; TheQuery = ""; numDocs = 0; theDocCursor = 0; // Here we create an instance of the class that handles the connections // with the service, in this example the mapquest directions web server routerinstance = new StreetRouterServer(); return; } // SetProperties(props) // props : list of the names of properties the caller wants // included in every returned document. This list must be a subset // of the list of properties supported by this CollectionPlug. If // the list is empty, all properties are wanted: public void SetProperties (String[] props) throws java.lang.IllegalArgumentException { int aux; if (props.length == 0) { //An empty list means all the properties: for(int i=0;i 0) && (theDocCursor < numDocs)) return true; else return false; } public int DocCursor () { return theDocCursor; } // CheckPropAvailability (list of property names) // Returns true if each property in a list of property names is // supported by this CollectionPlug. public static boolean CheckPropAvailability (String[] propList) { for (int i=0; i