maspack.util
Class Write

java.lang.Object
  extended by maspack.util.Write

public class Write
extends java.lang.Object

A set of static methods to help write values to a PrintWriter.


Constructor Summary
Write()
           
 
Method Summary
static java.lang.String getQuotedString(java.lang.String s)
          Converts a String to a double-quoted format.
static void writeColor(java.io.PrintWriter pw, java.awt.Color color)
           
static void writeColor(java.io.PrintWriter pw, java.awt.Color color, boolean newline)
          Writes A Color to a PrintWriter.
static void writeDoubles(java.io.PrintWriter pw, double[] vals, int n, NumberFormat fmt)
          Writes a set of double values, enclosed in square brackets [ ], to a PrintWriter.
static void writeDoubles(java.io.PrintWriter pw, double[] vals, NumberFormat fmt)
          Writes a set of double values, enclosed in square brackets [ ], to a PrintWriter.
static void writeFloats(java.io.PrintWriter pw, float[] vals, int n, NumberFormat fmt)
          Writes a set of float values, enclosed in square brackets [ ], to a PrintWriter.
static void writeFloats(java.io.PrintWriter pw, float[] vals, NumberFormat fmt)
          Writes a set of float values, enclosed in square brackets [ ], to a PrintWriter.
static void writeInts(java.io.PrintWriter pw, int[] vals, int n, NumberFormat fmt)
          Writes a set of integer values, enclosed in square brackets [ ], to a PrintWriter.
static void writeInts(java.io.PrintWriter pw, int[] vals, NumberFormat fmt)
          Writes a set of integer values, enclosed in square brackets [ ], to a PrintWriter.
static void writeLongs(java.io.PrintWriter pw, long[] vals, int n, NumberFormat fmt)
          Writes a set of long integer values, enclosed in square brackets [ ], to a PrintWriter.
static void writeLongs(java.io.PrintWriter pw, long[] vals, NumberFormat fmt)
          Writes a set of long integer values, enclosed in square brackets [ ], to a PrintWriter.
static void writeShorts(java.io.PrintWriter pw, short[] vals, int n, NumberFormat fmt)
          Writes a set of short integer values, enclosed in square brackets [ ], to a PrintWriter.
static void writeShorts(java.io.PrintWriter pw, short[] vals, NumberFormat fmt)
          Writes a set of short integer values, enclosed in square brackets [ ], to a PrintWriter.
static void writeString(java.io.PrintWriter pw, java.lang.String s)
          Writes out a String enclosed in double quotes ", formatted using the routine getQuotedString.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Write

public Write()
Method Detail

writeColor

public static void writeColor(java.io.PrintWriter pw,
                              java.awt.Color color)

writeColor

public static void writeColor(java.io.PrintWriter pw,
                              java.awt.Color color,
                              boolean newline)
Writes A Color to a PrintWriter. The output consists of three floating point numbers, representing the red, green, and blue color values in the range 0 to 1, plus the alpha value if it is not 1, all surrounded by brackets [ ].

Parameters:
pw - PrintWriter to which the output is written
color - color to write
newline - if true, place a newline at the end of the output

writeDoubles

public static void writeDoubles(java.io.PrintWriter pw,
                                double[] vals,
                                int n,
                                NumberFormat fmt)
                         throws java.io.IOException
Writes a set of double values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
n - number of values to write
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeDoubles

public static void writeDoubles(java.io.PrintWriter pw,
                                double[] vals,
                                NumberFormat fmt)
                         throws java.io.IOException
Writes a set of double values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeFloats

public static void writeFloats(java.io.PrintWriter pw,
                               float[] vals,
                               int n,
                               NumberFormat fmt)
                        throws java.io.IOException
Writes a set of float values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
n - number of values to write
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeFloats

public static void writeFloats(java.io.PrintWriter pw,
                               float[] vals,
                               NumberFormat fmt)
                        throws java.io.IOException
Writes a set of float values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeInts

public static void writeInts(java.io.PrintWriter pw,
                             int[] vals,
                             int n,
                             NumberFormat fmt)
                      throws java.io.IOException
Writes a set of integer values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
n - number of values to write
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeInts

public static void writeInts(java.io.PrintWriter pw,
                             int[] vals,
                             NumberFormat fmt)
                      throws java.io.IOException
Writes a set of integer values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeShorts

public static void writeShorts(java.io.PrintWriter pw,
                               short[] vals,
                               int n,
                               NumberFormat fmt)
                        throws java.io.IOException
Writes a set of short integer values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
n - number of values to write
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeShorts

public static void writeShorts(java.io.PrintWriter pw,
                               short[] vals,
                               NumberFormat fmt)
                        throws java.io.IOException
Writes a set of short integer values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeLongs

public static void writeLongs(java.io.PrintWriter pw,
                              long[] vals,
                              int n,
                              NumberFormat fmt)
                       throws java.io.IOException
Writes a set of long integer values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
n - number of values to write
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeLongs

public static void writeLongs(java.io.PrintWriter pw,
                              long[] vals,
                              NumberFormat fmt)
                       throws java.io.IOException
Writes a set of long integer values, enclosed in square brackets [ ], to a PrintWriter.

Parameters:
pw - PrintWriter to which values are written
vals - values to be written
fmt - (optional) numeric formatter for each value
Throws:
java.io.IOException

writeString

public static void writeString(java.io.PrintWriter pw,
                               java.lang.String s)
Writes out a String enclosed in double quotes ", formatted using the routine getQuotedString.

Parameters:
pw - PrintWriter to which string is written
s - String to be written
See Also:
getQuotedString(java.lang.String)

getQuotedString

public static java.lang.String getQuotedString(java.lang.String s)
Converts a String to a double-quoted format. The String itself is enclosed in double quotes ", and double quotes themselves are escaped using backslash \. The characters \b, \t, \n, \f, \r, and \ (corresponding to backspace, tab, linefeed, formfeed, carriage return, and backslash) are written using their canonical escape sequences. Any other character <= 0x1f or >= 0x7f is written by a backslashed octal number.

Parameters:
s - String to be converted to quoted format