|
LiveGraph data visualisation and analysis framework |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.LiveGraph.dataFile.write.DataStreamWriterFactory
public class DataStreamWriterFactory
This class provides static convenience methods for creating dedicated data stream writers.
Given just a directory on the local hard drive, this class can automatically
choose a descriptive and unique name for a data file and return an appropriate
DataStreamWriter
object.
An example of how to use this class can be found in
LiveGraphDemo
.
This product includes software developed by the
LiveGraph project and its contributors.
(http://www.live-graph.org)
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.
File: DataStreamWriterFactory.java
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:
1. Redistributions of source code must retain the above
acknowledgement of the LiveGraph project and its web-site, the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the
LiveGraph project and its web-site, the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with
the distribution.
3. All advertising materials mentioning features or use of this software or any derived
software must display the following acknowledgement:
This product includes software developed by the LiveGraph project and its
contributors.
(http://www.live-graph.org)
4. All advertising materials distributed in form of HTML pages or any other technology
permitting active hyper-links that mention features or use of this software or any
derived software must display the acknowledgment specified in condition 3 of this
agreement, and in addition, include a visible and working hyper-link to the LiveGraph
homepage (http://www.live-graph.org).
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Field Summary | |
---|---|
static java.lang.String |
defaultFileExtension
Data file extension used if no other specified. |
Constructor Summary | |
---|---|
DataStreamWriterFactory()
|
Method Summary | |
---|---|
static DataStreamWriter |
createDataWriter(java.io.File file,
boolean overwrite)
Creates a new DataStreamWriter object for the specified file. |
static DataStreamWriter |
createDataWriter(PipedInputStream pipedInputStream)
Creates a new DataStreamWriter object to write to the specified PipedInputStream . |
static DataStreamWriter |
createDataWriter(java.lang.String filePath,
boolean overwrite)
Creates a new DataStreamWriter object for the specified file path. |
static DataStreamWriter |
createDataWriter(java.lang.String dataFileDir,
java.lang.String dataFileBaseName)
Creates a new DataStreamWriter object for a unique file whose name is created
on the basis of the specified base name and directory as well as an optional
timestamp and an optional counter to make the file name unique.This method is a convenience shorthand for createDataWriter(dataFileDir, dataFileBaseName, defaultFileExtension) , where
DataStreamWriterFactory.defaultFileExtension = "lgdat". |
static DataStreamWriter |
createDataWriter(java.lang.String dataFileDir,
java.lang.String dataFileBaseName,
java.lang.String dataFileExt)
Creates a new DataStreamWriter object for a unique file whose name is created
on the basis of the specified base name, extension and directory as well as an optional
timestamp and an optional counter to make the file name unique.If despite of the unique file name an output stream cannot be open (this may happen with a small probability in the case of several competing processes) the semantics of this method are the same as for createDataWriter(File, boolean) (with
overwrite = false ).This method uses the library method FileTools.findUniqueFile(String, String, String, boolean)
for generating a unique file path (with alwaysUseTimestamp = false ). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String defaultFileExtension
Constructor Detail |
---|
public DataStreamWriterFactory()
Method Detail |
---|
public static DataStreamWriter createDataWriter(PipedInputStream pipedInputStream) throws java.io.IOException
DataStreamWriter
object to write to the specified PipedInputStream
.
Use this method to create writers to use with the memory stream mode.
pipedInputStream
- The input stream to which the data will be directed.
java.io.IOException
- If an error occurs when creating the piped streams (e.g. when the
PipedInputStream
is already connected or in other cases).public static DataStreamWriter createDataWriter(java.lang.String dataFileDir, java.lang.String dataFileBaseName)
DataStreamWriter
object for a unique file whose name is created
on the basis of the specified base name and directory as well as an optional
timestamp and an optional counter to make the file name unique.createDataWriter(dataFileDir, dataFileBaseName, defaultFileExtension)
, where
DataStreamWriterFactory.defaultFileExtension
= "lgdat".
See the three parameters version
for details.
dataFileDir
- The directory where the data file will be created.dataFileBaseName
- The base name for the data file.
DataStreamWriter
for the file created from the specifed values.
DataFileAlreadyExistsException
- If the specified files exists and canot be
overwritten.createDataWriter(String, String, String)
,
FileTools.findUniqueFile(String, String, String, boolean)
public static DataStreamWriter createDataWriter(java.lang.String dataFileDir, java.lang.String dataFileBaseName, java.lang.String dataFileExt)
DataStreamWriter
object for a unique file whose name is created
on the basis of the specified base name, extension and directory as well as an optional
timestamp and an optional counter to make the file name unique.createDataWriter(File, boolean)
(with
overwrite = false
).FileTools.findUniqueFile(String, String, String, boolean)
for generating a unique file path (with alwaysUseTimestamp = false
).
The semantics are as follows:directory/simulation.lgdat
").directory/simulation.08.01.20-18.30.15.lgdat
".directory/simulation.08.01.20-18.30.15(1).lgdat
".
dataFileDir
- The directory where the data file will be created.dataFileBaseName
- The base name for the data file.dataFileExt
- The extension of the data file.
DataStreamWriter
for the file created from the specifed values.
DataFileAlreadyExistsException
- If the specified files exists and canot be
overwritten.FileTools.findUniqueFile(String, String, String, boolean)
public static DataStreamWriter createDataWriter(java.lang.String filePath, boolean overwrite)
DataStreamWriter
object for the specified file path. overwrite
is true
.overwrite
is false
or for any other reason, the stream creation will be
attempted again several times with a short random delay that increases after each attempt. DataFileAlreadyExistsException
will be raised.createDataWriter(new File(filePath), overwrite)
.
filePath
- Path of the file to which the new DataStreamWriter
is to write its output.overwrite
- Whether to attempt overwriting the specified file it is exists.
DataStreamWriter
for the specified file.
java.lang.NullPointerException
- If the specified file is null
.
DataFileAlreadyExistsException
- If the specified files exists and canot be
overwritten.public static DataStreamWriter createDataWriter(java.io.File file, boolean overwrite)
DataStreamWriter
object for the specified file. overwrite
is true
.overwrite
is false
or for any other reason, the stream creation will be
attempted again several times with a short random delay that increases after each attempt. DataFileAlreadyExistsException
will be raised.
file
- A file to which the new DataStreamWriter
is to write its output.overwrite
- Whether to attempt overwriting the specified file it is exists.
DataStreamWriter
to the specified file.
java.lang.NullPointerException
- If the specified file is null
.
DataFileAlreadyExistsException
- If the specified files exists and canot be
overwritten.
|
LiveGraph data visualisation and analysis framework |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |