From 0a1e364e03f0f88d4c73f9c7100d2d855fd195e9 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 22 Aug 2001 00:08:12 +0000 Subject: [PATCH] Created adapters for the ClientObserver and LocationObserver interfaces to make handling just one or two of the callbacks for those interfaces simpler. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@305 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/client/LocationAdapter.java | 35 ++++++++++++++++ .../presents/client/ClientAdapter.java | 42 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/java/com/threerings/crowd/client/LocationAdapter.java create mode 100644 src/java/com/threerings/presents/client/ClientAdapter.java diff --git a/src/java/com/threerings/crowd/client/LocationAdapter.java b/src/java/com/threerings/crowd/client/LocationAdapter.java new file mode 100644 index 000000000..a03d2d83d --- /dev/null +++ b/src/java/com/threerings/crowd/client/LocationAdapter.java @@ -0,0 +1,35 @@ +// +// $Id: LocationAdapter.java,v 1.1 2001/08/22 00:08:12 mdb Exp $ + +package com.threerings.cocktail.party.client; + +import com.threerings.cocktail.party.data.PlaceObject; + +/** + * The location adapter makes life easier for a class that really only + * cares about one or two of the location observer callbacks and doesn't + * want to provide empty implementations of the others. One can either + * extend location adapter, or create an anonymous instance that overrides + * the desired callback(s). Note that the location adapter defaults to + * ratifying any location change. + * + * @see LocationObserver + */ +public class LocationAdapter implements LocationObserver +{ + // documentation inherited + public boolean locationMayChange (int placeId) + { + return true; + } + + // documentation inherited + public void locationDidChange (PlaceObject place) + { + } + + // documentation inherited + public void locationChangeFailed (int placeId, String reason) + { + } +} diff --git a/src/java/com/threerings/presents/client/ClientAdapter.java b/src/java/com/threerings/presents/client/ClientAdapter.java new file mode 100644 index 000000000..bb1aeab1f --- /dev/null +++ b/src/java/com/threerings/presents/client/ClientAdapter.java @@ -0,0 +1,42 @@ +// +// $Id: ClientAdapter.java,v 1.1 2001/08/22 00:08:12 mdb Exp $ + +package com.threerings.cocktail.cher.client; + +/** + * The client adapter makes life easier for client observer classes that + * only care about one or two of the client observer callbacks. They can + * either extend client adapter or create an anonymous class that extends + * it and overrides just the callbacks they care about. + * + *

Note that the client adapter defaults to always ratifying a call to + * {@link * #clientWillLogoff} by returning true. + */ +public class ClientAdapter implements ClientObserver +{ + // documentation inherited + public void clientDidLogon (Client client) + { + } + + // documentation inherited + public void clientFailedToLogon (Client client, Exception cause) + { + } + + // documentation inherited + public void clientConnectionFailed (Client client, Exception cause) + { + } + + // documentation inherited + public boolean clientWillLogoff (Client client) + { + return true; + } + + // documentation inherited + public void clientDidLogoff (Client client) + { + } +}