Subversion Repositories XServices

Rev

Rev 82 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/*
 *   Copyright 2010 Brian Rosenberger (Brutex Network)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package net.brutex.xservices.types;

import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import net.brutex.xservices.types.ant.AntProperty;
import net.brutex.xservices.util.BrutexNamespaces;

/**
 *
 * @author Brian Rosenberger, bru@brutex.de
 */
@XmlType(namespace=BrutexNamespaces.WS_XSERVICES, name="ReturnCodeType")
public class ReturnCode {

    /**
     * Numeric return code.
     *
     * The numeric return code of the last operation on the underlying operation
     * systen (OS). In general the return code indicates the failure or success
     * of a command. Which value indicates success is dependent on the OS, most
     * linux based systems use "0" for success.
     */
    @XmlElement(required=true, nillable=false)
    public int returnCode=0;

    /**
     * Standard Out as provided by the OS.
     *
     * The stdOut given by the last operation (if any).
     */
    @XmlElement(name="stdOut", nillable=false)
    public String stdOut="";

    /**
     * The Standard Error as provided by the OS.
     *
     * The stdErr given by the last operation (if any). The presents of any
     * value here ususally indicates that a failure has occured.
     */
    @XmlElement(name="stdErr", nillable=false)
    public String stdErr="";


    @XmlElement(name="propertyList", nillable=true)
    public List<AntProperty> property = null;

    /**
     * Create a new ReturnCode default constructor.
     */
    public ReturnCode() {
    }

    /**
     * Create a new ReturnCode.
     *
     * @param returnCode    return code integer value
     * @param stdOut        standard out string
     * @param stdErr        standard error string
     */
    public ReturnCode(int returnCode, String stdOut, String stdErr, List<AntProperty> props) {
        this.returnCode = returnCode;
        this.stdOut = stdOut;
        this.stdErr = stdErr;
        this.property = props;
    }
    
    /**
     * @param key
     * @return
     */
    public String getProperty(String key) {
        for(AntProperty prop : this.property) {
                if(key.equals(prop.name)) return prop.value;
        }
        return null;
    }
    
    /**
     * @return
     */
    public String getStdOut() { return this.stdOut; }
}