Package org.astrogrid.samp.hub
Class LockWriter
- java.lang.Object
-
- org.astrogrid.samp.hub.LockWriter
-
public class LockWriter extends java.lang.Object
Writes 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 void
close()
Closes the output stream.static void
setLockPermissions(java.io.File file)
Sets the permissions on a given file suitably for a SAMP Standard Profile lockfile.void
writeAssignment(java.lang.String name, java.lang.String value)
Writes a single assignment to the lockfile.void
writeAssignments(java.util.Map map)
Writes all the assignments in a given map to the lockfile.void
writeComment(java.lang.String comment)
Writes a comment line to the lockfile.void
writeLine()
Writes a blank line to the lockfile.protected void
writeLine(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.IOException
Writes 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.IOException
Writes 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.IOException
Writes a comment line to the lockfile.- Parameters:
comment
- comment text- Throws:
java.io.IOException
-
writeLine
public void writeLine() throws java.io.IOException
Writes a blank line to the lockfile.- Throws:
java.io.IOException
-
writeLine
protected void writeLine(java.lang.String line) throws java.io.IOException
Writes 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.IOException
Closes 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.IOException
Sets 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
-
-