001package org.apache.maven.scm;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.Serializable;
023
024/**
025 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
026 *
027 */
028public class ScmResult
029    implements Serializable
030{
031    private static final long serialVersionUID = 7037918334820621525L;
032
033    private final boolean success;
034
035    private final String providerMessage;
036
037    private final String commandOutput;
038
039    private final String commandLine;
040
041    /**
042     * Copy constructor.
043     * <p/>
044     * Typically used from derived classes when wrapping a ScmResult
045     * into a specific type eg. AddScmResult
046     *
047     * @param scmResult not null
048     */
049    public ScmResult( ScmResult scmResult )
050    {
051        this.commandLine = scmResult.commandLine;
052
053        this.providerMessage = scmResult.providerMessage;
054
055        this.commandOutput = scmResult.commandOutput;
056
057        this.success = scmResult.success;
058    }
059
060    /**
061     * ScmResult contructor.
062     *
063     * @param commandLine     The provider specific command line used
064     * @param providerMessage The provider message
065     * @param commandOutput   The command output of the scm tool
066     * @param success         True if the command is in success
067     */
068    public ScmResult( String commandLine, String providerMessage, String commandOutput, boolean success )
069    {
070        this.commandLine = commandLine;
071
072        this.providerMessage = providerMessage;
073
074        this.commandOutput = commandOutput;
075
076        this.success = success;
077    }
078
079    /**
080     * @return True if the command was in success
081     */
082    public boolean isSuccess()
083    {
084        return success;
085    }
086
087    /**
088     * @return A message from the provider. On success this would typically be null or
089     *         an empty string. On failure it would be the error message from the provider
090     */
091    public String getProviderMessage()
092    {
093        return providerMessage;
094    }
095
096    /**
097     * @return Output from Std.Out from the provider during execution
098     *         of the command that resulted in this
099     */
100    public String getCommandOutput()
101    {
102        return commandOutput;
103    }
104
105    /**
106     * @return The actual provider specific command that resulted in this
107     */
108    public String getCommandLine()
109    {
110        return commandLine;
111    }
112}