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
CommitLineData
1d6a2139
BH
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 **********************************************************************/
13package org.eclipse.tracecompass.internal.tmf.remote.core.stubs.shells;
14
15import org.eclipse.core.commands.ExecutionException;
16import org.eclipse.core.runtime.IProgressMonitor;
aa353506 17import org.eclipse.jdt.annotation.NonNull;
1d6a2139 18import org.eclipse.jdt.annotation.NonNullByDefault;
aa353506 19import org.eclipse.jdt.annotation.Nullable;
1d6a2139
BH
20import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput;
21import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandResult;
22import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
90700072 23import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandOutputListener;
1d6a2139
BH
24import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandResult;
25import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
26
27/**
28 * Command shell stub
29 */
aa353506 30@NonNullByDefault
1d6a2139
BH
31public 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
aa353506 42 public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor) throws ExecutionException {
90700072
BH
43 return executeCommand(command, monitor, null);
44 }
45
46 @Override
aa353506
AM
47 public ICommandResult executeCommand(ICommandInput command, @Nullable IProgressMonitor monitor,
48 @Nullable ICommandOutputListener listener) throws ExecutionException {
1d6a2139 49 if (fIsConnected) {
aa353506 50 return createCommandResult(0, new @NonNull String[0], new @NonNull String[0]);
1d6a2139 51 }
aa353506 52 return createCommandResult(1, new @NonNull String[0], new @NonNull String[0]);
1d6a2139
BH
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 */
aa353506 71 protected ICommandResult createCommandResult(int result, @NonNull String[] output, @NonNull String[] errorOutput) {
1d6a2139
BH
72 return new CommandResult(result, output, errorOutput);
73 }
aa353506 74}
This page took 0.065866 seconds and 5 git commands to generate.