private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
/** * Returns an instance of the class implementing the given command. The * class must have been registered via * {@link #addClass(Class, String...)} * @param cmd name of the command * @return instance of the requested command */ public Command getInstance(String cmd) { return getInstance(cmd, getConf()); }
private void printInfo(PrintStream out, String cmd, boolean showHelp) { if (cmd != null) { Command instance = commandFactory.getInstance("-" + cmd); if (instance == null) { throw new UnknownCommandException(cmd); Command instance = commandFactory.getInstance(name); if (!instance.isDeprecated()) { out.println("\t[" + instance.getUsage() + "]");
Command instance = null; try { instance = commandFactory.getInstance(cmd); if (instance == null) { throw new UnknownCommandException();
@Override public Command getInstance(String cmd) { Command command = commandFactory.getInstance(cmd); command.err = this.err; command.out = this.out; return command; }
@Override public Command getInstance(String cmdName, Configuration conf) { Command command = commandFactory.getInstance(cmdName, conf); command.err = this.err; command.out = this.out; return command; }
private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
/** * Returns an instance of the class implementing the given command. The * class must have been registered via * {@link #addClass(Class, String...)} * @param cmd name of the command * @return instance of the requested command */ public Command getInstance(String cmd) { return getInstance(cmd, getConf()); }
/** * Returns an instance of the class implementing the given command. The * class must have been registered via * {@link #addClass(Class, String...)} * @param cmd name of the command * @return instance of the requested command */ public Command getInstance(String cmd) { return getInstance(cmd, getConf()); }
/** * Returns an instance of the class implementing the given command. The * class must have been registered via * {@link #addClass(Class, String...)} * @param cmd name of the command * @return instance of the requested command */ public Command getInstance(String cmd) { return getInstance(cmd, getConf()); }
/** * Returns an instance of the class implementing the given command. The * class must have been registered via * {@link #addClass(Class, String...)} * @param cmd name of the command * @return instance of the requested command */ public Command getInstance(String cmd) { return getInstance(cmd, getConf()); }
private static Command getCommandInstance(String cmdName, Configuration conf) { final CommandFactory commandFactory = new CommandFactory(conf); FsCommand.registerCommands(commandFactory); return commandFactory.getInstance(cmdName, conf); }
@Override public void initialise(FindOptions options) throws IOException { super.initialise(options); String commandName = getArgument(1); this.command = getOptions().getCommandFactory().getInstance(commandName); if(this.command == null) { throw new IOException("Unknown command: " + commandName); } pathItems = new ArrayList<String>(); }
private void printInfo(PrintStream out, String cmd, boolean showHelp) { if (cmd != null) { Command instance = commandFactory.getInstance("-" + cmd); if (instance == null) { throw new UnknownCommandException(cmd); Command instance = commandFactory.getInstance(name); if (!instance.isDeprecated()) { out.println("\t[" + instance.getUsage() + "]");
Command instance = null; try { instance = commandFactory.getInstance(cmd); if (instance == null) { throw new UnknownCommandException();
@Test public void testGetInstances() { factory.registerCommands(TestRegistrar.class); Command instance; instance = factory.getInstance("blarg"); assertNull(instance); instance = factory.getInstance("tc1"); assertNotNull(instance); assertEquals(TestCommand1.class, instance.getClass()); assertEquals("tc1", instance.getCommandName()); instance = factory.getInstance("tc2"); assertNotNull(instance); assertEquals(TestCommand2.class, instance.getClass()); assertEquals("tc2", instance.getCommandName()); instance = factory.getInstance("tc2.1"); assertNotNull(instance); assertEquals(TestCommand2.class, instance.getClass()); assertEquals("tc2.1", instance.getCommandName()); }
@Test public void testGetInstances() { factory.registerCommands(TestRegistrar.class); Command instance; instance = factory.getInstance("blarg"); assertNull(instance); instance = factory.getInstance("tc1"); assertNotNull(instance); assertEquals(TestCommand1.class, instance.getClass()); assertEquals("tc1", instance.getCommandName()); instance = factory.getInstance("tc2"); assertNotNull(instance); assertEquals(TestCommand2.class, instance.getClass()); assertEquals("tc2", instance.getCommandName()); instance = factory.getInstance("tc2.1"); assertNotNull(instance); assertEquals(TestCommand2.class, instance.getClass()); assertEquals("tc2.1", instance.getCommandName()); }