001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.camel.component.exec; 018 019 import java.io.InputStream; 020 import java.io.Serializable; 021 022 import static org.apache.camel.util.ObjectHelper.notNull; 023 024 /** 025 * Value object, that represents the result of an {@link ExecCommand} execution. 026 */ 027 public class ExecResult implements Serializable { 028 029 private static final long serialVersionUID = -2238558080056724637L; 030 031 private final ExecCommand command; 032 033 private final int exitValue; 034 035 private final InputStream stdout; 036 037 private final InputStream stderr; 038 039 /** 040 * Creates a <code>ExecResult</code> instance. 041 * 042 * @param command A not-null reference of {@link ExecCommand}, that produced 043 * the result. 044 * @param stdout InputStream with the stdout of the command executable. If 045 * there was no stdout, the value must be <code>null</code>. 046 * @param stderr InputStream with the stderr of the command executable. If 047 * there was no stderr, the value must be <code>null</code>. 048 * @param exitValue the exit value of the command executable. 049 */ 050 public ExecResult(ExecCommand command, InputStream stdout, InputStream stderr, int exitValue) { 051 notNull(command, "command"); 052 this.command = command; 053 054 this.stdout = stdout; 055 this.stderr = stderr; 056 this.exitValue = exitValue; 057 } 058 059 /** 060 * The executed command, that produced this result. The returned object is 061 * never <code>null</code>. 062 * 063 * @return The executed command, that produced this result. 064 */ 065 public ExecCommand getCommand() { 066 return command; 067 } 068 069 /** 070 * The exit value of the command executable. 071 * 072 * @return The exit value of the command executable 073 */ 074 public int getExitValue() { 075 return exitValue; 076 } 077 078 /** 079 * Returns the content of the standart output (stdout) of the executed 080 * command or <code>null</code>, if no output was produced in the stdout. 081 * 082 * @return The standart output (stdout) of the command executable. 083 */ 084 public InputStream getStdout() { 085 return stdout; 086 } 087 088 /** 089 * Returns the content of the standart error output (stderr) of the executed 090 * command or <code>null</code>, if no output was produced in the stderr. 091 * 092 * @return The standart error output (stderr) of the command executable. 093 */ 094 public InputStream getStderr() { 095 return stderr; 096 } 097 }