com.continuent.tungsten.common.config
Class TungstenPropertiesIO

java.lang.Object
  extended by com.continuent.tungsten.common.config.TungstenPropertiesIO

public class TungstenPropertiesIO
extends java.lang.Object

This class reads and writes TungstenProperties data safely on a file system. It uses the generic FileIO class to ensure that properties files are handled as efficiently as possible.


Field Summary
 java.lang.String JAVA_PROPERTIES
          Process file using Java properties format serialization.
 java.lang.String JSON
          Process file using JSON format serialization.
 
Constructor Summary
TungstenPropertiesIO(java.io.File path)
          Creates a new instance for OS file system operating on the caller-specified file.
TungstenPropertiesIO(FileIO fileIO, FilePath filePath)
          Creates a new instance with user-specified FileIO implementation and file path.
 
Method Summary
 boolean delete()
          Delete the properties file.
 boolean exists()
          Returns true if the properties file exists.
 java.lang.String getCharset()
           
 java.lang.String getFormat()
           
 TungstenProperties read()
          Read properties file from the file system using selected serialization format and character set.
 void setCharset(java.lang.String charset)
          Sets the character set to use.
 void setFormat(java.lang.String format)
          Sets the serialization format to use.
 void write(TungstenProperties properties, boolean fsync)
          Write properties file to the file system using selected serialization format and character set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JSON

public final java.lang.String JSON
Process file using JSON format serialization.

See Also:
Constant Field Values

JAVA_PROPERTIES

public final java.lang.String JAVA_PROPERTIES
Process file using Java properties format serialization.

See Also:
Constant Field Values
Constructor Detail

TungstenPropertiesIO

public TungstenPropertiesIO(FileIO fileIO,
                            FilePath filePath)
Creates a new instance with user-specified FileIO implementation and file path.


TungstenPropertiesIO

public TungstenPropertiesIO(java.io.File path)
Creates a new instance for OS file system operating on the caller-specified file.

Method Detail

getFormat

public java.lang.String getFormat()

setFormat

public void setFormat(java.lang.String format)
Sets the serialization format to use.


getCharset

public java.lang.String getCharset()

setCharset

public void setCharset(java.lang.String charset)
Sets the character set to use.


exists

public boolean exists()
Returns true if the properties file exists.


delete

public boolean delete()
Delete the properties file.

Returns:
true if fully successful, otherwise false.

write

public void write(TungstenProperties properties,
                  boolean fsync)
           throws FileIOException
Write properties file to the file system using selected serialization format and character set.

Parameters:
properties - Properties to be written
fsync - If true issue an fsync, otherwise just flush
Throws:
FileIOException - Thrown if file is not writable

read

public TungstenProperties read()
                        throws FileIOException
Read properties file from the file system using selected serialization format and character set.

Returns:
Properties instance
Throws:
FileIOException - Thrown if file is not readable