baac253212e56b9441dcca806130448eac9ad7fd
1 /**********************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.tmf
.remote
.core
.shell
;
14 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.nullToEmptyString
;
17 import java
.util
.ArrayList
;
18 import java
.util
.List
;
20 import org
.eclipse
.jdt
.annotation
.Nullable
;
21 import org
.eclipse
.tracecompass
.tmf
.remote
.core
.shell
.ICommandInput
;
23 import com
.google
.common
.collect
.ImmutableList
;
26 * Class for defining command input for remote command execution.
28 * @author Bernd Hufmann
30 public class CommandInput
implements ICommandInput
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
35 /** The input as list of Strings. */
36 private final List
<String
> fInput
= new ArrayList
<>();
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
43 public List
<String
> getInput() {
44 return checkNotNull(ImmutableList
.copyOf(fInput
));
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
51 public void add(@Nullable String segment
) {
52 if (segment
!= null) {
58 public void addAll(List
<String
> segments
) {
59 for (String segment
: segments
) {
65 * Creates a single command string from a command line list.
67 * @return single command string
70 public String
toString() {
71 StringBuilder builder
= new StringBuilder();
72 for (String segment
: getInput()) {
73 builder
.append(segment
).append(' ');
75 return nullToEmptyString(builder
.toString().trim());
This page took 0.038448 seconds and 4 git commands to generate.