Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

reeb.lazysync
Class LazySyncThread  view LazySyncThread download LazySyncThread.java

java.lang.Object
  extended byjava.lang.Thread
      extended byreeb.lazysync.LazySyncThread
All Implemented Interfaces:
java.lang.Runnable

public class LazySyncThread
extends java.lang.Thread

The SavaJe Java LazySync client


Nested Class Summary
private  class LazySyncThread.AbortException
          Internal abort exception
private  class LazySyncThread.FileInfo
          Private class that encapsulates a files info
private  class LazySyncThread.SyncData
          Stores the changes required
 
Nested classes inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.io.PrintWriter console
          The text area writer
private static int DEFAULT_PORT
          The default server port
private  java.lang.String dir
          The local sync dir
private  java.lang.String serverIp
          The server ip address
private  boolean shouldStop
          Boolean that indicates if the thread should stop
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LazySyncThread(java.io.PrintWriter writer, java.lang.String serverIp, java.lang.String dir)
          Constructor
 
Method Summary
private  boolean arrayContains(java.lang.String[] array, java.lang.String searchItem)
          Searches a string array for a specified item
private  void copyLocalFiles(java.util.Vector files, java.net.Socket socket, java.io.PrintWriter writer, java.io.BufferedReader reader)
          Copies the local files
private  void copyRemoteFiles(java.util.Vector files, java.net.Socket socket, java.io.PrintWriter writer, java.io.BufferedReader reader)
          Copies the remote files
private  void createDir(java.io.BufferedReader reader, java.io.PrintWriter writer, java.lang.String dir)
          Creates a remote directory
private  void createLocalDirs(java.util.Vector dirs)
          Creates the necessary local dirs
private  void createRemoteDirs(java.util.Vector dirs, java.io.BufferedReader reader, java.io.PrintWriter writer)
          Creates the remote directories
private  void deleteFile(java.io.BufferedReader reader, java.io.PrintWriter writer, java.lang.String file)
          Deletes a remote directory or file
private  void deleteRemoteItems(java.util.Vector items, java.io.BufferedReader reader, java.io.PrintWriter writer, java.lang.String type)
          Deletes remote files or directories
private  java.lang.String getByteString(long fileSize)
          Returns a string that represents a file size
private  java.lang.String[] getDirList(java.io.BufferedReader reader, java.io.PrintWriter writer, java.lang.String dir)
          Returns a list of files for a directory
private  LazySyncThread.FileInfo getFileInfo(java.io.BufferedReader reader, java.io.PrintWriter writer, java.lang.String file)
          Returns file info for a specified file
private  void readLastSyncFiles(java.util.Vector dirList, java.util.Vector fileList, java.io.PrintWriter writer, java.io.BufferedReader reader)
          Reads in the last sync files
 void run()
          Main entry point
private  void scanLocalFileSystem(LazySyncThread.SyncData syncData, java.util.Vector thisSyncFiles, java.util.Vector thisSyncDirs, java.io.BufferedReader reader, java.io.PrintWriter writer, java.io.File localDir)
          Scans the local filesystem
private  void scanRemoteFileSystem(LazySyncThread.SyncData syncData, java.util.Vector lastSyncFiles, java.util.Vector lastSyncDirs, java.io.BufferedReader reader, java.io.PrintWriter writer, java.lang.String relativeDir)
          Scans the remote filesystem
 void stopThread()
          Request that the thread should stop
private  void updateLocalFile(java.net.Socket socket, java.io.PrintWriter writer, java.io.BufferedReader reader, java.lang.String relativeFile, LazySyncThread.FileInfo info)
          Updates a local file with one from the server
private  void updateRemoteFile(java.net.Socket socket, java.io.PrintWriter writer, java.io.BufferedReader reader, java.lang.String relativeFile)
          Updates a server file with a local file - will block until server has written
private  void writeLastSyncFiles(java.util.Vector dirList, java.util.Vector fileList, java.io.PrintWriter writer, java.io.BufferedReader reader)
          Writes out the last sync files
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PORT

private static final int DEFAULT_PORT
The default server port

See Also:
Constant Field Values

console

private java.io.PrintWriter console
The text area writer


serverIp

private java.lang.String serverIp
The server ip address


dir

private java.lang.String dir
The local sync dir


shouldStop

private boolean shouldStop
Boolean that indicates if the thread should stop

