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 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