Package org.astrogrid.samp.hub

# Class LockWriter

java.lang.Object
org.astrogrid.samp.hub.LockWriter

public class LockWriter extends Object
Writes records to a SAMP Standard Profile hub lockfile.

Since:
  15 Jul 2008
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`LockWriter(OutputStream out)`
Constructs a writer for writing to a given output stream.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Closes the output stream.
`static void`
`setLockPermissions(File file)`
Sets the permissions on a given file suitably for a SAMP Standard Profile lockfile.
`void`
`writeAssignment(String name, String value)`
Writes a single assignment to the lockfile.
`void`
`writeAssignments(Map map)`
Writes all the assignments in a given map to the lockfile.
`void`
`writeComment(String comment)`
Writes a comment line to the lockfile.
`void`
`writeLine()`
Writes a blank line to the lockfile.
`protected void`
`writeLine(String line)`
Writes a line of text to the lockfile, terminated with a line-end.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### LockWriter

public LockWriter(OutputStream out)
Constructs a writer for writing to a given output stream.

Parameters:
  `out` - output stream

## Method Details

### writeAssignments

public void writeAssignments(Map map) throws IOException
Writes all the assignments in a given map to the lockfile.

Parameters:
  `map` - assignment set to output
Throws:
  `IOException`

### writeAssignment

public void writeAssignment(String name, String value) throws IOException
Writes a single assignment to the lockfile.

Parameters:
  `name` - assignment key
  `value` - assignment value
Throws:
  `IOException`

### writeComment

public void writeComment(String comment) throws IOException
Writes a comment line to the lockfile.

Parameters:
  `comment` - comment text
Throws:
  `IOException`

### writeLine

public void writeLine() throws IOException
Writes a blank line to the lockfile.

Throws:
  `IOException`

### writeLine

protected void writeLine(String line) throws IOException
Writes a line of text to the lockfile, terminated with a line-end.

Parameters:
  `line` - line to write
Throws:
  `IOException`

### close

public void close() throws IOException
Closes the output stream. May be required to ensure that all data is written.

Throws:
  `IOException`

### setLockPermissions

public static void setLockPermissions(File file) throws 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:
  `IOException`