de.unikassel.android.sdcframework.transmission
Class AbstractProtocol

Package class diagram package AbstractProtocol
java.lang.Object
  extended by de.unikassel.android.sdcframework.transmission.AbstractProtocol
All Implemented Interfaces:
ProtocolStrategy, UpdatableTransmissionComponent<TransmissionProtocolConfiguration>
Direct Known Subclasses:
SimpleHttpProtocol, UnknownProtocol

public abstract class AbstractProtocol
extends Object
implements ProtocolStrategy

Abstract base class for protocol types.


Field Summary
private  String authPassword
          The password for authentication
protected  Context context
          the application context to use
static String FILE_NOT_FOUND
          The file not found message
private  String fileName
          The current file to upload
static String INVALID_URL
          The invalid URL message
protected  String lastError
          The last error message
static String UNKNOWN_PROTCOL
          The unknown protocol message
private  URL url
          The URL to upload files to
private  String userName
          The user name for authentication
private  UUID uuid
          The unique SDC installation identifier for this device
 
Constructor Summary
AbstractProtocol(Context context, UUID uuid, TransmissionProtocolConfiguration config)
          Constructor
 
Method Summary
protected  void doHandleError(String errorMsg)
          Error handler
protected abstract  boolean doUploadFile(File file)
          Does upload a file according to the concrete protocol
protected  String getAuthPassword()
          Getter for the authPassword
 Context getContext()
          Getter for the application context
 String getFileName()
          Getter for name of the file to upload
 String getHost()
          Getter for the host
 String getLastError()
          Getter for the last error
protected  String getMd5Password()
          Getter for the authPassword
 URL getURL()
          Getter for the URL
protected  String getUserName()
          Getter for the userName
protected  UUID getUuid()
          Getter for the uuid
 void setFileName(String fileName)
          Setter for the file to upload
 void setLastError(String lastError)
          Setter for the last error
protected  void setURL(URL url)
          Setter for the url
 void updateConfiguration(Context context, TransmissionProtocolConfiguration config)
          Method to update the component by a configuration
 boolean uploadFile()
          Does upload the current file set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_NOT_FOUND

public static final String FILE_NOT_FOUND
The file not found message

See Also:
Constant Field Values

INVALID_URL

public static final String INVALID_URL
The invalid URL message

See Also:
Constant Field Values

UNKNOWN_PROTCOL

public static final String UNKNOWN_PROTCOL
The unknown protocol message

See Also:
Constant Field Values

url

private URL url
The URL to upload files to


userName

private String userName
The user name for authentication


authPassword

private String authPassword
The password for authentication


fileName

private String fileName
The current file to upload


context

protected final Context context
the application context to use


uuid

private final UUID uuid
The unique SDC installation identifier for this device


lastError

protected String lastError
The last error message

Constructor Detail

AbstractProtocol

public AbstractProtocol(Context context,
                        UUID uuid,
                        TransmissionProtocolConfiguration config)
Constructor

Parameters:
context - the context
uuid - the unique SDC installation identifier for this device
config - the current transmission configuration
Method Detail

getURL

public final URL getURL()
Description copied from interface: ProtocolStrategy
Getter for the URL

Specified by:
getURL in interface ProtocolStrategy
Returns:
the URL

getHost

public final String getHost()
Description copied from interface: ProtocolStrategy
Getter for the host

Specified by:
getHost in interface ProtocolStrategy
Returns:
the host if url is valid, otherwise null

setURL

protected final void setURL(URL url)
Setter for the url

Parameters:
url - the url to set

getUserName

protected final String getUserName()
Getter for the userName

Returns:
the userName

getAuthPassword

protected final String getAuthPassword()
Getter for the authPassword

Returns:
the authPassword

getMd5Password

protected final String getMd5Password()
Getter for the authPassword

Returns:
the authPassword

getContext

public final Context getContext()
Description copied from interface: ProtocolStrategy
Getter for the application context

Specified by:
getContext in interface ProtocolStrategy
Returns:
the application context

getUuid

protected UUID getUuid()
Getter for the uuid

Returns:
the uuid

setFileName

public final void setFileName(String fileName)
Description copied from interface: ProtocolStrategy
Setter for the file to upload

Specified by:
setFileName in interface ProtocolStrategy
Parameters:
fileName - the name of the file to upload

getFileName

public final String getFileName()
Description copied from interface: ProtocolStrategy
Getter for name of the file to upload

Specified by:
getFileName in interface ProtocolStrategy
Returns:
the file to upload

setLastError

public final void setLastError(String lastError)
Description copied from interface: ProtocolStrategy
Setter for the last error

Specified by:
setLastError in interface ProtocolStrategy
Parameters:
lastError - the laste error to set

getLastError

public final String getLastError()
Description copied from interface: ProtocolStrategy
Getter for the last error

Specified by:
getLastError in interface ProtocolStrategy
Returns:
the last error description or null if no error did occur

updateConfiguration

public final void updateConfiguration(Context context,
                                      TransmissionProtocolConfiguration config)
Description copied from interface: UpdatableTransmissionComponent
Method to update the component by a configuration

Specified by:
updateConfiguration in interface UpdatableTransmissionComponent<TransmissionProtocolConfiguration>
Parameters:
context - the application context
config - the configuration to update from

uploadFile

public final boolean uploadFile()
Description copied from interface: ProtocolStrategy
Does upload the current file set

Specified by:
uploadFile in interface ProtocolStrategy
Returns:
true if successful, flase otherwise

doHandleError

protected final void doHandleError(String errorMsg)
Error handler

Parameters:
errorMsg - the error massage

doUploadFile

protected abstract boolean doUploadFile(File file)
Does upload a file according to the concrete protocol

Parameters:
file - the file for upload
Returns:
true if successful, false otherwise ( last error will be set in this case )