public class FilePipe extends Object implements JslipcPipe, JslipcBinman
ReadableJslipcFileChannel
and
WritableJslipcFileChannel
to set up a pipe based on two files. You may
either provide both files
or a
directory and the role
of this end
of the pipe. This implementation provides a
JslipcBinman.cleanUpOnClose()
method, which will delete the files on
close()
.Modifier and Type | Field and Description |
---|---|
static String |
YANG_TO_YIN_NAME |
static String |
YIN_TO_YANG_NAME |
Constructor and Description |
---|
FilePipe(File source,
File sink)
Creates a pipe with a
ReadableJslipcFileChannel and
WritableJslipcFileChannel based on the given files. |
FilePipe(File directory,
JslipcRole role)
This is an alternative to
FilePipe(File, File) where you do not
pass the two files, but a directory hosting two files
yangToYin.channel and yinToYang.channel . |
Modifier and Type | Method and Description |
---|---|
void |
cleanUpOnClose()
Attempts to clean up any resources on
Closeable.close() if they are no longer needed. |
void |
close() |
static File |
getSinkFile(File directory,
JslipcRole role) |
static File |
getSourceFile(File directory,
JslipcRole role) |
WritableJslipcFileChannel |
sink() |
ReadableJslipcFileChannel |
source() |
String |
toString() |
public static final String YANG_TO_YIN_NAME
public static final String YIN_TO_YANG_NAME
public FilePipe(File directory, JslipcRole role) throws IOException
FilePipe(File, File)
where you do not
pass the two files, but a directory hosting two files
yangToYin.channel
and yinToYang.channel
. The
files are created if they do not yet exist. Which one is used for source
or sink depends on the role:
role | source | sink |
---|---|---|
yang | yinToYang.channel | yangToYin.channel |
yin | yangToYin.channel | yinToYang.channel |
yin
or
yang
. It is just needed to distinguish the
endpoints of the pipe, so one end should have the role yin, the other
yang.directory
- role
- IOException
public FilePipe(File source, File sink)
ReadableJslipcFileChannel
and
WritableJslipcFileChannel
based on the given files.source
- the file to create the ReadableJslipcFileChannel
from.sink
- the file to create the WritableJslipcFileChannel
from.public void cleanUpOnClose()
JslipcBinman
Closeable.close()
if they are no longer needed.cleanUpOnClose
in interface JslipcBinman
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public ReadableJslipcFileChannel source() throws IOException
source
in interface JslipcPipe
IOException
public WritableJslipcFileChannel sink() throws IOException
sink
in interface JslipcPipe
IOException
public static File getSourceFile(File directory, JslipcRole role) throws IOException
IOException
public static File getSinkFile(File directory, JslipcRole role) throws IOException
IOException
Copyright © 2014. All Rights Reserved.