154e15b3396a89273b7268841413d683a42685b5
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / model / Schema.java
1 package com.quantum.model;
2
3 /**
4  * @author BC
5  */
6 public class Schema implements Comparable {
7     
8     private String name;
9     private String displayName;
10     private boolean isDefault;
11     
12     
13     public Schema() {
14     }
15
16     public Schema(String name, String displayName, boolean isDefault) {
17         this.name = name;
18         this.displayName = displayName;
19         this.isDefault = isDefault;
20     }
21     
22     public Schema(String name) {
23         this(name, name, false);
24     }
25     
26     /**
27      * @return
28      */
29     public String getName() {
30         return name;
31     }
32
33     /**
34      * @param string
35      */
36     public void setName(String string) {
37         name = string;
38     }
39
40     /**
41      * @see java.lang.Comparable#compareTo(java.lang.Object)
42      */
43     public int compareTo(Object o) {
44         Schema that = (Schema) o;
45         if (that.isDefault() == this.isDefault()) {
46             return this.getDisplayName().compareTo(that.getDisplayName());
47         } else {
48             return that.isDefault() ? 1 : -1;
49         }
50     }
51     public boolean equals(Object obj) {
52         if (getClass() != obj.getClass()) {
53             return false;
54         } else {
55             Schema that = (Schema) obj;
56             if (this.name == null && !(that.name == null)) {
57                 return false;
58             } else if (this.name != null && !this.name.equals(that.name)) {
59                 return false;
60             } else if (this.displayName == null && !(that.displayName == null)) {
61                 return false;
62             } else if (this.displayName == null && !this.displayName.equals(that.displayName)) {
63                 return false;
64             } else {
65                 return true;
66             }
67         }
68     }
69     public int hashCode() {
70         int hashCode = super.hashCode();
71         if (this.name != null) {
72             hashCode ^= this.name.hashCode();
73         }
74         if (this.displayName != null) {
75             hashCode ^= this.displayName.hashCode();
76         }
77         
78         return hashCode;
79     }
80     
81     /**
82      * @return
83      */
84     public boolean isDefault() {
85         return isDefault;
86     }
87
88     /**
89      * @param b
90      */
91     public void setDefault(boolean isDefault) {
92         this.isDefault = isDefault;
93     }
94
95     /**
96      * @return
97      */
98     public String getDisplayName() {
99         return displayName;
100     }
101
102     /**
103      * @param string
104      */
105     public void setDisplayName(String string) {
106         displayName = string;
107     }
108
109 }