Constructor Detail

LazySyncThread

public LazySyncThread(java.io.PrintWriter writer,
                      java.lang.String serverIp,
                      java.lang.String dir)
Constructor

Method Detail

stopThread

public void stopThread()
Request that the thread should stop


run

public void run()
Main entry point


deleteRemoteItems

private void deleteRemoteItems(java.util.Vector items,
                               java.io.BufferedReader reader,
                               java.io.PrintWriter writer,
                               java.lang.String type)
                        throws java.lang.Exception
Deletes remote files or directories


createRemoteDirs

private void createRemoteDirs(java.util.Vector dirs,
                              java.io.BufferedReader reader,
                              java.io.PrintWriter writer)
                       throws java.lang.Exception
Creates the remote directories


createLocalDirs

private void createLocalDirs(java.util.Vector dirs)
                      throws java.lang.Exception
Creates the necessary local dirs


copyRemoteFiles

private void copyRemoteFiles(java.util.Vector files,
                             java.net.Socket socket,
                             java.io.PrintWriter writer,
                             java.io.BufferedReader reader)
                      throws java.lang.Exception
Copies the remote files


copyLocalFiles

private void copyLocalFiles(java.util.Vector files,
                            java.net.Socket socket,
                            java.io.PrintWriter writer,
                            java.io.BufferedReader reader)
                     throws java.lang.Exception
Copies the local files


getByteString

private java.lang.String getByteString(long fileSize)
Returns a string that represents a file size


scanRemoteFileSystem

private void scanRemoteFileSystem(LazySyncThread.SyncData syncData,
                                  java.util.Vector lastSyncFiles,
                                  java.util.Vector lastSyncDirs,
                                  java.io.BufferedReader reader,
                                  java.io.PrintWriter writer,
                                  java.lang.String relativeDir)
                           throws java.lang.Exception
Scans the remote filesystem


scanLocalFileSystem

private void scanLocalFileSystem(LazySyncThread.SyncData syncData,
                                 java.util.Vector thisSyncFiles,
                                 java.util.Vector thisSyncDirs,
                                 java.io.BufferedReader reader,
                                 java.io.PrintWriter writer,
                                 java.io.File localDir)
                          throws java.lang.Exception
Scans the local filesystem


arrayContains

private boolean arrayContains(java.lang.String[] array,
                              java.lang.String searchItem)
Searches a string array for a specified item


readLastSyncFiles

private void readLastSyncFiles(java.util.Vector dirList,
                               java.util.Vector fileList,
                               java.io.PrintWriter writer,
                               java.io.BufferedReader reader)
                        throws java.lang.Exception
Reads in the last sync files


writeLastSyncFiles

private void writeLastSyncFiles(java.util.Vector dirList,
                                java.util.Vector fileList,
                                java.io.PrintWriter writer,
                                java.io.BufferedReader reader)
                         throws java.lang.Exception
Writes out the last sync files


updateRemoteFile

private void updateRemoteFile(java.net.Socket socket,
                              java.io.PrintWriter writer,
                              java.io.BufferedReader reader,
                              java.lang.String relativeFile)
                       throws java.lang.Exception
Updates a server file with a local file - will block until server has written


updateLocalFile

private void updateLocalFile(java.net.Socket socket,
                             java.io.PrintWriter writer,
                             java.io.BufferedReader reader,
                             java.lang.String relativeFile,
                             LazySyncThread.FileInfo info)
                      throws java.lang.Exception
Updates a local file with one from the server


deleteFile

private void deleteFile(java.io.BufferedReader reader,
                        java.io.PrintWriter writer,
                        java.lang.String file)
                 throws java.lang.Exception
Deletes a remote directory or file


createDir

private void createDir(java.io.BufferedReader reader,
                       java.io.PrintWriter writer,
                       java.lang.String dir)
                throws java.lang.Exception
Creates a remote directory


getFileInfo

private LazySyncThread.FileInfo getFileInfo(java.io.BufferedReader reader,
                                            java.io.PrintWriter writer,
                                            java.lang.String file)
                                     throws java.lang.Exception
Returns file info for a specified file


getDirList

private java.lang.String[] getDirList(java.io.BufferedReader reader,
                                      java.io.PrintWriter writer,
                                      java.lang.String dir)
                               throws java.lang.Exception
Returns a list of files for a directory