Package org.astrogrid.samp.hub
Class LockWriter
- java.lang.Object
-
- org.astrogrid.samp.hub.LockWriter
-
public class LockWriter extends java.lang.ObjectWrites records to a SAMP Standard Profile hub lockfile.- Since:
- 15 Jul 2008
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description LockWriter(java.io.OutputStream out)Constructs a writer for writing to a given output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the output stream.static voidsetLockPermissions(java.io.File file)Sets the permissions on a given file suitably for a SAMP Standard Profile lockfile.voidwriteAssignment(java.lang.String name, java.lang.String value)Writes a single assignment to the lockfile.voidwriteAssignments(java.util.Map map)Writes all the assignments in a given map to the lockfile.voidwriteComment(java.lang.String comment)Writes a comment line to the lockfile.voidwriteLine()Writes a blank line to the lockfile.protected voidwriteLine(java.lang.String line)Writes a line of text to the lockfile, terminated with a line-end.
-
-
-
Method Detail
-
writeAssignments
public void writeAssignments(java.util.Map map) throws java.io.IOExceptionWrites all the assignments in a given map to the lockfile.- Parameters:
map- assignment set to output- Throws:
java.io.IOException
-
writeAssignment
public void writeAssignment(java.lang.String name, java.lang.String value) throws java.io.IOExceptionWrites a single assignment to the lockfile.- Parameters:
name- assignment keyvalue- assignment value- Throws:
java.io.IOException
-
writeComment
public void writeComment(java.lang.String comment) throws java.io.IOExceptionWrites a comment line to the lockfile.- Parameters:
comment- comment text- Throws:
java.io.IOException
-
writeLine
public void writeLine() throws java.io.IOExceptionWrites a blank line to the lockfile.- Throws:
java.io.IOException
-
writeLine
protected void writeLine(java.lang.String line) throws java.io.IOExceptionWrites a line of text to the lockfile, terminated with a line-end.- Parameters:
line- line to write- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses the output stream. May be required to ensure that all data is written.- Throws:
java.io.IOException
-
setLockPermissions
public static void setLockPermissions(java.io.File file) throws java.io.IOExceptionSets the permissions on a given file suitably for a SAMP Standard Profile lockfile. This means that nobody apart from the file's owner can read it.- Parameters:
file- file to set access permissions on- Throws:
java.io.IOException
-
-