001: /*
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found in file GTPL, or at
004: * http://www.globus.org/toolkit/download/license.html. This notice must
005: * appear in redistributions of this file, with or without modification.
006: *
007: * Redistributions of this Software, with or without modification, must
008: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009: * some other similar material which is provided with the Software (if
010: * any).
011: *
012: * Copyright 1999-2004 University of Chicago and The University of
013: * Southern California. All rights reserved.
014: */
015: package org.griphyn.vdl.invocation;
016:
017: import java.util.*;
018: import java.io.Writer;
019: import java.io.IOException;
020:
021: /**
022: * This class is transient for XML parsing. The data value will be
023: * incorporated into the job status classes.
024: *
025: * @author Jens-S. Vöckler
026: * @author Yong Zhao
027: * @version $Revision: 50 $
028: * @see StatCall
029: */
030: public class JobStatusRegular extends JobStatus // implements Cloneable
031: {
032: /**
033: * This is exit code returned by the application.
034: */
035: private short m_exitcode;
036:
037: /**
038: * Default c'tor: Construct a hollow shell and allow further
039: * information to be added later.
040: */
041: public JobStatusRegular() {
042: m_exitcode = 0;
043: }
044:
045: /**
046: * Constructs an exit code.
047: * @param exitcode is the exit code of the application.
048: */
049: public JobStatusRegular(short exitcode) {
050: m_exitcode = exitcode;
051: }
052:
053: /**
054: * Accessor
055: *
056: * @see #setExitCode(short)
057: */
058: public short getExitCode() {
059: return this .m_exitcode;
060: }
061:
062: /**
063: * Accessor.
064: *
065: * @param exitcode
066: * @see #getExitCode()
067: */
068: public void setExitCode(short exitcode) {
069: this .m_exitcode = exitcode;
070: }
071:
072: /**
073: * Converts the active state into something meant for human consumption.
074: * The method will be called when recursively traversing the instance
075: * tree.
076: *
077: * @param stream is a stream opened and ready for writing. This can also
078: * be a string stream for efficient output.
079: */
080: public void toString(Writer stream) throws IOException {
081: throw new IOException(
082: "method not implemented, please contact vds-support@griphyn.org");
083: }
084:
085: /**
086: * Dumps the state of the current element as XML output. This function
087: * can return the necessary data more efficiently, thus overwriting
088: * the inherited method.
089: *
090: * @param indent is a <code>String</code> of spaces used for pretty
091: * printing. The initial amount of spaces should be an empty string.
092: * The parameter is used internally for the recursive traversal.
093: *
094: * @return a String which contains the state of the current class and
095: * its siblings using XML. Note that these strings might become large.
096: */
097: public String toXML(String indent) {
098: StringBuffer result = new StringBuffer(32); // good for no content
099:
100: result.append("<regular exitcode=\"");
101: result.append(Short.toString(m_exitcode));
102: result.append("\"/>");
103:
104: return result.toString();
105: }
106:
107: /**
108: * Dump the state of the current element as XML output. This function
109: * traverses all sibling classes as necessary, and converts the data
110: * into pretty-printed XML output. The stream interface should be able
111: * to handle large output efficiently.
112: *
113: * @param stream is a stream opened and ready for writing. This can also
114: * be a string stream for efficient output.
115: * @param indent is a <code>String</code> of spaces used for pretty
116: * printing. The initial amount of spaces should be an empty string.
117: * The parameter is used internally for the recursive traversal.
118: * If a <code>null</code> value is specified, no indentation nor
119: * linefeeds will be generated.
120: * @param namespace is the XML schema namespace prefix. If neither
121: * empty nor null, each element will be prefixed with this prefix,
122: * and the root element will map the XML namespace.
123: * @exception IOException if something fishy happens to the stream.
124: */
125: public void toXML(Writer stream, String indent, String namespace)
126: throws IOException {
127: stream.write('<');
128: if (namespace != null && namespace.length() > 0) {
129: stream.write(namespace);
130: stream.write(':');
131: }
132: stream.write("regular");
133: writeAttribute(stream, " exitcode=\"", Short
134: .toString(m_exitcode));
135: stream.write("/>");
136: }
137: }
|