Package: StandardCommandSession

StandardCommandSession

nameinstructionbranchcomplexitylinemethod
StandardCommandSession(CommandInvoker)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
execute(CharSequence)
M: 38 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.shell.internal;
13:
14: import java.util.Arrays;
15: import java.util.List;
16:
17: import org.eclipse.virgo.shell.internal.parsing.ParsedCommand;
18: import org.eclipse.virgo.shell.internal.parsing.ParsingUtils;
19:
20: /**
21: * The standard implementation of {@link CommandSession}
22: * </p>
23: *
24: * <strong>Concurrent Semantics</strong><br />
25: * threadsafe
26: *
27: */
28: final class StandardCommandSession implements CommandSession {
29:
30: private final CommandInvoker commandInvoker;
31:
32: StandardCommandSession(CommandInvoker commandInvoker) {
33: this.commandInvoker = commandInvoker;
34: }
35:
36: /**
37: * {@inheritDoc}
38: */
39: public List<String> execute(CharSequence commandLine) {
40: ParsedCommand command = ParsingUtils.parseCommand(commandLine);
41:
42:• if (command == null) {
43: return null;
44: }
45:
46: try {
47: return this.commandInvoker.invokeCommand(command);
48: } catch (CommandNotFoundException cnfe) {
49: return Arrays.asList(String.format("No command found for input %s", command));
50: } catch (ParametersMismatchException pme) {
51: return Arrays.asList(pme.getMessage());
52: }
53: }
54: }