KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > manentia > kasai > Operative


1 package org.manentia.kasai;
2
3 import java.sql.ResultSet JavaDoc;
4 import java.sql.SQLException JavaDoc;
5 import java.util.ArrayList JavaDoc;
6 import java.util.Collection JavaDoc;
7
8
9 /**
10  *
11  * @author fpena
12  *
13  */

14 public class Operative{
15
16     private String JavaDoc id;
17
18     private int sequence;
19
20     private String JavaDoc description;
21     private Collection JavaDoc roles;
22     
23     public Operative(){
24         roles = new ArrayList JavaDoc();
25     }
26     
27     public Operative(ResultSet JavaDoc rs) throws SQLException JavaDoc{
28         roles = new ArrayList JavaDoc();
29         id = rs.getString ("id");
30         sequence = rs.getInt("sequence");
31         description = rs.getString("description");
32     }
33     
34     public String JavaDoc getId() {
35         return this.id;
36     }
37
38     public void setId(String JavaDoc id) {
39         this.id = id;
40     }
41
42     public int getSequence() {
43         return this.sequence;
44     }
45
46     public void setSequence(int sequence) {
47         this.sequence = sequence;
48     }
49
50     public String JavaDoc getDescription() {
51         return this.description;
52     }
53
54     public void setDescription(String JavaDoc description) {
55         this.description = description;
56     }
57        
58     public Collection JavaDoc getRoles() {
59         return roles;
60     }
61
62     public void setRoles(Collection JavaDoc roles) {
63         this.roles = roles;
64     }
65     
66     public void addRole(Role role) {
67         if (role != null) {
68             if(!roles.contains(role)){
69                 this.roles.add(role);
70             }
71         }
72     }
73
74     public void removeRole (Role role){
75         if (role != null){
76             this.roles.remove(role);
77         }
78     }
79     
80     public boolean equals (java.lang.Object JavaDoc obj){
81         boolean result = false;
82         
83         try{
84             if (obj instanceof Operative){
85                 if (((Operative)obj).getId().equals (this.id)){
86                     result = true;
87                 }
88             }
89         }
90         catch (Exception JavaDoc e){
91             result = false;
92         }
93         return result;
94     }
95     
96 }
97
Popular Tags