|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Device
A general interface for a Output-Device. A Device is the destination, where the HTML-code is written to. This is like the 'Graphics' - device in GUI applications.
All the printing methods return the Device itself, to allow simple chaining:
someDevice.print("foo").print("bar");
Usually, the underlying data sink of a Device would be some OutputStream, as it finally writes through some socket to the client browser. The Device, however, offers basically two methods for writing to the output: with print() and write() like methods. The print() like methods get character input that has to be converted to a byte-stream before it actually can be written to the underlying OutputStream, while the write() like methods directly handle arrays of bytes to do this. So if possible, try to always use the write() methods, if you can pre-calculate the byte-representation of the output (if you have some static Strings, for instance, consider using String.getBytes()).
| Method Summary | |
|---|---|
void |
close()
close the Device. |
void |
flush()
Flush this Device. |
boolean |
isSizePreserving()
returns, whether this the size of data put into this device is the same as comes out. |
Device |
print(char c)
Print a character. |
Device |
print(char[] c)
Print a character array. |
Device |
print(char[] c,
int start,
int len)
Print len characters from the specified char array starting at offset off to this Device. |
Device |
print(int i)
Print an integer. |
Device |
print(Object o)
Print any Object |
Device |
print(String s)
Print a String. |
Device |
write(byte[] b)
Writes b.length bytes from the specified byte array to this output stream. |
Device |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this Device. |
Device |
write(int c)
Writes the specified byte to this data output stream. |
| Method Detail |
|---|
void flush()
throws IOException
IOException
void close()
throws IOException
IOExceptionboolean isSizePreserving()
Device print(char c)
throws IOException
IOException
Device print(char[] c)
throws IOException
IOException
Device print(char[] c,
int start,
int len)
throws IOException
IOException
Device print(String s)
throws IOException
IOException
Device print(int i)
throws IOException
IOException
Device print(Object o)
throws IOException
IOException
Device write(int c)
throws IOException
IOException
Device write(byte[] b)
throws IOException
IOException
Device write(byte[] b,
int off,
int len)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||