All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.vsj.PortableOutputStream

java.lang.Object
   |
   +----com.roguewave.vsj.PortableOutputStream

public class PortableOutputStream
extends Object
implements VirtualOutputStream
The PortableOutputStream class corresponds to the Tools.h++ class RWpostream. The class contains methods to output basic data and save objects to an underlying output stream. These items can later restored from either a C++ program using an implementation of the Tools.h++ class RWpistream or a Java program using class PortableInputStream.

Data written from PortableOutputStream is stored in a human-readable format which is portable among machines of different architectures.

Each method that writes data is meant to be used in conjuction with a specific RWpistream (C++) or PortableInputStream (Java) method to read the data. These correspondences are given in the method descriptions below.

With regard to naming conventions, you'll note that C++ methods in RWpostream that overload the insertion operator are provided here as methods with names beginning with insert. For example,

   RWvostream& RWvostream::operator<<(char);
 
is represented here as
   VirtualOutputStream PortableOutputStream.insertChar(char);
 
We use widening, where we can, to deal with C++ basic types such as unsigned int that don't have Java counterparts. For example, the method
   VirtualOutputStream PortableOutputStream.insertUnsignedInt(long)
 
takes a long since the range of a typical C++ unsigned int contains values that won't necessarily fit into a Java int. While we've done our best to ensure that the types we use can hold any value expected by a C++ program, in the end we cannot guarantee this since ranges of basic types in C++ are implementation defined.

See Also:
PortableInputStream

Variable Index

 o column_
Keep track of the column to enhance human readability of output
 o ps_
The underlying output stream
 o saveContext_
The store table maintained by this stream.

Constructor Index

 o PortableOutputStream(OutputStream)
Create a PortableOutputStream from the given OutputStream.
 o PortableOutputStream(OutputStream, SaveContext)
Create a RWpistream from the given InputStream.

Method Index

 o flush()
flush the underlying stream
 o getSaveContext()
Return the save context maintained by this stream.
 o insertChar(char)
Write a character.
 o insertDouble(double)
Write a double.
 o insertFloat(float)
Write a float.
 o insertInt(int)
Write an int.
 o insertLong(long)
Write a long.
 o insertShort(short)
Write a short.
 o insertUnsignedChar(char)
Write an unsigned character.
 o insertUnsignedInt(long)
Write an unsigned int.
 o insertUnsignedLong(long)
Write an unsigned long.
 o insertUnsignedShort(int)
Write an unsigned short.
 o insertWChar(char)
Write a wide character.
 o putCChar(char)
 o putChar(char)
Write a character.
 o putChars(char[], int)
Write an array of characters.
 o putDoubles(double[], int)
Write an array of doubles.
 o putFloats(float[], int)
Write an array of floats.
 o putInts(int[], int)
Write an array of ints.
 o putLongs(long[], int)
Write an array of longs.
 o putShorts(short[], int)
Write an array of shorts.
 o putString(String, int)
Write a string.
 o putUnsigned(char)
Write an unsigned character.
 o putUnsignedChar(char)
Write an unsigned character.
 o putUnsignedChars(char[], int)
Write an array of unsigned characters.
 o putUnsignedInts(long[], int)
Write an array of unsigned ints.
 o putUnsignedLongs(long[], int)
Write an array of unsigned longs.
 o putUnsignedShorts(int[], int)
Write an array of unsigned shorts.
 o putWChar(char)
Write a wide character.
 o putWChars(char[], int)
Write an array of wide characters.
 o putwrap(char)
Print a character, checking the column and moving to the next line if necessary
 o putwrap(String, int)
Print a string of characters, checking the column and moving to the next line if necessary
 o saveObject(Object, ObjectStreamer)
Write an object to the stream using the given ObjectStreamer.

Variables

 o column_
 protected int column_
Keep track of the column to enhance human readability of output

 o ps_
 protected PrintWriter ps_
The underlying output stream

 o saveContext_
 protected SaveContext saveContext_
The store table maintained by this stream. The store table keeps track of objects as they are written so that back-references can be used to maintain the shape of a graph of objects.

Constructors

 o PortableOutputStream
 public PortableOutputStream(OutputStream ostr)
