1 package org.metricshub.winrm;
2
3 /*-
4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5 * WinRM Java Client
6 * ჻჻჻჻჻჻
7 * Copyright (C) 2023 - 2026 MetricsHub
8 * ჻჻჻჻჻჻
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
21 */
22
23 public class WindowsRemoteCommandResult {
24
25 private final String stdout;
26 private final String stderr;
27 private final float executionTime;
28 private final int statusCode;
29
30 /**
31 * Command Result constructor
32 *
33 * @param stdout The stdout of the command
34 * @param stderr The stderr of the command
35 * @param executionTime The execution time of the command in milliseconds
36 * @param statusCode The command return status code
37 */
38 public WindowsRemoteCommandResult(
39 final String stdout,
40 final String stderr,
41 final float executionTime,
42 final int statusCode
43 ) {
44 this.stdout = stdout;
45 this.stderr = stderr;
46 this.executionTime = executionTime;
47 this.statusCode = statusCode;
48 }
49
50 /**
51 * Get the stdout of the command.
52 *
53 * @return
54 */
55 public String getStdout() {
56 return stdout;
57 }
58
59 /**
60 * Get the stderr of the command.
61 *
62 * @return
63 */
64 public String getStderr() {
65 return stderr;
66 }
67
68 /**
69 * Get the execution time of the command in seconds.
70 *
71 * @return
72 */
73 public float getExecutionTime() {
74 return executionTime;
75 }
76
77 /**
78 * Get the return status code of the command
79 *
80 * @return
81 */
82 public int getStatusCode() {
83 return statusCode;
84 }
85
86 @Override
87 public String toString() {
88 return new StringBuilder()
89 .append("WindowsRemoteCommandResult:\nstdout:\n")
90 .append(stdout)
91 .append("\nstderr:\n")
92 .append(stderr)
93 .append("\nexecutionTime = ")
94 .append(executionTime)
95 .append("\nstatusCode = ")
96 .append(statusCode)
97 .toString();
98 }
99 }