001: /*
002: * State.java - 0.9.0 01/07/2001 - 15:47:55
003: *
004: * Copyright (C) 2000,2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.groboclown.util.states.v1;
028:
029: /**
030: * The basic state object.
031: *
032: * @author Matt Albrecht
033: * @version 0.9.0 Alpha
034: */
035: public class State {
036: //---------------------------------------------------------------------
037: // Public Static Fields
038:
039: //---------------------------------------------------------------------
040: // Protected Static Fields
041:
042: //---------------------------------------------------------------------
043: // Private Static Fields
044:
045: //---------------------------------------------------------------------
046: // Public Fields
047:
048: //---------------------------------------------------------------------
049: // Protected Fields
050:
051: //---------------------------------------------------------------------
052: // Private Fields
053:
054: private int index;
055: private int category;
056:
057: //---------------------------------------------------------------------
058: // Constructors
059:
060: /**
061: * Default Constructor - protected
062: */
063: protected State(int stateCategory, int stateIndex) {
064: this .index = stateIndex;
065: this .category = stateCategory;
066: }
067:
068: //---------------------------------------------------------------------
069: // Public Methods
070:
071: public boolean equals(Object o) {
072: if (o == null)
073: return false;
074: if (o == this )
075: return true;
076: if (o instanceof State) {
077: State s = (State) o;
078: if (s.index == this .index && s.category == this .category) {
079: return true;
080: }
081: }
082: return false;
083: }
084:
085: public int hashcode() {
086: return this .index + this .category;
087: }
088:
089: protected boolean isSameCategory(State s) {
090: return (s.category == this .category);
091: }
092:
093: //---------------------------------------------------------------------
094: // Protected Methods
095:
096: protected int getIndex() {
097: return this .index;
098: }
099:
100: protected int getCategory() {
101: return this .category;
102: }
103:
104: //---------------------------------------------------------------------
105: // Private Methods
106: }
|