Package com.sun.grid.util.expect
Class ExpectBuffer
- java.lang.Object
-
- com.sun.grid.util.expect.ExpectBuffer
-
public class ExpectBuffer extends java.lang.ObjectAnExpectBufferholds the content of stdout and sterr of a process.ExpectHandlers can use theconsume...method to consome content. TheExpectobject uses theappendmethods to add new content to the buffer.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNL
-
Constructor Summary
Constructors Constructor Description ExpectBuffer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(char[] s, int offset, int len)Add new content to the buffervoidappend(java.lang.String s)Add new content to the bufferjava.lang.Stringconsume(java.lang.String s)Search the first occurancy ofsis the buffer and consume it (sis also consumed).java.lang.StringconsumeLine()The consume the content of the buffer until the next linefeed.java.lang.StringconsumeLine(java.lang.String prefix)Search a line which contains withprefixand consume it.intlength()get the length of the buffer
-
-
-
Method Detail
-
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
public void append(java.lang.String s)
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
public java.lang.String consume(java.lang.String s)
Search the first occurancy ofsis the buffer and consume it (sis 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
public java.lang.String consumeLine(java.lang.String prefix)
Search a line which contains withprefixand 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
public java.lang.String consumeLine()
The consume the content of the buffer until the next linefeed.- Returns:
- the consumed string
-
-