org.extex.engine.backend
Class NamedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.extex.engine.backend.NamedOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class NamedOutputStream
extends java.io.OutputStream

This class provides a delegate to an output stream with an additional name.

Version:
$Revision$
Author:
Gerd Neugebauer

Constructor Summary
NamedOutputStream(java.lang.String name, java.io.OutputStream stream)
          Creates a new object.
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with this stream.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
 java.lang.String getName()
          Getter for the destination.
 int hashCode()
          Returns a hash code value for the object.
 java.lang.String toString()
          Returns a string representation of the object.
 void write(byte[] b)
          Writes b.length bytes from the specified byte array to this output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedOutputStream

public NamedOutputStream(java.lang.String name,
                         java.io.OutputStream stream)
Creates a new object.

Parameters:
name - the name
stream - the stream
Method Detail

close

public void close()
           throws java.io.IOException
Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
OutputStream.close()

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.equals(java.lang.Object)

flush

public void flush()
           throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
OutputStream.flush()

getName

public java.lang.String getName()
Getter for the destination. The destination is some printable representation describing where the output went to.

Returns:
the name of the destination

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object
See Also:
Object.toString()

write

public void write(byte[] b)
           throws java.io.IOException
Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Overrides:
write in class java.io.OutputStream
Parameters:
b - the data.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
OutputStream.write(byte[])

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
See Also:
OutputStream.write(byte[], int, int)

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this output stream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte.
Throws:
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
See Also:
OutputStream.write(int)