public static Token parse(CharSequence s) { return parse(s, 0); }
private TestTokenizer(CharSequence s) throws NullPointerException { current = Token.parse(s); }
public static Token parse(final CharSequence s, final int index) { Character lastQuote = null; int pos = index; while (pos < s.length()) { char c = s.charAt(pos); if (lastQuote == null) { if (c == '|') { break; } else if (c == '"' || c == '\'') { lastQuote = c; } } else { if (lastQuote == c) { lastQuote = null; } } pos++; } Token next = pos < s.length() ? parse(s, pos + 1) : null; return new Token(s.subSequence(index, pos).toString(), next); } }
public CommandInvoker<?, ?> resolve(String s) throws CommandException { CRaSHSession session = (CRaSHSession)getSession(); Token token2 = Token.parse(s); try { PipeLineFactory factory = token2.createFactory(); return factory.create(session); } catch (CommandNotFoundException e) { throw new CommandException(ErrorKind.SYNTAX, e.getMessage(), e); } }
public CompletionMatch complete(ShellSession session, String prefix) { Token ast = Token.parse(prefix); String termPrefix; if (ast != null) {
private void assertSyntaxException(String s) { try { Token.parse(s).createFactory(); fail(); } catch (CommandException e) { assertEquals(ErrorKind.SYNTAX, e.getErrorKind()); } } }
public static Token parse(CharSequence s) { return parse(s, 0); }
public static Token parse(CharSequence s) { return parse(s, 0); }
public void testCommand() throws CommandException { PipeLineFactory e = Token.parse("a").createFactory(); assertEquals("a", e.getLine()); assertNull(e.getNext()); }
public ReplResponse eval(ShellSession session, String request) { PipeLineFactory factory; try { factory = Token.parse(request).createFactory(); } catch (CommandException e) { return new ReplResponse.Response(ShellResponse.error(e.getErrorKind(), e.getMessage(), e.getCause())); } if (factory != null) { try { CommandInvoker<Void, Object> invoker = factory.create(session); return new ReplResponse.Invoke(invoker); } catch (CommandNotFoundException e) { log.log(Level.FINER, "Could not create command", e); return new ReplResponse.Response(ShellResponse.unknownCommand(e.getName())); } catch (CommandException e) { log.log(Level.FINER, "Could not create command", e); return new ReplResponse.Response(ShellResponse.error(e.getErrorKind(), e.getMessage(), e)); } } else { return new ReplResponse.Response(ShellResponse.noCommand()); } }
public void testPipe() throws CommandException { PipeLineFactory e = Token.parse("a|b").createFactory(); assertEquals("a", e.getLine()); assertEquals("b", e.getNext().getLine()); assertNull(e.getNext().getNext()); }
public static Token parse(final CharSequence s, final int index) { Character lastQuote = null; int pos = index; while (pos < s.length()) { char c = s.charAt(pos); if (lastQuote == null) { if (c == '|') { break; } else if (c == '"' || c == '\'') { lastQuote = c; } } else { if (lastQuote == c) { lastQuote = null; } } pos++; } Token next = pos < s.length() ? parse(s, pos + 1) : null; return new Token(s.subSequence(index, pos).toString(), next); } }
public static Token parse(final CharSequence s, final int index) { Character lastQuote = null; int pos = index; while (pos < s.length()) { char c = s.charAt(pos); if (lastQuote == null) { if (c == '|') { break; } else if (c == '"' || c == '\'') { lastQuote = c; } } else { if (lastQuote == c) { lastQuote = null; } } pos++; } Token next = pos < s.length() ? parse(s, pos + 1) : null; return new Token(s.subSequence(index, pos).toString(), next); } }
public CommandInvoker<?, ?> resolve(String s) throws CommandException { CRaSHSession session = (CRaSHSession)getSession(); Token token2 = Token.parse(s); try { PipeLineFactory factory = token2.createFactory(); return factory.create(session); } catch (CommandNotFoundException e) { throw new CommandException(ErrorKind.SYNTAX, e.getMessage(), e); } }
public CommandInvoker<?, ?> resolve(String s) throws CommandException { CRaSHSession session = (CRaSHSession)getSession(); Token token2 = Token.parse(s); try { PipeLineFactory factory = token2.createFactory(); return factory.create(session); } catch (CommandNotFoundException e) { throw new CommandException(ErrorKind.SYNTAX, e.getMessage(), e); } }
public CompletionMatch complete(ShellSession session, String prefix) { Token ast = Token.parse(prefix); String termPrefix; if (ast != null) {
public CompletionMatch complete(ShellSession session, String prefix) { Token ast = Token.parse(prefix); String termPrefix; if (ast != null) {
public ReplResponse eval(ShellSession session, String request) { PipeLineFactory factory; try { factory = Token.parse(request).createFactory(); } catch (CommandException e) { return new ReplResponse.Response(ShellResponse.error(e.getErrorKind(), e.getMessage(), e.getCause())); } if (factory != null) { try { CommandInvoker<Void, Object> invoker = factory.create(session); return new ReplResponse.Invoke(invoker); } catch (CommandNotFoundException e) { log.log(Level.FINER, "Could not create command", e); return new ReplResponse.Response(ShellResponse.unknownCommand(e.getName())); } catch (CommandException e) { log.log(Level.FINER, "Could not create command", e); return new ReplResponse.Response(ShellResponse.error(e.getErrorKind(), e.getMessage(), e)); } } else { return new ReplResponse.Response(ShellResponse.noCommand()); } }
public ReplResponse eval(ShellSession session, String request) { PipeLineFactory factory; try { factory = Token.parse(request).createFactory(); } catch (CommandException e) { return new ReplResponse.Response(ShellResponse.error(e.getErrorKind(), e.getMessage(), e.getCause())); } if (factory != null) { try { CommandInvoker<Void, Object> invoker = factory.create(session); return new ReplResponse.Invoke(invoker); } catch (CommandNotFoundException e) { log.log(Level.FINER, "Could not create command", e); return new ReplResponse.Response(ShellResponse.unknownCommand(e.getName())); } catch (CommandException e) { log.log(Level.FINER, "Could not create command", e); return new ReplResponse.Response(ShellResponse.error(e.getErrorKind(), e.getMessage(), e)); } } else { return new ReplResponse.Response(ShellResponse.noCommand()); } }