public abstract class FileRemoteAccessor extends java.lang.Object implements EventConsumer
Modifier and Type | Class and Description |
---|---|
static class |
FileRemoteAccessor.FileWalkerThread
This class offers a Thread especially for
FileRemoteAccessor#walkFileTree(FileRemote, boolean, FileFilter, int, CallbackFile)
which can be use for devices which can evaluate the files by immediately system calls without communication but with maybe waiting for response. |
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID |
static java.lang.String |
version
Version, history and license.
|
mEventConsumed, mEventConsumerException, mEventConsumFinished, mEventDonotRelinquish, mMaskReservedHere
Modifier | Constructor and Description |
---|---|
protected |
FileRemoteAccessor() |
Modifier and Type | Method and Description |
---|---|
abstract void |
abortAll()
Abort currently running and saved copy, check etc. actions.
|
abstract void |
activate()
Activates working of the devide, thread starting, communication establishing etc.
|
abstract void |
close() |
abstract java.lang.String |
cmd(boolean bWait,
FileRemoteCmdEventData co,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Common form of a command with the file.
|
java.lang.String |
cmdFile(FileRemote file,
FileRemoteCmdEventData.Cmd cmd,
FileRemote fileDst,
java.lang.String nameNew,
long dateNew,
EventWithDst<FileRemoteProgressEvData,FileRemoteCmdEventData> evBack)
Command to handle one single file and maybe a destination file for example for rename, copy, mkdir etc.
|
abstract java.lang.CharSequence |
completeFilePath(java.lang.CharSequence path)
Returns a unique absolute path for the file regarding maybe tmp, home, environment variables etc.
|
abstract void |
copyChecked(FileRemote fileSrc,
java.lang.String pathDst,
java.lang.String nameModification,
int mode,
FileRemoteWalkerCallback callbackUser,
FileRemoteProgressEvData timeOrderProgress)
Copies all files which are checked before.
|
abstract boolean |
createNewFile(FileRemote file,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
abstract boolean |
delete(FileRemote file,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Try to delete the file.
|
abstract java.util.List<java.io.File> |
getChildren(FileRemote file,
java.io.FileFilter filter)
Gets files and sub directories of a directory.
|
abstract java.lang.CharSequence |
getStateInfo() |
abstract boolean |
isLocalFileSystem()
Creates or prepares a CmdEvent to send to the correct destination.
|
abstract boolean |
mkdir(FileRemote file,
boolean subdirs,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
abstract java.io.InputStream |
openInputStream(FileRemote file,
long passPhase)
Creates an InputStream with this fileRemote instance.
|
abstract java.io.OutputStream |
openOutputStream(FileRemote file,
long passPhase)
Creates an OutputStream with this fileRemote instance.
|
abstract java.nio.channels.ReadableByteChannel |
openRead(FileRemote file,
long passPhase) |
abstract java.nio.channels.WritableByteChannel |
openWrite(FileRemote file,
long passPhase) |
abstract void |
refreshFileProperties(FileRemote file,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Gets the properties of the file from the physical file.
|
abstract void |
search(FileRemote fileSrc,
byte[] search,
FileRemoteWalkerCallback callbackUser,
FileRemoteProgressEvData timeOrderProgress)
Search in all files.
|
protected abstract boolean |
setLastModified(FileRemote file,
long time) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
evThread, processEvent
private static final long serialVersionUID
public static final java.lang.String version
cmdFile(FileRemote, org.vishia.fileRemote.FileRemoteCmdEventData.Cmd, FileRemote, String, long, EventWithDst)
.
as common solution for all Accessor, uses cmd(boolean, FileRemoteCmdEventData, EventWithDst)
for execution.
close()
defined here,
because there are anytime again unnecessary warnings "resource" on access to this instance.
openOutputStream(FileRemote, long)
Note: it may be that the openRead(FileRemote, long)
and openWrite(FileRemote, long)
is not proper for some requirements, working with the traditional streams may be better.
#walkFileTreeCheck(FileRemote, boolean, boolean, boolean, String, long, int, FileRemoteWalkerCallback)
CallbackFile
, #walkFileTree(FileRemote, FileFilter, int, CallbackFile)
.
setLastModified(FileRemote, long)
.
getChildren(FileRemote, FileFilter)
here only abstract.
openInputStream(FileRemote, long)
getChildren(FileRemote, FileFilter)
implemented here.
FileAccessZip
,
see FileRemote
Commission#newDate
etc.
for FileRemote#chgProps(String, int, int, long, org.vishia.fileRemote.FileRemote.CallbackEvent)
.
#refreshFileProperties(FileRemote)
.
Commission
and #addCommission(Commission)
. It is used
to add commissions to the implementation class to do in another thread/via communication.
FileRemoteAccessorLocalFile
is written.
public abstract void activate()
public abstract void close()
public abstract java.lang.CharSequence completeFilePath(java.lang.CharSequence path)
path
- given pathpublic abstract void refreshFileProperties(FileRemote file, EventWithDst<FileRemoteProgressEvData,?> evBack)
file
- the destination file object.callback
- If null then the method should access the file system immediately in this thread.
It means it is possible that this needs a longer time for wait for response
from a maybe remote file system with a suitable timeout.
public abstract java.lang.String cmd(boolean bWait, FileRemoteCmdEventData co, EventWithDst<FileRemoteProgressEvData,?> evBack)
bWait
- true then wait for fulfill. If it is a local file (depends on FileRemote.device()
,
then the execution is immediately done in the same thread.
If it is especially a file on a remote device only able to reach via communication
( for example on an embedded device), the operation should wait for success.co
- Command description. It is the payload of an command event.evBack
- prepared event for back information or also for progress.
The event knows a destination where the back event is processed.
If this argument is null, no back information will be sent. This is sensible if bWait is true,
and if the caller can check what is happen.
Hint: Usual an instance of FileRemoteProgressEventConsumer
can be used to execute the event,
and also to wait for success on user level.public java.lang.String cmdFile(FileRemote file, FileRemoteCmdEventData.Cmd cmd, FileRemote fileDst, java.lang.String nameNew, long dateNew, EventWithDst<FileRemoteProgressEvData,FileRemoteCmdEventData> evBack)
cmd(boolean, FileRemoteCmdEventData, EventWithDst)
with prepared FileRemoteCmdEventData gotten from a given evBack . EventWithDst.getOpponent()
or if that is not given from a temporary instance for 'FileRemoteCmdEventData'.file
- The file to handlecmd
- command what to dofileDst
- null or maybe a destination path due to cmdnameNew
- null or maybe a new name due to cmd (for rename)dateNew
- null or maybe a timestamp due to cmd.evBack
- back event and the command event usable given as EventWithDst.getOpponent()
.
If the opponent is not given, the command will be executed in the own thread.cmd(boolean, FileRemoteCmdEventData, EventWithDst)
.
null if successfully or no error known. The complete success will be notified by evBack.
If evBack is not given, null is a hint that all is done successfully.public abstract java.util.List<java.io.File> getChildren(FileRemote file, java.io.FileFilter filter)
File
access methods to get the children of this file.file
- parent directory.filter
- maybe a filterprotected abstract boolean setLastModified(FileRemote file, long time)
public abstract boolean createNewFile(FileRemote file, EventWithDst<FileRemoteProgressEvData,?> evBack) throws java.io.IOException
java.io.IOException
public abstract boolean delete(FileRemote file, EventWithDst<FileRemoteProgressEvData,?> evBack)
callback
- public abstract boolean mkdir(FileRemote file, boolean subdirs, EventWithDst<FileRemoteProgressEvData,?> evBack)
file
- subdirs
- true then create all necessary dirs on the pathevBack
- It will be called on any directory which was made, to update the local instance of FileRemote.public abstract void copyChecked(FileRemote fileSrc, java.lang.String pathDst, java.lang.String nameModification, int mode, FileRemoteWalkerCallback callbackUser, FileRemoteProgressEvData timeOrderProgress)
fileSrc
- dir or file as root for copy to the given pathDstpathDst
- String given destination for the copynameModification
- Modification for each name. null then no modification. TODOmode
- One of the bits FileRemote.modeCopyCreateYes
etc.callbackUser
- Maybe null, elsewhere on every directory and file which is finished to copy a callback is invoked.timeOrderProgress
- may be null, to show the progress of copy.public abstract void search(FileRemote fileSrc, byte[] search, FileRemoteWalkerCallback callbackUser, FileRemoteProgressEvData timeOrderProgress)
fileSrc
- dir or file as root for search the given byte[]callbackUser
- Maybe null, elsewhere on every directory and file which is finished to copy a callback is invoked.timeOrderProgress
- may be null, to show the progress of copy.public abstract java.nio.channels.ReadableByteChannel openRead(FileRemote file, long passPhase)
public abstract java.io.InputStream openInputStream(FileRemote file, long passPhase)
file
- passPhase
- public abstract java.nio.channels.WritableByteChannel openWrite(FileRemote file, long passPhase)
public abstract java.io.OutputStream openOutputStream(FileRemote file, long passPhase)
file
- passPhase
- public abstract boolean isLocalFileSystem()
public abstract java.lang.CharSequence getStateInfo()
public abstract void abortAll()