dip.world
Class Phase

java.lang.Object
  extended bydip.world.Phase
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Phase
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

A Phase object represents when a turn takes place, and contains the year, game phase (PhaseType), and Season information.

Phase objects are mutable and comparable.

PhaseType and SeasonType objects may be compared with referential equality. (For example, "Phase.getSeasonType() == SeasonType.SPRING")

See Also:
Serialized Form

Nested Class Summary
static class Phase.PhaseType
          PhaseTypes represent game phases.
static class Phase.SeasonType
          Represents seasons SeasonType constants should be used, rather than creating new SeasonType objects.
static class Phase.YearType
          YearType is used to represent the Year A YearType is used because we now support negative years ("BC") and need to appropriately advance, parse, and format these years.
 
Field Summary
protected  Phase.PhaseType phaseType
           
protected  Phase.SeasonType seasonType
           
protected  Phase.YearType yearType
           
 
Constructor Summary
  Phase(Phase.SeasonType seasonType, int year, Phase.PhaseType phaseType)
          Create a new Phase.
  Phase(Phase.SeasonType seasonType, Phase.YearType yearType, Phase.PhaseType phaseType)
          Create a new Phase.
protected Phase(Phase.YearType yt, int idx)
          Create a new Phase, given a known index
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares the Phase to the given Phase object.
 boolean equals(java.lang.Object obj)
          Returns true if the two phases are equivalent.
static java.lang.String[] getAllSeasonPhaseCombos()
          Returns a String array, in order, of valid season/phase combinations.
 java.lang.String getBriefName()
          Displays as a short String (e.g., F1902R)
 Phase getNext()
          Get the phase that would be after to the current phase
 Phase.PhaseType getPhaseType()
          Returns the PhaseType
 Phase getPrevious()
          Get the phase that would come before the current phase
 Phase.SeasonType getSeasonType()
          Returns the SeasonType
 int getYear()
          Returns the year
 Phase.YearType getYearType()
          Returns the YearType
static boolean isValid(Phase.SeasonType st, Phase.PhaseType pt)
          Determines if this phase is valid.
static Phase parse(java.lang.String in)
          Determines the Phase from a String.
protected  java.lang.Object readResolve()
          Reconstitute a Phase object
 java.lang.String toString()
          Displays the phase as a String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

seasonType

protected final Phase.SeasonType seasonType

yearType

protected final Phase.YearType yearType

phaseType

protected final Phase.PhaseType phaseType
Constructor Detail

Phase

public Phase(Phase.SeasonType seasonType,
             int year,
             Phase.PhaseType phaseType)
Create a new Phase.


Phase

public Phase(Phase.SeasonType seasonType,
             Phase.YearType yearType,
             Phase.PhaseType phaseType)
Create a new Phase.


Phase

protected Phase(Phase.YearType yt,
                int idx)
Create a new Phase, given a known index

Method Detail

getYear

public int getYear()
Returns the year


getYearType

public Phase.YearType getYearType()
Returns the YearType


getPhaseType

public Phase.PhaseType getPhaseType()
Returns the PhaseType


getSeasonType

public Phase.SeasonType getSeasonType()
Returns the SeasonType


getBriefName

public java.lang.String getBriefName()
Displays as a short String (e.g., F1902R)


toString

public java.lang.String toString()
Displays the phase as a String


equals

public boolean equals(java.lang.Object obj)
Returns true if the two phases are equivalent.


compareTo

public int compareTo(java.lang.Object obj)
Compares the Phase to the given Phase object. Returns a negative, zero, or positive integer depending if the given Phase is less than, equal, or greater than (temporally) to this Phase.

Specified by:
compareTo in interface java.lang.Comparable

getNext

public Phase getNext()
Get the phase that would be after to the current phase


getPrevious

public Phase getPrevious()
Get the phase that would come before the current phase


isValid

public static boolean isValid(Phase.SeasonType st,
                              Phase.PhaseType pt)
Determines if this phase is valid. Not all PhaseType and SeasonType combinations are valid.


parse

public static Phase parse(java.lang.String in)
Determines the Phase from a String.

Expects input in the following form(s):

Season, Year (Phase)
Season, Year [Phase]
SYYYYP as a single 6-character token, e.g., F1900M = Fall 1900, Movement

Whitespace: space, comma, colon, semicolon, [], (), tab, newline, return, quotes

The order is not important. If the combination is not valid (via isValid()), or if any Phase component cannot be parsed, a null value is returned. Note that this is very forgiving, but it does not allow any non-word tokens between what we look for.


getAllSeasonPhaseCombos

public static java.lang.String[] getAllSeasonPhaseCombos()
Returns a String array, in order, of valid season/phase combinations.

E.g.: Spring Move, or Spring Adjustment, etc.


readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Reconstitute a Phase object

Throws:
java.io.ObjectStreamException


Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.