com.novell.java.io
Class NOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.novell.java.io.NOutputStream

public class NOutputStream
extends java.io.OutputStream

Provides output stream functionality to various data device objects, which implements the DataAccessable interface.

The various constructors open an output stream on (or with) the DataAccessable object passed into the constructors. The DataAccessable object might have container capabilities and support subordinate streams, or it may only support a stream to itself. The constructors with a name parameter (which must be atomic) attempt to open a subordinate stream through the given DataAccessable object. The constructors without a name parameter attempt to open a stream on the given DataAcessable object.

There is also a set of constructors that support provider based custom parameters. A given implementation of a DataAccessable object might require custom parameters to open the stream. For example, a file system provider might require open flags, fork selectors, name space information, size, and so forth, to open the stream. The custom Object parameter allows for passing known provider-supplied objects to their DataAccessable implementations, allowing the user full control over the opening of the stream if needed. The various providers must implement reasonable defaults for any custom parameters if the non-custom constructors are used (open flags == WRITE). See Novell's DataAccessableParameters and NFileOutputStream for an example of how a provider might implement this support.

NoSubordinateAccessException will be thrown if the given DataAccessable object does not support subordinate streams (subordinate constructors). SubordinateAccessOnlyException will be thrown if the given DataAccessable object does not support a stream on itself.

See Also:
DataAccessable, NInputStream, RandomAccess, NFileOutputStream, DataAccessableParameters

Constructor Summary
NOutputStream(DataAccessable accessor)
          Creates an instance of the NOutputStream object.
NOutputStream(DataAccessable accessor, java.lang.Object custom)
          Creates an instance of the NOutputStream object with the custom parameter to the accessor.
NOutputStream(java.lang.String name, DataAccessable accessor)
          Creates a subordinate instance of the NOutputStream.
NOutputStream(java.lang.String name, DataAccessable accessor, java.lang.Object custom)
          Creates a subordinate instance of an NOutputStream with the custom parameter.
 
Method Summary
 void close()
          Closes the stream.
 void flush()
          Makes sure that all output is written.
 void write(byte[] b)
          Writes an array of bytes.
 void write(byte[] b, int off, int len)
          Writes a subset of an array of bytes.
 void write(int b)
          Writes one byte.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NOutputStream

public NOutputStream(DataAccessable accessor)
              throws java.io.IOException
Creates an instance of the NOutputStream object.

Opens an output stream to the DataAccessable accessor parameter.

Parameters:
accessor - The DataAccessable object to use.
Throws:
java.io.IOException - If the stream cannot be opened.
SubordinateAccessOnlyException - If the accessor does not support a stream to itself, for example, a directory.
OutputStreamNotSupportedException - If the accessor does not support an output stream.

NOutputStream

public NOutputStream(DataAccessable accessor,
                     java.lang.Object custom)
              throws java.io.IOException
Creates an instance of the NOutputStream object with the custom parameter to the accessor.

Opens an output stream to the DataAccessable accessor parameter, passing the provider-based custom parameter to the accessor for the open.

Parameters:
accessor - The DataAccessable object to use.
custom - The provider-specific custom object containing any needed parameters to open the stream.
Throws:
SubordinateAccessOnlyException - If the accessor does not support a stream to itself, for example, a directory.
OutputStreamNotSupportedException - If the accessor does not support an output stream.
java.lang.IllegalArgumentException - If the custom object is not of the expected type for the given provider.

NOutputStream

public NOutputStream(java.lang.String name,
                     DataAccessable accessor)
              throws java.io.IOException
Creates a subordinate instance of the NOutputStream.

Opens a subordinate output stream to the DataAccessable accessor parameter.

Parameters:
name - The atomic subordinate stream name to open.
accessor - The DataAccessable object to use.
Throws:
java.io.IOException - If the stream cannot be opened.
NoSubordinateAccessException - If the accessor does not support opening a subordinate stream; for example, a file.
OutputStreamNotSupportedException - If the accessor does not support an output stream.

NOutputStream

public NOutputStream(java.lang.String name,
                     DataAccessable accessor,
                     java.lang.Object custom)
              throws java.io.IOException
Creates a subordinate instance of an NOutputStream with the custom parameter.

Opens a subordinate output stream to the DataAccessable accessor parameter, passing the provider based custom parameter to the accessor for the open.

Parameters:
name - The atomic subordinate stream name to open.
accessor - The DataAccessable object to use.
custom - The Provider specific custom object containing any needed parameters to open the stream.
Throws:
java.io.IOException - If the stream cannot be opened.
NoSubordinateAccessException - If the accessor does not support opening a subordinate stream; for example, a file.
OutputStreamNotSupportedException - If the accessor does not support an output stream.
java.lang.IllegalArgumentException - If the custom object is not of the expected type for the given provider.
Method Detail

close

public void close()
           throws java.io.IOException
Closes the stream.
Throws:
java.io.IOException - When an I/O error occurs while closing.
Overrides:
close in class java.io.OutputStream

flush

public void flush()
           throws java.io.IOException
Makes sure that all output is written.
Throws:
java.io.IOException - When an I/O error occurs.
Overrides:
flush in class java.io.OutputStream

write

public void write(int b)
           throws java.io.IOException
Writes one byte.
Parameters:
b - The byte to write.
Throws:
java.io.IOException - When an I/O error occurs.
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] b)
           throws java.io.IOException
Writes an array of bytes.

All bytes in the array are written.

Parameters:
b - The array of bytes to write.
Throws:
java.io.IOException - When an I/O error occurs.
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes a subset of an array of bytes.
Parameters:
b - The array of bytes to write.
off - The offset from which to start writing.
len - The number of bytes to write.
Throws:
java.io.IOException - When an I/O error occurs.
Overrides:
write in class java.io.OutputStream