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 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 Token getLast() { return next != null ? next.getLast() : this; }
public static Token parse(CharSequence s) { return parse(s, 0); }
public PipeLineFactory createFactory() throws CommandException { if (next != null) { PipeLineFactory nextFactory = next.createFactory(); if (nextFactory != null) { return new PipeLineFactory(value, nextFactory); } else { throw new CommandException(ErrorKind.SYNTAX, ""); } } else { return Utils.notBlank(value) ? new PipeLineFactory(value, null) : null; } }
private TestTokenizer(CharSequence s) throws NullPointerException { current = Token.parse(s); }
public PipeLineFactory createFactory() throws CommandException { if (next != null) { PipeLineFactory nextFactory = next.createFactory(); if (nextFactory != null) { return new PipeLineFactory(value, nextFactory); } else { throw new CommandException(ErrorKind.SYNTAX, ""); } } else { return Utils.notBlank(value) ? new PipeLineFactory(value, null) : null; } }
public void testBlank() throws CommandException { assertNull(Token.parse("").createFactory()); assertNull(Token.parse(" ").createFactory()); }
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(CharSequence s) { return parse(s, 0); }
public PipeLineFactory createFactory() throws CommandException { if (next != null) { PipeLineFactory nextFactory = next.createFactory(); if (nextFactory != null) { return new PipeLineFactory(value, nextFactory); } else { throw new CommandException(ErrorKind.SYNTAX, ""); } } else { return Utils.notBlank(value) ? new PipeLineFactory(value, null) : null; } }
public Token getLast() { return next != null ? next.getLast() : this; }
private void assertSyntaxException(String s) { try { Token.parse(s).createFactory(); fail(); } catch (CommandException e) { assertEquals(ErrorKind.SYNTAX, e.getErrorKind()); } } }
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(CharSequence s) { return parse(s, 0); }
public Token getLast() { return next != null ? next.getLast() : this; }
public void testCommand() throws CommandException { PipeLineFactory e = Token.parse("a").createFactory(); assertEquals("a", e.getLine()); assertNull(e.getNext()); }