Source Code Cross Referenced for PegasusFile.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » classes » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » pegasus 2.1.0 » org.griphyn.cPlanner.classes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:
016:        package org.griphyn.cPlanner.classes;
017:
018:        import java.util.BitSet;
019:
020:        /**
021:         * The logical file object that contains the logical filename which is got from
022:         * the DAX, and the associated set of flags specifying the transient
023:         * characteristics.
024:         * It ends up associating the following information with a lfn
025:         *     -type of the file (data or executable)
026:         *     -optionality of a file
027:         *     -transient attributes of a file (dontTransfer and dontRegister)
028:         *
029:         * @author Gaurang Mehta
030:         * @author Karan Vahi
031:         * @version $Revision: 373 $
032:         */
033:        public class PegasusFile extends Data {
034:
035:            /**
036:             * The index of the flags field which when set indicates that the file
037:             * is to be considered optional.
038:             */
039:            public static final int TRANSIENT_OPTIONAL_FLAG = 0;
040:
041:            /**
042:             * The index of the flags field which when set indicates that the file is
043:             * not to be registered in the RLS/ RC.
044:             */
045:            public static final int TRANSIENT_REGISTRATION_FLAG = 1;
046:
047:            /**
048:             * The number of transient flags. This is the length of the BitSet in the
049:             * flags fields.
050:             */
051:            public static final int NO_OF_TRANSIENT_FLAGS = 2;
052:
053:            /**
054:             * The mode where the transfer for this file to the pool
055:             * is constructed and the transfer job fails if the transfer fails.
056:             * The corresponding dT (dontTransfer) value is false.
057:             */
058:            public static final int TRANSFER_MANDATORY = 0;
059:
060:            /**
061:             * The mode where the transfer for this file to the pool is constructed,
062:             * but the transfer job should not fail if the transfer fails.
063:             * The corresponding dT (dontTransfer) value is optional.
064:             */
065:            public static final int TRANSFER_OPTIONAL = 1;
066:
067:            /**
068:             * The mode where the transfer for this file is not constructed.
069:             * The corresponding dT (dontTransfer) value is true.
070:             */
071:            public static final int TRANSFER_NOT = 2;
072:
073:            /**
074:             * The string value of a file that is of type data.
075:             * @see #DATA_FILE
076:             */
077:            public static final String DATA_TYPE = "data";
078:
079:            /**
080:             * The string value of a file that is of type executable.
081:             * @see #DATA_FILE
082:             */
083:            public static final String EXECUTABLE_TYPE = "executable";
084:
085:            /**
086:             * The type denoting that a logical file is a data file.
087:             */
088:            public static final int DATA_FILE = 0;
089:
090:            /**
091:             * The type denoting that a logical file is a executable file.
092:             */
093:            public static final int EXECUTABLE_FILE = 1;
094:
095:            /**
096:             * The logical name of the file.
097:             */
098:            protected String mLogicalFile;
099:
100:            /**
101:             * The type associated with the file. It can either be a data file or an
102:             * executable file.
103:             *
104:             * @see #DATA_FILE
105:             * @see #EXECUTABLE_FILE
106:             */
107:            protected int mType;
108:
109:            /**
110:             * The transfer flag associated with the file containing tristate of
111:             * transfer,dontTransfer and optional.
112:             *
113:             * @see #TRANSFER_MANDATORY
114:             * @see #TRANSFER_OPTIONAL
115:             * @see #TRANSFER_NOT
116:             */
117:            protected int mTransferFlag;
118:
119:            /**
120:             * The transient flags field which is kept as a bit field. It keeps track
121:             * of the dontRegister and optional attributes associated with the filename
122:             * in the dax.
123:             */
124:            protected BitSet mFlags;
125:
126:            /**
127:             * The default constructor.
128:             */
129:            public PegasusFile() {
130:                super ();
131:                mFlags = new BitSet(NO_OF_TRANSIENT_FLAGS);
132:                mLogicalFile = new String();
133:                //by default the type is DATA
134:                //and transfers are mandatory
135:                mType = DATA_FILE;
136:                mTransferFlag = this .TRANSFER_MANDATORY;
137:            }
138:
139:            /**
140:             * The overloaded constructor.
141:             *
142:             * @param logName  the logical name of the file.
143:             */
144:            public PegasusFile(String logName) {
145:                super ();
146:                mFlags = new BitSet(NO_OF_TRANSIENT_FLAGS);
147:                mLogicalFile = logName;
148:                //by default the type is DATA
149:                //and transfers are mandatory
150:                mType = DATA_FILE;
151:                mTransferFlag = this .TRANSFER_MANDATORY;
152:            }
153:
154:            /**
155:             * It returns the lfn of the file that is associated with this transfer.
156:             *
157:             * @return the lfn associated with the transfer
158:             */
159:            public String getLFN() {
160:                return this .mLogicalFile;
161:            }
162:
163:            /**
164:             * It sets the logical filename of the file that is being transferred.
165:             *
166:             * @param lfn  the logical name of the file that this transfer is associated
167:             *             with.
168:             */
169:            public void setLFN(String lfn) {
170:                mLogicalFile = lfn;
171:            }
172:
173:            /**
174:             * Returns whether the type of file value is valid or not.
175:             *
176:             * @param type  the value for the type of file.
177:             *
178:             * @return true if the value is in range.
179:             *         false if the value is not in range.
180:             */
181:            public boolean typeValid(int type) {
182:                return (type >= this .DATA_FILE && type <= this .EXECUTABLE_FILE);
183:            }
184:
185:            /**
186:             * Returns whether the transfer value for the mode is in range or not.
187:             *
188:             * @param transfer  the value for the transfer.
189:             *
190:             * @return true if the value is in range.
191:             *         false if the value is not in range.
192:             */
193:            public boolean transferInRange(int transfer) {
194:                return (transfer >= this .TRANSFER_MANDATORY && transfer <= this .TRANSFER_NOT);
195:            }
196:
197:            /**
198:             * Sets the type flag to value passed.
199:             *
200:             * @param type valid transfer value.
201:             * @exception IllegalArgumentException if the transfer mode is outside
202:             * its legal range.
203:             *
204:             * @see #DATA_FILE
205:             * @see #EXECUTABLE_FILE
206:             */
207:            public void setType(int type) throws IllegalArgumentException {
208:
209:                if (typeValid(type)) {
210:                    mType = type;
211:                } else {
212:                    throw new IllegalArgumentException();
213:                }
214:            }
215:
216:            /**
217:             * Sets the transient transfer flag to value passed.
218:             *
219:             * @param type valid transfer value.
220:             * @exception IllegalArgumentException if the transfer mode is outside
221:             * its legal range.
222:             *
223:             * @see #DATA_FILE
224:             * @see #EXECUTABLE_FILE
225:             */
226:            public void setType(String type) throws IllegalArgumentException {
227:
228:                if (type == null || type.length() == 0)
229:                    throw new IllegalArgumentException("Invalid Type passed "
230:                            + type);
231:
232:                if (type.equals(this .DATA_TYPE)) {
233:                    mType = this .DATA_FILE;
234:                } else if (type.equals(this .EXECUTABLE_TYPE)) {
235:                    mType = this .EXECUTABLE_FILE;
236:                } else {
237:                    throw new IllegalArgumentException("Invalid Type passed "
238:                            + type);
239:                }
240:            }
241:
242:            /**
243:             * Sets the transient transfer flag to value passed.
244:             *
245:             * @param transfer valid transfer value.
246:             * @exception IllegalArgumentException if the transfer mode is outside
247:             * its legal range.
248:             *
249:             * @see #TRANSFER_MANDATORY
250:             * @see #TRANSFER_NOT
251:             * @see #TRANSFER_OPTIONAL
252:             */
253:            public void setTransferFlag(int transfer)
254:                    throws IllegalArgumentException {
255:
256:                if (this .transferInRange(transfer)) {
257:                    mTransferFlag = transfer;
258:                } else {
259:                    throw new IllegalArgumentException();
260:                }
261:            }
262:
263:            /**
264:             * Sets the transient transfer flag corresponding to the string
265:             * value of transfer mode passed. The legal range of transfer values is
266:             * true|false|optional.
267:             *
268:             * @param flag            tri-state transfer value as got from dontTransfer flag.
269:             * @param doubleNegative  indicates whether a double negative or not.
270:             *
271:             * @exception IllegalArgumentException if the transfer mode is outside
272:             * its legal range.
273:             *
274:             * @see #TRANSFER_MANDATORY
275:             * @see #TRANSFER_NOT
276:             * @see #TRANSFER_OPTIONAL
277:             */
278:            public void setTransferFlag(String flag, boolean doubleNegative)
279:                    throws IllegalArgumentException {
280:                if (flag == null || flag.length() == 0) {
281:                    //set to default value.
282:                    //throw new IllegalArgumentException();
283:                    mTransferFlag = this .TRANSFER_MANDATORY;
284:                    return;
285:                }
286:
287:                if (flag.equals("true")) {
288:                    mTransferFlag = (doubleNegative) ? this .TRANSFER_NOT
289:                            : this .TRANSFER_MANDATORY;
290:                } else if (flag.equals("false")) {
291:                    mTransferFlag = (doubleNegative) ? this .TRANSFER_MANDATORY
292:                            : this .TRANSFER_NOT;
293:                } else if (flag.equals("optional"))
294:                    mTransferFlag = this .TRANSFER_OPTIONAL;
295:                else {
296:                    throw new IllegalArgumentException(
297:                            "Invalid transfer value passed " + flag);
298:
299:                }
300:            }
301:
302:            /**
303:             * Returns whether the transfer is transient or not. By transient we mean
304:             * no transfer.
305:             *
306:             * @return  true if transfer mode is TRANSFER_NOT
307:             *          false if transfer mandatory or optional.
308:             */
309:            public boolean getTransientTransferFlag() {
310:                return (mTransferFlag == this .TRANSFER_NOT);
311:            }
312:
313:            /**
314:             * Sets the transient registration flag to true.
315:             */
316:            public void setTransientRegFlag() {
317:                mFlags.set(TRANSIENT_REGISTRATION_FLAG);
318:            }
319:
320:            /**
321:             * Sets the optionalflag denoting the file to be optional to true.
322:             */
323:            public void setFileOptional() {
324:                mFlags.set(TRANSIENT_OPTIONAL_FLAG);
325:            }
326:
327:            /**
328:             * Returns optionalflag denoting the file to be optional or not.
329:             *
330:             * @return true  denoting the file is optional.
331:             *         false denoting that file is not optional.
332:             */
333:            public boolean fileOptional() {
334:                return mFlags.get(TRANSIENT_OPTIONAL_FLAG);
335:            }
336:
337:            /**
338:             * Returns the tristate transfer mode that is associated with the file.
339:             *
340:             * @return the int value denoting the type.
341:             *
342:             * @see #DATA_FILE
343:             * @see #EXECUTABLE_FILE
344:             */
345:            public int getType() {
346:                return mType;
347:            }
348:
349:            /**
350:             * Returns the tristate transfer mode that is associated with the file.
351:             *
352:             * @return the int value denoting the tristate.
353:             *
354:             * @see #TRANSFER_MANDATORY
355:             * @see #TRANSFER_NOT
356:             * @see #TRANSFER_OPTIONAL
357:             */
358:            public int getTransferFlag() {
359:                return mTransferFlag;
360:            }
361:
362:            /**
363:             * Returns the transient registration flag (the value of dontRegister).
364:             *
365:             * @return true denoting the file need not be registered into the replica
366:             *              catalog.
367:             *         false denoting that file needs to be registered.
368:             */
369:            public boolean getTransientRegFlag() {
370:                return mFlags.get(TRANSIENT_REGISTRATION_FLAG);
371:            }
372:
373:            /**
374:             * Returns the bit fields that contain the transient flags (dR and optional).
375:             *
376:             *
377:             * @see #NO_OF_TRANSIENT_FLAGS
378:             * @see #TRANSIENT_OPTIONAL_FLAG
379:             * @see #TRANSIENT_REGISTRATION_FLAG
380:             */
381:            public BitSet getFlags() {
382:                return mFlags;
383:            }
384:
385:            /**
386:             * Checks if an object is similar to the one referred to by this class.
387:             * We compare the primary key to determine if it is the same or not.
388:             *
389:             * @return true if the primary key (lfn,transfer flag,transient flag) match.
390:             *         else false.
391:             */
392:            /*    public boolean equals(Object o){
393:             if(o instanceof PegasusFile){
394:             PegasusFile file = (PegasusFile) o;
395:
396:             return (file.mLogicalFile.equals(this.mLogicalFile) &&
397:             (file.getTransientRegFlag() == this.getTransientRegFlag()) &&
398:             (file.getTransferFlag() == this.getTransferFlag()));
399:             }
400:             return false;
401:             }
402:             */
403:
404:            /**
405:             * Checks if an object is similar to the one referred to by this class.
406:             * We compare the primary key to determine if it is the same or not.
407:             *
408:             * @return true if the primary key (lfn) matches.
409:             *         else false.
410:             */
411:            public boolean equals(Object o) {
412:                if (o instanceof  PegasusFile) {
413:                    PegasusFile file = (PegasusFile) o;
414:
415:                    return (file.mLogicalFile.equals(this .mLogicalFile));
416:                }
417:                return false;
418:            }
419:
420:            /**
421:             * Calculate a hash code value for the object to support hash tables.
422:             *
423:             * @return a hash code value for the object.
424:             */
425:            public int hashCode() {
426:                return this .mLogicalFile.hashCode();
427:            }
428:
429:            /**
430:             * Returns a copy of the existing data object.
431:             *
432:             * @return clone of the object.
433:             */
434:            public Object clone() {
435:                PegasusFile pf = new PegasusFile();
436:                pf.mLogicalFile = new String(mLogicalFile);
437:                pf.mFlags = (BitSet) this .mFlags.clone();
438:                pf.mType = mType;
439:                pf.mTransferFlag = mTransferFlag;
440:                return pf;
441:            }
442:
443:            /**
444:             * Returns the type associated with the logical file.
445:             *
446:             * @return type of the file.
447:             */
448:            public String typeToString() {
449:                return (mType == DATA_FILE) ? DATA_TYPE : EXECUTABLE_TYPE;
450:            }
451:
452:            /**
453:             * Returns the String version of the data object, which is in human readable
454:             * form.
455:             *
456:             * @return the dump of the data object into a string.
457:             */
458:            public String toString() {
459:                String st = "\n Logical Name :"
460:                        + this .mLogicalFile
461:                        + "\n Type         :"
462:                        + typeToString()
463:                        + "\n Transient Flags (transfer,dontRegister,optional):"
464:                        + " ( ";
465:
466:                st += getTransferFlag() + ",";
467:
468:                for (int i = 0; i < NO_OF_TRANSIENT_FLAGS; i++) {
469:                    st += mFlags.get(i);
470:                    if (i < NO_OF_TRANSIENT_FLAGS)
471:                        st += ",";
472:                }
473:                st += ")";
474:
475:                return st;
476:            }
477:
478:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.