public class LockWriter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static byte[] |
linesep_ |
private java.io.OutputStream |
out_ |
private static java.util.regex.Pattern |
TOKEN_PATTERN |
private static java.lang.String |
TOKEN_REGEX |
Constructor and Description |
---|
LockWriter(java.io.OutputStream out)
Constructs a writer for writing to a given output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the output stream.
|
private static byte[] |
getLineSeparator()
Returns the platform-specific line separator sequence as an array of
bytes.
|
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.
|
private final java.io.OutputStream out_
private static final byte[] linesep_
private static final java.lang.String TOKEN_REGEX
private static final java.util.regex.Pattern TOKEN_PATTERN
public LockWriter(java.io.OutputStream out)
out
- output streampublic void writeAssignments(java.util.Map map) throws java.io.IOException
map
- assignment set to outputjava.io.IOException
public void writeAssignment(java.lang.String name, java.lang.String value) throws java.io.IOException
name
- assignment keyvalue
- assignment valuejava.io.IOException
public void writeComment(java.lang.String comment) throws java.io.IOException
comment
- comment textjava.io.IOException
public void writeLine() throws java.io.IOException
java.io.IOException
protected void writeLine(java.lang.String line) throws java.io.IOException
line
- line to writejava.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public static void setLockPermissions(java.io.File file) throws java.io.IOException
file
- file to set access permissions onjava.io.IOException
private static final byte[] getLineSeparator()