Package ipsk.net
Class UploadCache
- java.lang.Object
- 
- ipsk.net.UploadCache
 
- 
- All Implemented Interfaces:
- java.lang.Runnable
 - Direct Known Subclasses:
- HttpUploadCache,- SplittingHttpUploadCache
 
 public abstract class UploadCache extends java.lang.Object implements java.lang.RunnableCaches upload data and sends it to remote server.- Author:
- K.Jaensch, klausj@phonetik.uni-muenchen.de
- See Also:
- Upload
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classUploadCache.EventTransformer
 - 
Field SummaryFields Modifier and Type Field Description protected byte[]bufferprotected intbufSizeprotected floatbyteRateprotected static intCONNECT_RETRY_DELAYprotected booleanconnectedprotected longconnectedTimeInMillisprotected java.net.URLConnectionconnectionprotected UploadcurrentStreamprotected intcurrentStreamIndexprotected Upload[]currentUploadprotected static booleanDEBUGprotected static intDEBUG_DELAYstatic java.lang.StringDEF_CHECKSUM_ALGORITHMprotected static intDEFAULT_BUFSIZEprotected static intDEFAULT_CONNECT_RETRIESprotected UploadCache.EventTransformereventTransformerprotected longguessedToUploadLengthprotected longholdLengthprotected longholdSizeprotected booleanidleprotected booleanidleNotifiedprotected java.io.InputStreaminputStreamprotected static intON_IDLE_DELAYprotected java.io.OutputStreamoutputStreamprotected java.lang.StringrequestMethodprotected java.lang.StringresponseMessageprotected booleanrunningprotected longstartConnectprotected booleansyncedprotected longtotalLengthprotected longtotalUploadLengthprotected longtoUploadLengthprotected inttransferRateLimitprotected booleantransferRateLimitSupportedstatic intUNLIMITEDprotected static intUPLOAD_RETRIESprotected static intUPLOAD_RETRY_DELAYprotected intuploadRetryCount
 - 
Constructor SummaryConstructors Constructor Description UploadCache()Create new empty cache.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddUploadCacheListener(UploadCacheListener acl)Add listener.protected voidcalculateLength()voidclear()Clear all contents.voidclose()Close upload cache.protected voidfireConnected()protected voidfireDisconnected()protected voidfireFinished()protected voidfireStateChanged(Upload uvb)protected voidfireStateChangedWait(Upload uvb)protected voidfireTryConnect()floatgetByteRate()Get estimated upload byte rate.java.io.InputStream[]getCachedInputStream(java.net.URL[] urls)Try to get an input stream to cached data for the given URL.UploadgetCurrentUploadStream()Get the current upload.longgetGuessedToUploadLength()Get guessed bytes to upload.longgetHoldLength()Get current count of hold bytes.longgetHoldSize()Get maximum of bytes to hold in the cache.protected voidgetNextUpload()java.lang.StringgetRequestMethod()Get HTTP request method.intgetResponseCode()Get current HTTP response code.java.lang.StringgetResponseMessage()Get HTTP response message.longgetTotalLength()Get total length in bytes.longgetTotalUploadLength()Get total bytes already uploaded.longgetToUploadLength()Get bytes to upload.intgetTransferLimit()booleanisConnected()Get connected status.booleanisIdle()Get idle status.booleanisOverwrite()booleanisRunning()Get upload running status.booleanisTransferLimitSupported()voidremoveUploadCacheListener(UploadCacheListener acl)Remove listener.abstract voidrun()voidsetHoldSize(long l)Set maximum of bytes to hold in the cache.voidsetOverwrite(boolean overwrite)voidsetRequestMethod(java.lang.String string)Set HTTP request method.voidsetTransferLimit(int transferLimit)voidsetTransferLimitSupported(boolean transferLimitSupported)voidstart()Start upload.voidstop()Stop upload.voidupload(Upload[] vbs)Request an upload of the referenced data buffers to the given URLs.
 
- 
- 
- 
Field Detail- 
DEF_CHECKSUM_ALGORITHMpublic static final java.lang.String DEF_CHECKSUM_ALGORITHM - See Also:
- Constant Field Values
 
 - 
DEBUGprotected static boolean DEBUG 
 - 
UNLIMITEDpublic static final int UNLIMITED - See Also:
- Constant Field Values
 
 - 
ON_IDLE_DELAYprotected static int ON_IDLE_DELAY 
 - 
CONNECT_RETRY_DELAYprotected static int CONNECT_RETRY_DELAY 
 - 
DEFAULT_CONNECT_RETRIESprotected static int DEFAULT_CONNECT_RETRIES 
 - 
UPLOAD_RETRY_DELAYprotected static int UPLOAD_RETRY_DELAY 
 - 
UPLOAD_RETRIESprotected static int UPLOAD_RETRIES 
 - 
DEBUG_DELAYprotected static int DEBUG_DELAY 
 - 
DEFAULT_BUFSIZEprotected static int DEFAULT_BUFSIZE 
 - 
byteRateprotected float byteRate 
 - 
connectedTimeInMillisprotected long connectedTimeInMillis 
 - 
totalUploadLengthprotected long totalUploadLength 
 - 
connectedprotected boolean connected 
 - 
idleprotected boolean idle 
 - 
idleNotifiedprotected boolean idleNotified 
 - 
bufSizeprotected int bufSize 
 - 
outputStreamprotected java.io.OutputStream outputStream 
 - 
inputStreamprotected java.io.InputStream inputStream 
 - 
