Package com.sun.grid.util.expect
Class ExpectBuffer
java.lang.Object
com.sun.grid.util.expect.ExpectBuffer
An
ExpectBuffer
holds the content of stdout and sterr of
a process. ExpectHandler
s can use the consume...
method to consome content.
The Expect
object uses the append
methods to add
new content to the buffer.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(char[] s, int offset, int len) Add new content to the buffervoid
Add new content to the bufferSearch the first occurancy ofs
is the buffer and consume it (s
is also consumed).The consume the content of the buffer until the next linefeed.consumeLine
(String prefix) Search a line which contains withprefix
and consume it.int
length()
get the length of the buffer
-
Field Details
-
NL
-
-
Constructor Details
-
ExpectBuffer
public ExpectBuffer()
-
-
Method Details
-
append
public void append(char[] s, int offset, int len) Add new content to the buffer- Parameters:
s
- char array with the contentoffset
- offset in the char arraylen
- len of the the content
-
append
Add new content to the buffer- Parameters:
s
- a string with the content
-
length
public int length()get the length of the buffer- Returns:
- length of the buffer
-
consume
Search the first occurancy ofs
is the buffer and consume it (s
is also consumed). If the content of the buffer is "1234" a consume("2") will remove "12".- Parameters:
s
- the search string- Returns:
- the consumed string ("12")
-
consumeLine
Search a line which contains withprefix
and consume it. If the content of a buffer is "1\\n123\\m" a consumeLine("2") will consume "1\\n122\\n".- Parameters:
prefix
- the prefix- Returns:
- the consumed string
-
consumeLine
The consume the content of the buffer until the next linefeed.- Returns:
- the consumed string
-