de.unikassel.android.sdcframework.transmission
Class AbstractConnectionStrategy

Package class diagram package AbstractConnectionStrategy
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.AbstractChainWorker<ProtocolStrategy>
      extended by de.unikassel.android.sdcframework.transmission.AbstractConnectionStrategy
All Implemented Interfaces:
ConnectionStrategy, ChainWorker<ProtocolStrategy>
Direct Known Subclasses:
MobileConnectionStrategy, UseAvailableConnectionStrategy, WLANConnectionStrategy

public abstract class AbstractConnectionStrategy
extends AbstractChainWorker<ProtocolStrategy>
implements ConnectionStrategy

Abstract base class for connection strategy types, knowing a successor to delegate to if the strategy fails.


Field Summary
private  ConnectivityWrapper connectivityWrapper
          The the connectivity wrapper to access network information
private  Class<?> controlActivityClass
          The control activity class to use for notifications.
static int NOTIFICATION
          The notification id
 
Constructor Summary
AbstractConnectionStrategy(ConnectivityWrapper connectivityWrapper, Class<?> controlActivityClass)
          Constructor
 
Method Summary
 boolean doWork(ProtocolStrategy protocolStrategy)
          The work method called by the client
protected  ConnectivityWrapper getConnectivityWrapper()
          Getter for the connectivity wrapper
protected  boolean isConnectionAvailable(Context context, int networkType, String hostName)
          Internal method to test for an available connection of a specific type
protected  boolean process(ProtocolStrategy protocolStrategy)
          Processing method of the worker
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractChainWorker
getSuccessor, setSuccessor, withSuccessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unikassel.android.sdcframework.transmission.facade.ConnectionStrategy
isConnectionAvailable
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ChainWorker
getSuccessor, setSuccessor, withSuccessor
 

Field Detail

NOTIFICATION

public static final int NOTIFICATION
The notification id


connectivityWrapper

private final ConnectivityWrapper connectivityWrapper
The the connectivity wrapper to access network information


controlActivityClass

private final Class<?> controlActivityClass
The control activity class to use for notifications.

Constructor Detail

AbstractConnectionStrategy

public AbstractConnectionStrategy(ConnectivityWrapper connectivityWrapper,
                                  Class<?> controlActivityClass)
Constructor

Parameters:
connectivityWrapper - the connectivity wrapper to use
controlActivityClass - the control activity class or null
Method Detail

getConnectivityWrapper

protected ConnectivityWrapper getConnectivityWrapper()
Getter for the connectivity wrapper

Returns:
the connectivity wrapper

doWork

public final boolean doWork(ProtocolStrategy protocolStrategy)
Description copied from interface: ChainWorker
The work method called by the client

Specified by:
doWork in interface ChainWorker<ProtocolStrategy>
Overrides:
doWork in class AbstractChainWorker<ProtocolStrategy>
Parameters:
protocolStrategy - the client to do the work for
Returns:
true if successful, false otherwise

process

protected final boolean process(ProtocolStrategy protocolStrategy)
Description copied from class: AbstractChainWorker
Processing method of the worker

Specified by:
process in class AbstractChainWorker<ProtocolStrategy>
Parameters:
protocolStrategy - the client
Returns:
true if successful

isConnectionAvailable

protected final boolean isConnectionAvailable(Context context,
                                              int networkType,
                                              String hostName)
Internal method to test for an available connection of a specific type

Parameters:
context - the application context
networkType - the network type
hostName - the host name if a rout to host shall be tested, otherwise null
Returns:
true if a connection is available, false otherwise