bufferprotected byte[] buffer 
 - 
connectionprotected java.net.URLConnection connection 
 - 
requestMethodprotected java.lang.String requestMethod 
 - 
currentUploadprotected Upload[] currentUpload 
 - 
currentStreamprotected Upload currentStream 
 - 
currentStreamIndexprotected int currentStreamIndex 
 - 
runningprotected boolean running 
 - 
eventTransformerprotected UploadCache.EventTransformer eventTransformer 
 - 
startConnectprotected long startConnect 
 - 
totalLengthprotected long totalLength 
 - 
toUploadLengthprotected long toUploadLength 
 - 
guessedToUploadLengthprotected long guessedToUploadLength 
 - 
holdLengthprotected long holdLength 
 - 
holdSizeprotected long holdSize 
 - 
syncedprotected boolean synced 
 - 
responseMessageprotected java.lang.String responseMessage 
 - 
uploadRetryCountprotected int uploadRetryCount 
 - 
transferRateLimitSupportedprotected boolean transferRateLimitSupported 
 - 
transferRateLimitprotected int transferRateLimit 
 
- 
 - 
Method Detail- 
calculateLengthprotected void calculateLength() 
 - 
uploadpublic void upload(Upload[] vbs) throws UploadException Request an upload of the referenced data buffers to the given URLs.- Parameters:
- vbs- the container of buffer references with data to upload
- Throws:
- UploadException
 
 - 
getCachedInputStreampublic java.io.InputStream[] getCachedInputStream(java.net.URL[] urls) throws UploadExceptionTry to get an input stream to cached data for the given URL.- Parameters:
- urls-
- Returns:
- the input stream if the requested data was found in the cache
- nullif the requested URL data was not found in the cache
 
- Throws:
- UploadException
 
 - 
startpublic void start() Start upload.
 - 
stoppublic void stop() Stop upload.
 - 
getNextUploadprotected void getNextUpload() 
 - 
runpublic abstract void run() - Specified by:
- runin interface- java.lang.Runnable
 
 - 
getCurrentUploadStreampublic Upload getCurrentUploadStream() Get the current upload.- Returns:
- current upload
 
 - 
isConnectedpublic boolean isConnected() Get connected status.- Returns:
- true if connected
 
 - 
clearpublic void clear() Clear all contents.
 - 
closepublic void close() Close upload cache. Same as stop() and clear().
 - 
addUploadCacheListenerpublic void addUploadCacheListener(UploadCacheListener acl) Add listener.- Parameters:
- acl- listener to add
 
 - 
removeUploadCacheListenerpublic void removeUploadCacheListener(UploadCacheListener acl) Remove listener.- Parameters:
- acl- listener to remove
 
 - 
fireConnectedprotected void fireConnected() 
 - 
fireTryConnectprotected void fireTryConnect() 
 - 
fireStateChangedprotected void fireStateChanged(Upload uvb) 
 - 
fireStateChangedWaitprotected void fireStateChangedWait(Upload uvb) 
 - 
fireDisconnectedprotected void fireDisconnected() 
 - 
fireFinishedprotected void fireFinished() 
 - 
getTotalLengthpublic long getTotalLength() Get total length in bytes.- Returns:
- total length of
 
 - 
getTotalUploadLengthpublic long getTotalUploadLength() Get total bytes already uploaded.- Returns:
- uploaded count of bytes
 
 - 
isIdlepublic boolean isIdle() Get idle status.- Returns:
- idle status
 
 - 
getResponseCodepublic int getResponseCode() Get current HTTP response code.- Returns:
- HTTP response code
 
 - 
getResponseMessagepublic java.lang.String getResponseMessage() Get HTTP response message.- Returns:
- HTTP response message
 
 - 
getHoldSizepublic long getHoldSize() Get maximum of bytes to hold in the cache.- Returns:
- maximum hold size
 
 - 
setHoldSizepublic void setHoldSize(long l) Set maximum of bytes to hold in the cache.- Parameters:
- l- maximum hold size
 
 - 
getHoldLengthpublic long getHoldLength() Get current count of hold bytes.- Returns:
- bytes currently hold
 
 - 
getByteRatepublic float getByteRate() Get estimated upload byte rate.- Returns:
- byte rate in bytes/second
 
 - 
getToUploadLengthpublic long getToUploadLength() Get bytes to upload. The current upload is ignored.- Returns:
- bytes to upload
- See Also:
- getGuessedToUploadLength()
 
 - 
getGuessedToUploadLengthpublic long getGuessedToUploadLength() Get guessed bytes to upload. The progress of the current upload can only be estimated.- Returns:
- estimated count of bytes not yet uploaded
 
 - 
getRequestMethodpublic java.lang.String getRequestMethod() Get HTTP request method.- Returns:
- request method
 
 - 
setRequestMethodpublic void setRequestMethod(java.lang.String string) Set HTTP request method.- Parameters:
- string- request method
 
 - 
isRunningpublic boolean isRunning() Get upload running status.- Returns:
- true if upload thread is running.
 
 - 
isOverwritepublic boolean isOverwrite() 
 - 
setOverwritepublic void setOverwrite(boolean overwrite) 
 - 
getTransferLimitpublic int getTransferLimit() 
 - 
setTransferLimitpublic void setTransferLimit(int transferLimit) 
 - 
isTransferLimitSupportedpublic boolean isTransferLimitSupported() 
 - 
setTransferLimitSupportedpublic void setTransferLimitSupported(boolean transferLimitSupported) 
 
- 
 
-