~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jdrmaa/src/org/ggf/drmaa/FileTransferMode.java

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
/*
 
33
 * FileTransferMode.java
 
34
 *
 
35
 * Created on October 6, 2004, 6:05 PM
 
36
 */
 
37
 
 
38
package org.ggf.drmaa;
 
39
 
 
40
import java.io.Serializable;
 
41
 
 
42
/**
 
43
 * This class represents the streams which should be used for file transfers.
 
44
 * For each of the three properties which is set to true, the corresponding
 
45
 * stream's path property in the job template will be treated as a source or
 
46
 * destination (depending on the stream) for file tranfers.  For example, if the
 
47
 * inputStream property is set to true, the inputPath property of the
 
48
 * JobTemplate will be interpreted as a source from which to transfer files.
 
49
 * @author dan.templeton@sun.com
 
50
 * @since 0.5
 
51
 * @version 1.0
 
52
 */
 
53
public class FileTransferMode implements Serializable, Cloneable {
 
54
    /** Whether to transfer error stream files. */
 
55
    private boolean errorStream = false;
 
56
    /** Whether to transfer input stream files. */
 
57
    private boolean inputStream = false;
 
58
    /** Whether to transfer output stream files. */
 
59
    private boolean outputStream = false;
 
60
    
 
61
    /**
 
62
     * Creates a new instance of FileTransferMode
 
63
     */
 
64
    public FileTransferMode() {
 
65
    }
 
66
    
 
67
    /**
 
68
     * Create a new instance with the property values preset.
 
69
     * @param inputStream whether to transfer input stream files
 
70
     * @param outputStream whether to transfer output stream files
 
71
     * @param errorStream whether to transfer error stream files
 
72
     */
 
73
    public FileTransferMode(boolean inputStream, boolean outputStream, boolean errorStream) {
 
74
        this.errorStream = errorStream;
 
75
        this.inputStream = inputStream;
 
76
        this.outputStream = outputStream;
 
77
    }
 
78
    
 
79
    /**
 
80
     * Set whether to transfer error stream files.
 
81
     * @param errorStream whether to transfer error stream files
 
82
     */
 
83
    public void setErrorStream(boolean errorStream) {
 
84
        this.errorStream = errorStream;
 
85
    }
 
86
    
 
87
    /**
 
88
     * Whether to transfer error stream files.
 
89
     * @return whether to transfer error stream files
 
90
     */
 
91
    public boolean getErrorStream() {
 
92
        return errorStream;
 
93
    }
 
94
    
 
95
    /**
 
96
     * Set whether to transfer error stream files.
 
97
     * @param inputStream whether to transfer error stream files
 
98
     */
 
99
    public void setInputStream(boolean inputStream) {
 
100
        this.inputStream = inputStream;
 
101
    }
 
102
    
 
103
    /**
 
104
     * Whether to transfer error stream files.
 
105
     * @return whether to transfer error stream files
 
106
     */
 
107
    public boolean getInputStream() {
 
108
        return inputStream;
 
109
    }
 
110
    
 
111
    /**
 
112
     * Set whether to transfer error stream files.
 
113
     * @param outputStream whether to transfer error stream files
 
114
     */
 
115
    public void setOutputStream(boolean outputStream) {
 
116
        this.outputStream = outputStream;
 
117
    }
 
118
    
 
119
    /**
 
120
     * Whether to transfer error stream files.
 
121
     * @return whether to transfer error stream files
 
122
     */
 
123
    public boolean getOutputStream() {
 
124
        return outputStream;
 
125
    }
 
126
    
 
127
    /**
 
128
     * Test whether two FileTransferMode objects have the same property
 
129
     * settings.
 
130
     * @param obj the Object to test for equality
 
131
     * @return whether the FileTransferMode object has the same property
 
132
     * settings as this one
 
133
     */
 
134
    public boolean equals(Object obj) {
 
135
        return ((obj instanceof FileTransferMode) &&
 
136
                (((FileTransferMode)obj).errorStream == errorStream) &&
 
137
                (((FileTransferMode)obj).inputStream == inputStream) &&
 
138
                (((FileTransferMode)obj).outputStream == outputStream));
 
139
    }
 
140
    
 
141
    /**
 
142
     * Returns a hash code based on the file transfer properties.
 
143
     * @return a hash code based on the file transfer properties
 
144
     */
 
145
    public int hashCode() {
 
146
        int ret = 0;
 
147
        
 
148
        ret += inputStream ? 1 : 0;
 
149
        ret += outputStream ? 2 : 0;
 
150
        ret += errorStream ? 4 : 0;
 
151
        
 
152
        return ret;
 
153
    }
 
154
    
 
155
    /**
 
156
     * Creates a copy of this FileTransferMode object.
 
157
     * @return a copy of this FileTransferMode object
 
158
     */
 
159
    public Object clone() {
 
160
        try {
 
161
            return super.clone();
 
162
        } catch (CloneNotSupportedException e) {
 
163
            // this shouldn't happen, since we are Cloneable
 
164
            throw new InternalError();
 
165
        }
 
166
    }
 
167
    
 
168
    /**
 
169
     * Returns a string containing the stream settings.
 
170
     * @return a string containing the stream settings
 
171
     */
 
172
    public String toString() {
 
173
        StringBuffer out = new StringBuffer();
 
174
        boolean firstProperty = true;
 
175
        
 
176
        if (inputStream) {
 
177
            out.append("input");
 
178
            firstProperty = false;
 
179
        }
 
180
        
 
181
        if (outputStream) {
 
182
            if (firstProperty) {
 
183
                firstProperty = false;
 
184
            } else {
 
185
                out.append(", ");
 
186
            }
 
187
            
 
188
            out.append("output");
 
189
        }
 
190
        
 
191
        if (errorStream) {
 
192
            if (!firstProperty) {
 
193
                out.append(", ");
 
194
            }
 
195
            
 
196
            out.append("error");
 
197
        }
 
198
        
 
199
        return out.toString();
 
200
    }
 
201
}