dip.world
Class Coast

java.lang.Object
  extended bydip.world.Coast
All Implemented Interfaces:
java.io.Serializable

public final class Coast
extends java.lang.Object
implements java.io.Serializable

Coasts are essential to determining connectivity between Provinces.

Coast constants should be used.

See Also:
Serialized Form

Field Summary
static Coast[] ALL_COASTS
          Array of the 6 main coast types (NONE, SINGLE, NORTH, SOUTH, WEST, EAST) Warning: this should not be mutated.
static Coast[] ANY_DIRECTIONAL
          Array of directional coasts (NORTH, SOUTH, WEST, EAST) Warning: this should not be mutated.
static Coast[] ANY_SEA
          Array of sea coasts (SINGLE, NORTH, SOUTH, WEST, EAST) Warning: this should not be mutated.
static Coast EAST
          Constant indicating East Coast
static Coast LAND
          Alias for Coast.NONE
static Coast NONE
          Constant indicating no coast (Army movement)
static Coast NORTH
          Constant indicating North Coast
static Coast[] NOT_DISPLAYED
          Array of Coasts that are not typically displayed Warning: this should not be mutated.
static Coast SEA
          Alias for Coast.SINGLE
static Coast SINGLE
          Constant indicating a single Coast (for fleets in coastal land areas, or sea-only provinces)
static Coast SOUTH
          Constant indicating South Coast
static Coast TOUCHING
          Alias for Coast.WING
static Coast UNDEFINED
          Constant indicated an Undefined coast
static Coast WEST
          Constant indicating West Coast
static Coast WING
          Constant indicating Wing coast (for Wing movement)
 
Method Summary
 java.lang.String getAbbreviation()
          Returns the abbreviated coast name (e.g., "nc")
static Coast getCoast(int idx)
          Gets the Coast corresponding to an index; null if index is out of range.
 int getIndex()
          Gets the index of a Coast.
 java.lang.String getName()
          Returns the full name (long name) of a coast; e.g., "North Coast"
static java.lang.String getProvinceName(java.lang.String input)
          Returns the Province name upto the first Coast seperator character ('-', '/', or '\'); Parentheses are not supported.
 int hashCode()
          Implementation of Object.hashCode()
 boolean isDirectional()
          Returns true if coast is one of Coast.NORTH, Coast.SOUTH, Coast.WEST, or Coast.EAST
static boolean isDisplayable(Coast coast)
          Returns if this Coast is typically displayed
static java.lang.String normalize(java.lang.String input)
          Normalizes coasts to standard format "/xx".
static Coast parse(java.lang.String text)
          Parses the coast from a text token.
protected  java.lang.Object readResolve()
          Assigns serialized objects to a single constant reference
 java.lang.String toString()
          Returns the full name of the coast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEFINED

public static final Coast UNDEFINED
Constant indicated an Undefined coast


WING

public static final Coast WING
Constant indicating Wing coast (for Wing movement)


NONE

public static final Coast NONE
Constant indicating no coast (Army movement)


SINGLE

public static final Coast SINGLE
Constant indicating a single Coast (for fleets in coastal land areas, or sea-only provinces)


NORTH

public static final Coast NORTH
Constant indicating North Coast


SOUTH

public static final Coast SOUTH
Constant indicating South Coast


WEST

public static final Coast WEST
Constant indicating West Coast


EAST

public static final Coast EAST
Constant indicating East Coast


TOUCHING

public static final Coast TOUCHING
Alias for Coast.WING


LAND

public static final Coast LAND
Alias for Coast.NONE


SEA

public static final Coast SEA
Alias for Coast.SINGLE


NOT_DISPLAYED

public static final Coast[] NOT_DISPLAYED
Array of Coasts that are not typically displayed Warning: this should not be mutated.


ALL_COASTS

public static final Coast[] ALL_COASTS
Array of the 6 main coast types (NONE, SINGLE, NORTH, SOUTH, WEST, EAST) Warning: this should not be mutated.


ANY_SEA

public static final Coast[] ANY_SEA
Array of sea coasts (SINGLE, NORTH, SOUTH, WEST, EAST) Warning: this should not be mutated.


ANY_DIRECTIONAL

public static final Coast[] ANY_DIRECTIONAL
Array of directional coasts (NORTH, SOUTH, WEST, EAST) Warning: this should not be mutated.

Method Detail

getName

public java.lang.String getName()
Returns the full name (long name) of a coast; e.g., "North Coast"


getAbbreviation

public java.lang.String getAbbreviation()
Returns the abbreviated coast name (e.g., "nc")


getIndex

public int getIndex()
Gets the index of a Coast. Indices are >= 0.


getCoast

public static Coast getCoast(int idx)
Gets the Coast corresponding to an index; null if index is out of range.


toString

public java.lang.String toString()
Returns the full name of the coast


isDisplayable

public static boolean isDisplayable(Coast coast)
Returns if this Coast is typically displayed


parse

public static Coast parse(java.lang.String text)
Parses the coast from a text token.

Given a text token such as "spa-sc" or "spa/nc", Returns the Coast constant. Coasts must begin with a '/', '-', or '\'; parenthetical notation e.g., "(nc)" is not supported.

This method never returns null; for nonexistent or unparsable coasts, Coast.UNDEFINED is returned.


getProvinceName

public static java.lang.String getProvinceName(java.lang.String input)
Returns the Province name upto the first Coast seperator character ('-', '/', or '\'); Parentheses are not supported.


normalize

public static java.lang.String normalize(java.lang.String input)
                                  throws OrderException
Normalizes coasts to standard format "/xx".

The following applies:

                a) input must be lower-case
                b) normalizes:
                                axy     where a = "/" "\" or "-"
                                x       where x = any alphanumeric [but is later checked]; a "." may follow
                                y       where y = "c" or (if x="m", "v"); a "." my follow
                c) parenthetical coasts
                        coalesces preceding spaces (before parenthesis), so
                        "stp(sc)", "stp( sc)", "stp(.s.c.)", "stp (sc)", and "stp    (sc)" all would become "stp/sc"
                        coast depends upon FIRST character
                        stp(qoieru)    ==> invalid!  
	

An OrderException is thrown if the coast is not recognized. The OrderException will contain the invalid coast text only.

Bug note: the following "xxx-n.c." will be converted to "xxx-nc ." Note the extra period.

Throws:
OrderException

isDirectional

public boolean isDirectional()
Returns true if coast is one of Coast.NORTH, Coast.SOUTH, Coast.WEST, or Coast.EAST


hashCode

public int hashCode()
Implementation of Object.hashCode()


readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Assigns serialized objects to a single constant reference

Throws:
java.io.ObjectStreamException


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