import java.util.*; /** * This class exemplifies what an application would look like if it used * the MobileClient class to provide location awareness to a device. * Besides constructing a new MobileClient object, the most important * part of the TestApp class is the roomChanged method, which is called * by the MobileClient class when there has been a change in room data. * The object received by the roomChanged method is a HashMap, which * maps room-identifying strings to relative magnitudes. Higher * magnitudes represent a greater confidence in the room identified the * string key. This test application simply prints out the room * distribution magnitudes, but other applications can use this * information as necessary. * * @author Chris Palistrant * @author Tony Offer * @version 1.0 */ public class TestApp implements LocationTracker { private MobileClient mc = null; public TestApp(boolean debug) { mc = new MobileClient(this, debug); } /** * This method is called by the Mobile Client class with a HashMap * containing room strings and their associated relative confidence * magnitudes. The TestApp class simply displays these magnitudes. * * @param distribution The map of room-identifying strings to * associated relative confidence magnitudes. */ public void roomChanged(HashMap distribution) { Iterator I = distribution.keySet().iterator(); System.out.println(""); while (I.hasNext()) { String room = (String) I.next(); System.out.println(room + ": " + ((Integer) distribution.get (room)).intValue()); } System.out.println(""); } /** * Create a new TestApp object, which in turn creates a new * MobileClient object. Once a MobileClient is created, updates * containing room information periodically come in to this class. * Running TestApp with the option "-d" provides extra debugging * output. */ public static void main (String [] args) { TestApp test; if (args.length > 0 && args[0].equals("-d")) test = new TestApp(true); else test = new TestApp(false); } }