Methods Summary |
---|
public void | close()
synchronized(lock) {
if (in != null) {
in.close();
in = null;
}
}
|
private void | ensureOpen()
if (in == null)
throw new IOException("Stream closed");
|
public java.util.List | parseCommandLine(java.lang.String commandLine)
StringBuffer current = new StringBuffer();
Vector args = new Vector();
boolean allowEmpty = false;
boolean bailout = commandLine.length() == 0;
int index = 0;
int state = ENTER;
while (!bailout) {
int ch = commandLine.charAt(index++);
bailout = (index == commandLine.length());
char c = (char) ch;
// if (c!='\n'){
//
// line.append( c );
// }
//
switch (state) {
/*case SKIP:
switch (c) {
case ' ': case '\t':
break;
case '\"':
mode = QUOTE;
break;
case '&':
background = true;
case ';':
contLine = line.substring(pos +1);
pos = line.length();
break;
default:
mode = READ;
--pos;
}
break;*/
case ENTER:
switch (c) {
case '\"":
state = QUOTE;
break;
/*case ' ': case '\t':
mode = SKIP;
break;*/
case '\\":
state = NONQUOTEDESCAPE;
break;
// case '\n':
// bailout = true;
// break;
case '\r":
break;
default:
current.append(c);
}
if ((state == ENTER) && ((c==' ") || (bailout))) {
String arg = current.toString().trim();
if( arg.length() > 0 || allowEmpty )
{
args.addElement(arg);
allowEmpty = false;
}
current = new StringBuffer();
}
break;
case QUOTE:
switch (c) {
case '\"":
allowEmpty = true;
state = ENTER;
break;
case '\\":
state = ESCAPE;
break;
default:
current.append(c);
}
break;
case ESCAPE:
switch (c) {
case 'n": c = '\n"; break;
case 'r": c = '\r"; break;
case 't": c = '\t"; break;
case 'b": c = '\b"; break;
case 'f": c = '\f"; break;
default: current.append('\\"); break;
}
state = QUOTE;
current.append(c);
break;
case NONQUOTEDESCAPE:
switch (c) {
case ';":
state = ENTER;
current.append(c);
break;
default: // This is not a escaped char.
state = ENTER;
current.append('\\");
current.append(c);
break;
}
break;
}
}
if ((state == ENTER) && (current.toString().trim().length() > 0 || allowEmpty) )
{
String arg = current.toString().trim();
args.addElement(arg);
}
return args;
|
public int | read()
synchronized(lock) {
ensureOpen();
return in.read();
}
|
public int | read(char[] cbuf, int off, int len)
synchronized(lock) {
ensureOpen();
return in.read(cbuf, off, len);
}
|
public java.lang.String | readLine()
synchronized(lock) {
ensureOpen();
StringBuffer line = new StringBuffer();
int ch;
while( (char)(ch = in.read()) != '\n" )
{
if( ch == -1 )
{
throw new IOException("stream closed");
}
line.append((char)ch);
}
return line.toString().trim();
}
|