01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.services.jdktools;
16:
17: /** This structure contains comilation output */
18: public final class CompilationResult {
19: /** This fields contains true if compiler has succeeded */
20: protected boolean mIsSuccessful = false;
21: /** This fields contains the printout of the compilation */
22: protected String mCompilerPrintout = "";
23: /** This fields contains the jar result of the successfull compilation */
24: protected byte[] mJarredOutput = new byte[0];
25:
26: /** Creates the result containing the failure */
27: public static CompilationResult createCompilerFailure(
28: String pCompilerPrintout) {
29: CompilationResult lResult = new CompilationResult();
30: lResult.mIsSuccessful = false;
31: lResult.mCompilerPrintout = pCompilerPrintout;
32: lResult.mJarredOutput = new byte[0];
33: return lResult;
34: }
35:
36: /** Creates the result containing the success */
37: public static CompilationResult createCompilerSuccess(
38: byte[] pJarredOutput, String pCompilerPrintout) {
39: CompilationResult lResult = new CompilationResult();
40: lResult.mIsSuccessful = true;
41: lResult.mCompilerPrintout = (pCompilerPrintout == null) ? ""
42: : pCompilerPrintout;
43: lResult.mJarredOutput = pJarredOutput;
44: return lResult;
45: }
46:
47: /** Creates the result containing the success */
48: public static CompilationResult createCompilerSuccess(
49: byte[] pJarredOutput) {
50: CompilationResult lResult = new CompilationResult();
51: lResult.mIsSuccessful = true;
52: lResult.mCompilerPrintout = "";
53: lResult.mJarredOutput = pJarredOutput;
54: return lResult;
55: }
56:
57: /** Returns true if result is successfull */
58: public boolean isSuccessful() {
59: return mIsSuccessful;
60: }
61:
62: /** Returns contents of the jar file */
63: public byte[] getResultJar() {
64: if (!mIsSuccessful)
65: throw new java.lang.IllegalStateException(
66: "Result jar is only available from successful compilation result");
67: return mJarredOutput;
68: }
69:
70: /** Returns contents of the compiler output */
71: public String getCompilerPrintout() {
72: return mCompilerPrintout;
73: }
74: }
|