KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > groboclown > util > states > v1 > State


1 /*
2  * State.java - 0.9.0 01/07/2001 - 15:47:55
3  *
4  * Copyright (C) 2000,2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

26
27 package net.groboclown.util.states.v1;
28
29
30 /**
31  * The basic state object.
32  *
33  * @author Matt Albrecht
34  * @version 0.9.0 Alpha
35  */

36 public class State
37 {
38     //---------------------------------------------------------------------
39
// Public Static Fields
40

41      
42     //---------------------------------------------------------------------
43
// Protected Static Fields
44

45      
46     //---------------------------------------------------------------------
47
// Private Static Fields
48

49      
50     //---------------------------------------------------------------------
51
// Public Fields
52

53      
54     //---------------------------------------------------------------------
55
// Protected Fields
56

57      
58     //---------------------------------------------------------------------
59
// Private Fields
60

61     private int index;
62     private int category;
63      
64      
65      
66     //---------------------------------------------------------------------
67
// Constructors
68

69      
70     /**
71      * Default Constructor - protected
72      */

73     protected State( int stateCategory, int stateIndex )
74     {
75         this.index = stateIndex;
76         this.category = stateCategory;
77     }
78      
79      
80      
81      
82      
83     //---------------------------------------------------------------------
84
// Public Methods
85

86     public boolean equals( Object JavaDoc o )
87     {
88         if (o == null) return false;
89         if (o == this) return true;
90         if (o instanceof State)
91         {
92             State s = (State)o;
93             if (s.index == this.index && s.category == this.category)
94             {
95                 return true;
96             }
97         }
98         return false;
99     }
100     
101     
102     public int hashcode()
103     {
104         return this.index + this.category;
105     }
106     
107     protected boolean isSameCategory( State s )
108     {
109         return (s.category == this.category);
110     }
111      
112     //---------------------------------------------------------------------
113
// Protected Methods
114

115     
116     protected int getIndex()
117     {
118         return this.index;
119     }
120     
121     protected int getCategory()
122     {
123         return this.category;
124     }
125     
126     
127      
128     //---------------------------------------------------------------------
129
// Private Methods
130
}
131  
132
Popular Tags