Create a PortableOutputStream from the given OutputStream. This constructor will initialize the store table with the default SaveContext with the concrete StoreTable implementation from this package.

See Also:
StoreTable
 o PortableOutputStream
 public PortableOutputStream(OutputStream ostr,
                             SaveContext storetable)
Create a RWpistream from the given InputStream. Initialize the stream's SaveContext with storetable.

See Also:
StoreTable

Methods

 o saveObject
 public VirtualOutputStream saveObject(Object data,
                                       ObjectStreamer streamer) throws IOException
Write an object to the stream using the given ObjectStreamer. The ObjectStreamer may call this method recursively in order to save a graph of objects. The object may later be restored from either a C++ or a Java program. The basic types which make up the serialized object must be read with a corresponding C++ RWpistream or a Java PortableInputStream. It is up to the ObjectStreamer to understand how to arrange those basic types, possibly coupled with additional meta-information, to represent the object being written.

Note that ObjectStreamers for certain classes in Tools.h++, JTools, and the JDK are supplied with this product. See the User's Guide.

 o getSaveContext
 public SaveContext getSaveContext()
Return the save context maintained by this stream. The save context keeps track of objects as they are written so that back-references can be used to maintain the shape of a graph of objects.

 o putString
 public VirtualOutputStream putString(String data,
                                      int count) throws IOException
Write a string. Writes at most count characters, stopping at the end of the string if the string length is less than count.

Corresponding input functions:
From C++From Java
RWpistream::getString(const char*, size_t) PortableInputStream.getString(int)

 o putChar
 public VirtualOutputStream putChar(char data) throws IOException
Write a character. The C++ virtual stream interface allows for two different ways of interpreting a char: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertChar and putChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::get(char) PortableInputStream.getChar()

See Also:
insertChar
 o putUnsignedChar
 public VirtualOutputStream putUnsignedChar(char data) throws IOException
Write an unsigned character. The C++ virtual stream interface allows for two different ways of interpreting an unsigned char: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertUnsignedChar and putUnsignedChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::get(unsigned char&) PortableInputStream.getUnsignedChar()

See Also:
insertUnsignedChar
 o insertChar
 public VirtualOutputStream insertChar(char data) throws IOException
Write a character. The C++ virtual stream interface allows for two different ways of interpreting a char: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertChar and putChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(char&) PortableInputStream.extractChar()

See Also:
putChar
 o putWChar
 public VirtualOutputStream putWChar(char data) throws IOException
Write a wide character. The C++ virtual stream interface allows for two different ways of interpreting a wchar_t: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertWChar and putWChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::get(wchar_t&) PortableInputStream.getWChar()

See Also:
insertWChar
 o insertWChar
 public VirtualOutputStream insertWChar(char data) throws IOException
Write a wide character. The C++ virtual stream interface allows for two different ways of interpreting a wchar_t: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertWChar and putWChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(wchar_t&) PortableInputStream.extractWChar()

See Also:
putWChar
 o putUnsigned
 public VirtualOutputStream putUnsigned(char data) throws IOException
Write an unsigned character. The C++ virtual stream interface allows for two different ways of interpreting an unsigned char: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertUnsignedChar and putUnsignedChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::get(unsigned char&) PortableInputStream.getUnsignedChar()

See Also:
insertUnsignedChar
 o insertUnsignedChar
 public VirtualOutputStream insertUnsignedChar(char data) throws IOException
Write an unsigned character. The C++ virtual stream interface allows for two different ways of interpreting an unsigned char: as a character, or as a number. Although this distinction doesn't really apply to Java, it is still important to choose the correct method between insertUnsignedChar and putUnsignedChar depending on the method to be used to input the character.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(unsigned char&) PortableInputStream.extractUnsignedChar()

See Also:
putUnsignedChar
 o insertDouble
 public VirtualOutputStream insertDouble(double data) throws IOException
Write a double.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(double&) PortableInputStream.extractDouble()

 o insertFloat
 public VirtualOutputStream insertFloat(float data) throws IOException
Write a float.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(float&) PortableInputStream.extractFloat()

 o insertInt
 public VirtualOutputStream insertInt(int data) throws IOException
Write an int.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(int&) PortableInputStream.extractInt()

 o insertUnsignedInt
 public VirtualOutputStream insertUnsignedInt(long data) throws IOException
