|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.OutputStream | +--java.io.FilterOutputStream | +--java.io.PrintStream | +--com.dalsemi.shell.server.SystemPrintStream
A basic implementation of a PrintStream for use as System.out
and System.err
. This class allows its root stream to be set,
and overrides all of its parent's (PrintStream) methods.
This allows special cases to be handled at the expense of some code space.
For instance, a SystemPrintStream
can be set to protect itself
if an IOException
occurs. This is useful, for example,
from a telnet session if you run a Java program in the background.
The program and the session are both using a socket for output to the user.
If the user exits the telnet session, that socket goes away, and the
process would receive a SocketException
on
every write, probably killing the process. If it is set to protect itself,
the SystemPrintStream
will set its internal root stream to
a NullOutputStream
when it detects an IOException
.
Thus, the process can continue to run.
SystemInputStream
,
NullOutputStream
,
Session
Field Summary | |
boolean |
append
If this SystemPrintStream outputs to a file,
this variable determines if the output will be appended
to the file or if it will over-write the file. |
String |
fileOutName
The name of the file this SystemPrintStream is
outputting to, or null if this stream is not redirecting to a file. |
protected Session |
session
The user session that owns this SystemPrintStream . |
boolean |
shieldsUp
Allows the SystemPrintStream to protect itself. |
Fields inherited from class java.io.FilterOutputStream |
out |
Constructor Summary | |
SystemPrintStream(OutputStream root)
Creates a new SystemPrintStream with the specified
underlying root OutputStream . |
|
SystemPrintStream(OutputStream out,
boolean autoFlush)
Creates a new SystemPrintStream with the specified
underlying root OutputStream . |
|
SystemPrintStream(OutputStream root,
String fileOutName,
boolean append)
Creates a new SystemPrintStream with the specified
underlying root OutputStream . |
Method Summary | |
OutputStream |
getRootOutputStream()
Returns the underlying root OutputStream of this stream. |
void |
print(boolean b)
Prints the value of the boolean argument. |
void |
print(char c)
Prints the value of the char argument according to the
default encoding scheme. |
void |
print(char[] s)
Prints the char array according to the
default encoding scheme. |
void |
print(double d)
Prints the double precision floating point argument by calling the Double.toString(double) method. |
void |
print(float f)
Prints the floating point argument by calling the Float.toString(float) method. |
void |
print(int i)
Prints the int argument by calling the
Integer.toString(int) method. |
void |
print(long l)
Prints the long argument by calling the
Long.toString(long) method. |
void |
print(Object obj)
Prints a String representation of
the argument Object by invoking its
toString() method, or prints the
String "null" if the argument is
null . |
void |
print(String s)
Prints the String argument to the
underlying root stream, or the String
"null" if the argument is null . |
void |
println()
Writes the end of line sequence CRLF to the underlying OutputStream . |
void |
println(boolean x)
Prints the value of the boolean argument, followed
by the end of line sequence. |
void |
println(char x)
Prints the value of the char argument according to the
default encoding scheme, followed by the end of line sequence. |
void |
println(char[] x)
Prints the character array according to the default encoding scheme, followed by the end of line sequence. |
void |
println(double x)
Prints the double precision floating point argument by calling the Double.toString(double) method, followed by
the end of line sequence. |
void |
println(float x)
Prints the floating point argument by calling the Float.toString(float) method, followed
by the end of line sequence. |
void |
println(int x)
Prints the int argument by calling the
Integer.toString(int) method,
followed by the end of line sequence. |
void |
println(long x)
Prints the long argument by calling the
Long.toString(long) method,
followed by the end of line sequence. |
void |
println(Object x)
Prints a String representation of
the argument Object by invoking its
toString() method, or prints the
String "null" if the argument is
null , followed by the end of
line sequence. |
void |
println(String x)
Prints the String argument to the
underlying root stream, or the String
"null" if the argument is null ,
followed by the end of line sequence. |
void |
setRootStream(OutputStream root)
Sets the underlying root output stream of this stream. |
void |
setSession(Session s)
Informs this stream of its owning session. |
void |
write(byte[] buf,
int off,
int len)
Writes a portion of a byte array to the underlying
OutputStream . |
void |
write(int b)
Writes the byte to the underlying OutputStream . |
Methods inherited from class java.io.PrintStream |
checkError,
close,
flush,
setError |
Methods inherited from class java.io.FilterOutputStream |
write |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected Session session
SystemPrintStream
.
This could be a session on the serial port, through a telnet or
FTP connection, or through any other user created Session
.public String fileOutName
SystemPrintStream
is
outputting to, or null if this stream is not redirecting to a file.public boolean append
SystemPrintStream
outputs to a file,
this variable determines if the output will be appended
to the file or if it will over-write the file.public boolean shieldsUp
SystemPrintStream
to protect itself. When a process
is run in the background and not redirected to a file, then its OutputStream
is in danger of causing problems if the underlying Session
is
terminated. If the Session
ends and the shieldsUp
variable is true, this SystemPrintStream
's internal root
stream must be reassigned to a NullOutputStream
.Constructor Detail |
public SystemPrintStream(OutputStream root)
SystemPrintStream
with the specified
underlying root OutputStream
.root
- the internal root OutputStream
for this SystemPrintStream
public SystemPrintStream(OutputStream out, boolean autoFlush)
SystemPrintStream
with the specified
underlying root OutputStream
.root
- the internal root OutputStream
for this SystemPrintStream
autoFlush
- set to true if the SystemPrintStream
should flush the internal root stream on every write callpublic SystemPrintStream(OutputStream root, String fileOutName, boolean append)
SystemPrintStream
with the specified
underlying root OutputStream
. In this case, the
underlying root stream should be for a file.root
- the internal root OutputStream
for this SystemPrintStream
fileOutName
- name of the file this SystemPrintStream
is directing its output towardsappend
- true if this SystemPrintStream
should
append to the file, false if it should over-write the fileMethod Detail |
public void setRootStream(OutputStream root)
root
- the new underlying stream to usegetRootOutputStream()
public OutputStream getRootOutputStream()
OutputStream
of this stream.setRootStream(java.io.OutputStream)
public void setSession(Session s)
session
- the owning sessionpublic void write(int b)
OutputStream
.b
- value to be writtenpublic void write(byte[] buf, int off, int len)
byte
array to the underlying
OutputStream
.buf
- a byte
arrayoff
- offset in the byte
array to begin writing bytes fromlen
- number of bytes to writepublic void print(boolean b)
boolean
argument. If the argument
is true
, the String
"true" is printed. If the
argument is false
, the String
"false" is printed.b
- the boolean
value to printprintln(boolean)
public void print(char c)
char
argument according to the
default encoding scheme.c
- the char
to be printedprintln(char)
public void print(int i)
int
argument by calling the
Integer.toString(int)
method.i
- the int
to be printedprintln(int)
public void print(long l)
long
argument by calling the
Long.toString(long)
method.l
- the long
to be printedprintln(long)
public void print(float f)
Float.toString(float)
method.f
- the float
to be printedprintln(float)
public void print(double d)
Double.toString(double)
method.d
- the double
to be printedprintln(double)
public void print(char[] s)
char
array according to the
default encoding scheme.s
- the char
array to be printedprintln(char[])
public void print(String s)
String
argument to the
underlying root stream, or the String
"null" if the argument is null
.s
- the String
to printprintln(java.lang.String)
public void print(Object obj)
String
representation of
the argument Object
by invoking its
toString()
method, or prints the
String
"null" if the argument is
null
.obj
- the Object
to printprintln(java.lang.Object)
public void println()
OutputStream
.public void println(boolean x)
boolean
argument, followed
by the end of line sequence. If the argument
is true
, the String
"true" is printed. If the
argument is false
, the String
"false" is printed.x
- the boolean
value to printprint(boolean)
public void println(char x)
char
argument according to the
default encoding scheme, followed by the end of line sequence.x
- the char
to be printedprint(char)
public void println(int x)
int
argument by calling the
Integer.toString(int)
method,
followed by the end of line sequence.x
- the int
to be printedprint(int)
public void println(long x)
long
argument by calling the
Long.toString(long)
method,
followed by the end of line sequence.x
- the long
to be printedprint(long)
public void println(float x)
Float.toString(float)
method, followed
by the end of line sequence.x
- the float
to be printedprint(float)
public void println(double x)
Double.toString(double)
method, followed by
the end of line sequence.x
- the double
to be printedprint(double)
public void println(char[] x)
x
- the char
array to be printedprint(char[])
public void println(String x)
String
argument to the
underlying root stream, or the String
"null" if the argument is null
,
followed by the end of line sequence.x
- the String
to printprint(java.lang.String)
public void println(Object x)
String
representation of
the argument Object
by invoking its
toString()
method, or prints the
String
"null" if the argument is
null
, followed by the end of
line sequence.x
- the Object
to printprint(java.lang.Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |