Fix some null warnings
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.remote.core.tests / stubs / org / eclipse / tracecompass / internal / tmf / remote / core / stubs / shells / TestCommandShell.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
12 **********************************************************************/
13 package org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells;
14
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput;
21 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandResult;
22 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
23 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandOutputListener;
24 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandResult;
25 import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
26
27 /**
28 * Command shell stub
29 */
30 @NonNullByDefault
31 public class TestCommandShell implements ICommandShell {
32
33 /** If the shell is connected */
34 protected boolean fIsConnected = false;
35
36 @Override
37 public void dispose() {
38 fIsConnected = false;
39 }
40
41 @Override
42 public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor) throws ExecutionException {
43 return executeCommand(command, monitor, null);
44 }
45
46 @Override
47 public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor,
48 @Nullable ICommandOutputListener listener) throws ExecutionException {
49 if (fIsConnected) {
50 return createCommandResult(0, new @NonNull String[0], new @NonNull String[0]);
51 }
52 return createCommandResult(1, new @NonNull String[0], new @NonNull String[0]);
53 }
54
55 @Override
56 public ICommandInput createCommand() {
57 return new CommandInput();
58 }
59
60 /**
61 * Creates a command result
62 *
63 * @param result
64 * The result of the command
65 * @param output
66 * The output, as an array of strings
67 * @param errorOutput
68 * THe error output as an array of strings
69 * @return {@link ICommandResult} instance
70 */
71 protected ICommandResult createCommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) {
72 return new CommandResult(result, output, errorOutput);
73 }
74 }
This page took 0.043079 seconds and 5 git commands to generate.