01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.cPlanner.classes;
16:
17: import java.util.Enumeration;
18: import java.util.Iterator;
19: import java.util.Set;
20: import java.util.Vector;
21:
22: import org.griphyn.cPlanner.common.LogManager;
23:
24: /**
25: * This is the container for all the Data classes.
26: *
27: * @author Karan Vahi
28: * @author Gaurang Mehta
29: * @version $Revision: 50 $
30: */
31: public abstract class Data implements Cloneable {
32:
33: /**
34: * The LogManager object which is used to log all the messages.
35: *
36: * @see org.griphyn.cPlanner.common.LogManager
37: */
38: public LogManager mLogger = LogManager.getInstance();
39:
40: /**
41: * The String which stores the message to be stored.
42: */
43: public String mLogMsg;
44:
45: /**
46: * The default constructor.
47: */
48: public Data() {
49: mLogMsg = new String();
50: }
51:
52: /**
53: * Returns the String version of the data object, which is in human readable
54: * form.
55: */
56: public abstract String toString();
57:
58: /**
59: * It converts the contents of the Vector to a String and returns it.
60: * For this to work , all the objects making up the vector should be having
61: * a valid toString() method.
62: *
63: * @param heading The heading you want to give
64: * to the text which is printed
65: *
66: * @param vector The <code>Vector</code> whose
67: * elements you want to print
68: */
69: public String vectorToString(String heading, Vector vector) {
70: Enumeration e = vector.elements();
71:
72: String st = "\n" + heading;
73: while (e.hasMoreElements()) {
74: st += " " + e.nextElement().toString();
75: }
76:
77: return st;
78: }
79:
80: /**
81: * A small helper method that displays the contents of a Set in a String.
82: *
83: * @param delim The delimited between the members of the set.
84: * @return String
85: */
86: public String setToString(Set s, String delim) {
87: Iterator it = s.iterator();
88: String st = new String();
89: while (it.hasNext()) {
90: st += (String) it.next() + delim;
91: }
92: st = (st.length() > 0) ? st.substring(0, st.lastIndexOf(delim))
93: : st;
94: return st;
95: }
96:
97: }
|