@Test public void type() throws IllegalArgumentException { CommandFactory factory = runner.getCommandFactory(); factory.newCommand(1, "type", "aaa", ""); }
@Override public ICommand newCommand(int index, String name, String... args) { if (name == null || name.isEmpty()) name = "nop"; else if (name.startsWith(" return new Echo(index, name, args); for (ICommandFactory factory : commandFactories) { ICommand command = factory.newCommand(index, name, args); if (command != null) return command; } boolean andWait = name.endsWith(AND_WAIT); String realName = andWait ? name.substring(0, name.length() - AND_WAIT.length()) : name; Constructor<? extends ICommand> constructor = constructorMap.get(realName); if (constructor != null) { try { return constructor.newInstance(index, name, args); } catch (Exception e) { throw new SeleneseRunnerRuntimeException(e); } } SubCommandMap subCommandMap = subCommandMapProvider.getSubCommandMap(); ISubCommand<?> subCommand = subCommandMap.get(realName); if (subCommand != null) return new BuiltInCommand(index, name, args, subCommand, andWait); Matcher matcher = COMMAND_PATTERN.matcher(name); if (!matcher.matches()) throw new SeleneseRunnerRuntimeException("No such command: " + name); String assertion = matcher.group(ASSERTION); String target = matcher.group(TARGET1); if (target == null) target = "Expression"; String target2 = matcher.group(TARGET2); if (target2 != null) target += target2; boolean isBoolean = false; String getter = "get" + target; ISubCommand<?> getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) { getter = "is" + target; getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) throw new SeleneseRunnerRuntimeException("No such command: " + name); isBoolean = true; } if (assertion != null) { boolean isInverse = matcher.group(NOT1) != null || matcher.group(NOT2) != null; return new Assertion(index, name, args, assertion, getterSubCommand, isBoolean, isInverse); } else { return new Store(index, name, args, getterSubCommand); } }
CommandFactory implements ICommandFactory { @Override public ICommand newCommand(int index, String name, String... args) { if (name == null || name.isEmpty()) name = "nop"; else if (name.startsWith(" return new Echo(index, name, args); for (ICommandFactory factory : commandFactories) { ICommand command = factory.newCommand(index, name, args); if (command != null) return command; } boolean andWait = name.endsWith(AND_WAIT); String realName = andWait ? name.substring(0, name.length() - AND_WAIT.length()) : name; Constructor<? extends ICommand> constructor = constructorMap.get(realName); if (constructor != null) { try { return constructor.newInstance(index, name, args); } catch (Exception e) { throw new SeleneseRunnerRuntimeException(e); } } SubCommandMap subCommandMap = subCommandMapProvider.getSubCommandMap(); ISubCommand<?> subCommand = subCommandMap.get(realName); if (subCommand != null) return new BuiltInCommand(index, name, args, subCommand, andWait); Matcher matcher = COMMAND_PATTERN.matcher(name); if (!matcher.matches()) throw new SeleneseRunnerRuntimeException("No such command: " + name); String assertion = matcher.group(ASSERTION); String target = matcher.group(TARGET1); if (target == null) target = "Expression"; String target2 = matcher.group(TARGET2); if (target2 != null) target += target2; boolean isBoolean = false; String getter = "get" + target; ISubCommand<?> getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) { getter = "is" + target; getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) throw new SeleneseRunnerRuntimeException("No such command: " + name); isBoolean = true; } if (assertion != null) { boolean isInverse = matcher.group(NOT1) != null || matcher.group(NOT2) != null; return new Assertion(index, name, args, assertion, getterSubCommand, isBoolean, isInverse); } else { return new Store(index, name, args, getterSubCommand); } } }
CommandFactory implements ICommandFactory { @Override public ICommand newCommand(int index, String name, String... args) { if (name == null || name.isEmpty()) name = "nop"; else if (name.startsWith(" return new Echo(index, name, args); for (ICommandFactory factory : commandFactories) { ICommand command = factory.newCommand(index, name, args); if (command != null) return command; } boolean andWait = name.endsWith(AND_WAIT); String realName = andWait ? name.substring(0, name.length() - AND_WAIT.length()) : name; Constructor<? extends ICommand> constructor = constructorMap.get(realName); if (constructor != null) { try { return constructor.newInstance(index, name, args); } catch (Exception e) { throw new SeleneseRunnerRuntimeException(e); } } SubCommandMap subCommandMap = subCommandMapProvider.getSubCommandMap(); ISubCommand<?> subCommand = subCommandMap.get(realName); if (subCommand != null) return new BuiltInCommand(index, name, args, subCommand, andWait); Matcher matcher = COMMAND_PATTERN.matcher(name); if (!matcher.matches()) throw new SeleneseRunnerRuntimeException("No such command: " + name); String assertion = matcher.group(ASSERTION); String target = matcher.group(TARGET1); if (target == null) target = "Expression"; String target2 = matcher.group(TARGET2); if (target2 != null) target += target2; boolean isBoolean = false; String getter = "get" + target; ISubCommand<?> getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) { getter = "is" + target; getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) throw new SeleneseRunnerRuntimeException("No such command: " + name); isBoolean = true; } if (assertion != null) { boolean isInverse = matcher.group(NOT1) != null || matcher.group(NOT2) != null; return new Assertion(index, name, args, assertion, getterSubCommand, isBoolean, isInverse); } else { return new Store(index, name, args, getterSubCommand); } } CommandFactory();  CommandFactory(SubCommandMapProvider subCommandMapProvider); @Deprecated  CommandFactory(Context context); }
CommandFactory implements ICommandFactory { @Override public ICommand newCommand(int index, String name, String... args) { if (name == null || name.isEmpty()) name = "nop"; else if (name.startsWith(" return new Echo(index, name, args); for (ICommandFactory factory : commandFactories) { ICommand command = factory.newCommand(index, name, args); if (command != null) return command; } boolean andWait = name.endsWith(AND_WAIT); String realName = andWait ? name.substring(0, name.length() - AND_WAIT.length()) : name; Constructor<? extends ICommand> constructor = constructorMap.get(realName); if (constructor != null) { try { return constructor.newInstance(index, name, args); } catch (Exception e) { throw new SeleneseRunnerRuntimeException(e); } } SubCommandMap subCommandMap = subCommandMapProvider.getSubCommandMap(); ISubCommand<?> subCommand = subCommandMap.get(realName); if (subCommand != null) return new BuiltInCommand(index, name, args, subCommand, andWait); Matcher matcher = COMMAND_PATTERN.matcher(name); if (!matcher.matches()) throw new SeleneseRunnerRuntimeException("No such command: " + name); String assertion = matcher.group(ASSERTION); String target = matcher.group(TARGET1); if (target == null) target = "Expression"; String target2 = matcher.group(TARGET2); if (target2 != null) target += target2; boolean isBoolean = false; String getter = "get" + target; ISubCommand<?> getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) { getter = "is" + target; getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) throw new SeleneseRunnerRuntimeException("No such command: " + name); isBoolean = true; } if (assertion != null) { boolean isInverse = matcher.group(NOT1) != null || matcher.group(NOT2) != null; return new Assertion(index, name, args, assertion, getterSubCommand, isBoolean, isInverse); } else { return new Store(index, name, args, getterSubCommand); } } CommandFactory();  CommandFactory(SubCommandMapProvider subCommandMapProvider); @Deprecated  CommandFactory(Context context); void registerCommandFactory(ICommandFactory factory); @Override ICommand newCommand(int index, String name, String... args); static Set<Entry<String, Constructor<? extends ICommand>>> getCommandEntries(); }
CommandFactory implements ICommandFactory { @Override public ICommand newCommand(int index, String name, String... args) { if (name == null || name.isEmpty()) name = "nop"; else if (name.startsWith(" return new Echo(index, name, args); for (ICommandFactory factory : commandFactories) { ICommand command = factory.newCommand(index, name, args); if (command != null) return command; } boolean andWait = name.endsWith(AND_WAIT); String realName = andWait ? name.substring(0, name.length() - AND_WAIT.length()) : name; Constructor<? extends ICommand> constructor = constructorMap.get(realName); if (constructor != null) { try { return constructor.newInstance(index, name, args); } catch (Exception e) { throw new SeleneseRunnerRuntimeException(e); } } SubCommandMap subCommandMap = subCommandMapProvider.getSubCommandMap(); ISubCommand<?> subCommand = subCommandMap.get(realName); if (subCommand != null) return new BuiltInCommand(index, name, args, subCommand, andWait); Matcher matcher = COMMAND_PATTERN.matcher(name); if (!matcher.matches()) throw new SeleneseRunnerRuntimeException("No such command: " + name); String assertion = matcher.group(ASSERTION); String target = matcher.group(TARGET1); if (target == null) target = "Expression"; String target2 = matcher.group(TARGET2); if (target2 != null) target += target2; boolean isBoolean = false; String getter = "get" + target; ISubCommand<?> getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) { getter = "is" + target; getterSubCommand = subCommandMap.get(getter); if (getterSubCommand == null) throw new SeleneseRunnerRuntimeException("No such command: " + name); isBoolean = true; } if (assertion != null) { boolean isInverse = matcher.group(NOT1) != null || matcher.group(NOT2) != null; return new Assertion(index, name, args, assertion, getterSubCommand, isBoolean, isInverse); } else { return new Store(index, name, args, getterSubCommand); } } CommandFactory();  CommandFactory(SubCommandMapProvider subCommandMapProvider); @Deprecated  CommandFactory(Context context); void registerCommandFactory(ICommandFactory factory); @Override ICommand newCommand(int index, String name, String... args); static Set<Entry<String, Constructor<? extends ICommand>>> getCommandEntries();  }