Write an unsigned int.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(unsigned int&) PortableInputStream.extractUnsignedInt()

 o insertShort
 public VirtualOutputStream insertShort(short data) throws IOException
Write a short.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(short&) PortableInputStream.extractShort()

 o insertUnsignedShort
 public VirtualOutputStream insertUnsignedShort(int data) throws IOException
Write an unsigned short.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(unsigned short&) PortableInputStream.extractUnsignedShort()

 o insertLong
 public VirtualOutputStream insertLong(long data) throws IOException
Write a long.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(long&) PortableInputStream.extractLong()

 o insertUnsignedLong
 public VirtualOutputStream insertUnsignedLong(long data) throws IOException
Write an unsigned long.

Corresponding input functions:
From C++From Java
RWpistream::operator>>(unsigned long&) PortableInputStream.extractUnsignedLong()

 o putChars
 public VirtualOutputStream putChars(char data[],
                                     int count) throws IOException
Write an array of characters.

Corresponding input functions:
From C++From Java
RWpistream::get(char*, size_t) PortableInputStream.getChars(int)

 o putWChars
 public VirtualOutputStream putWChars(char data[],
                                      int count) throws IOException
Write an array of wide characters.

Corresponding input functions:
From C++From Java
RWpistream::get(wchar_t*, size_t) PortableInputStream.getWChars(int)

 o putUnsignedChars
 public VirtualOutputStream putUnsignedChars(char data[],
                                             int count) throws IOException
Write an array of unsigned characters.

Corresponding input functions:
From C++From Java
RWpistream::get(unsigned char*, size_t) PortableInputStream.getUnsignedChars(int)

 o putDoubles
 public VirtualOutputStream putDoubles(double data[],
                                       int count) throws IOException
Write an array of doubles.

Corresponding input functions:
From C++From Java
RWpistream::get(double*, size_t) PortableInputStream.getDoubles(int)

 o putFloats
 public VirtualOutputStream putFloats(float data[],
                                      int count) throws IOException
Write an array of floats.

Corresponding input functions:
From C++From Java
RWpistream::get(float*, size_t) PortableInputStream.getFloats(int)

 o putInts
 public VirtualOutputStream putInts(int data[],
                                    int count) throws IOException
Write an array of ints.

Corresponding input functions:
From C++From Java
RWpistream::get(int*, size_t) PortableInputStream.getInts(int)

 o putUnsignedInts
 public VirtualOutputStream putUnsignedInts(long data[],
                                            int count) throws IOException
Write an array of unsigned ints.

Corresponding input functions:
From C++From Java
RWpistream::get(unsigned int*, size_t) PortableInputStream.getunsignedInt(int)

 o putShorts
 public VirtualOutputStream putShorts(short data[],
                                      int count) throws IOException
Write an array of shorts.

Corresponding input functions:
From C++From Java
RWpistream::get(short*, size_t) PortableInputStream.getShorts(int)

 o putUnsignedShorts
 public VirtualOutputStream putUnsignedShorts(int data[],
                                              int count) throws IOException
Write an array of unsigned shorts.

Corresponding input functions:
From C++From Java
RWpistream::get(unsigned short*, size_t) PortableInputStream.getUnsignedShorts(int)

 o putLongs
 public VirtualOutputStream putLongs(long data[],
                                     int count) throws IOException
Write an array of longs.

Corresponding input functions:
From C++From Java
RWpistream::get(long*, size_t) PortableInputStream.getLong(int)

 o putUnsignedLongs
 public VirtualOutputStream putUnsignedLongs(long data[],
                                             int count) throws IOException
Write an array of unsigned longs.

Corresponding input functions:
From C++From Java
RWpistream::get(unsigned long*, size_t) PortableInputStream.getUnsignedLong(int)

 o flush
 public VirtualOutputStream flush() throws IOException
flush the underlying stream

 o putCChar
 protected void putCChar(char c)
 o putwrap
 protected void putwrap(char c)
Print a character, checking the column and moving to the next line if necessary

 o putwrap
 protected void putwrap(String s,
                        int len)
Print a string of characters, checking the column and moving to the next line if necessary


All Packages  Class Hierarchy  This Package  Previous  Next  Index