View Javadoc

1   /*
2   * The contents of this file are subject to the BT "ZEUS" Open Source 
3   * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
4   * except in compliance with the Licence. You may obtain a copy of the Licence
5   * from $ZEUS_INSTALL/licence.html or alternatively from
6   * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7   * 
8   * Except as stated in Clause 7 of the Licence, software distributed under the
9   * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
10  * implied. See the Licence for the specific language governing rights and 
11  * limitations under the Licence.
12  * 
13  * The Original Code is within the package zeus.*.
14  * The Initial Developer of the Original Code is British Telecommunications
15  * public limited company, whose registered office is at 81 Newgate Street, 
16  * London, EC1A 7AJ, England. Portions created by British Telecommunications 
17  * public limited company are Copyright 1996-9. All Rights Reserved.
18  * 
19  * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20  */
21  
22  
23  
24  package zeus.concepts;
25  
26  import java.util.*;
27  import zeus.util.*;
28  
29  
30  public class GoalSummary extends Summary {
31     public static String DISCRETE = "Discrete";
32     public static String CONTINUOUS = "Continuous";
33     public static String ENACTMENT = "Enactment";
34  
35     public static String RUNNING = "Running";
36     public static String SUSPENDED = "Suspended";
37     public static String CANCELLED = "Cancelled";
38     public static String FAILED = "Failed";
39     public static String COMPLETED = "Completed";
40  
41     protected String id;
42     protected String type;
43     protected String owner;
44     protected String item;
45  
46     public GoalSummary(String id, String type, String status,
47                        String owner, String item) {
48        setId(id);
49        setType(type);
50        setStatus(status);
51        setOwner(owner);
52        setItem(item);
53     }
54  
55     public GoalSummary(GoalSummary g) {
56        id = g.getId();
57        type = g.getType();
58        status = g.getStatus();
59        owner = g.getOwner();
60        item = g.getItem();
61     }
62  
63     public String getId()    { return id; }
64     public String getType()  { return type; }
65     public String getOwner() { return owner; }
66     public String getItem()  { return item; }
67  
68     public String[] summarize() {
69        String[] data = { item, owner, id, type, status };
70        return data;
71     }
72     public void setId(String id) {
73        Assert.notNull(id);
74        this.id = id;
75     }
76     public void setType(String type) {
77        Assert.notNull(type);
78        Assert.notFalse( type.equals(DISCRETE) || type.equals(CONTINUOUS) ||
79                         type.equals(ENACTMENT) );
80        this.type = type;
81     }
82     public void setStatus(String status) {
83        Assert.notNull(status);
84        Assert.notFalse( status.equals(RUNNING) || status.equals(SUSPENDED) ||
85                         status.equals(CANCELLED) || status.equals(FAILED) ||
86                         status.equals(COMPLETED) || status.equals(UNKNOWN) );
87        this.status = status;
88     }
89     public void setOwner(String owner) {
90        Assert.notNull(owner);
91        this.owner = owner;
92     }
93     public void setItem(String item) {
94        Assert.notNull(item);
95        this.item = item;
96     }
97  
98     public boolean equals(GoalSummary g ) {
99        return id.equals(g.getId()) && type.equals(g.getType()) &&
100              status.equals(g.getStatus()) && owner.equals(g.getOwner()) &&
101              item.equals(g.getItem());
102    }
103 
104    public String toString() {
105       return( "(" +
106                ":id " + id + " " +
107                ":type " + type + " " +
108                ":status " + status +
109                ":owner " + owner +
110                ":item " + item +
111               ")"
112             );
113    }
114 }