|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdip.world.Map
A Map is a list of Provinces and Powers, and methods for obtaining and parsing these Provinces and Powers.
Constructor Summary | |
protected |
Map(Power[] powerArray,
Province[] provinceArray)
Constructs a Map object. |
Method Summary | |
void |
filterPowerNames(java.lang.StringBuffer sb)
Eliminates any Power Names (e.g., "France") after the first whitespace character or colon(this is done to prevent elimination of the first power, which is required). |
Power |
getClosestPower(java.lang.String powerName)
Returns the closest Power to the given input String. |
Power |
getFirstPower(java.lang.String input)
If a power token is specified (e.g., France), returns the token as a String. |
java.lang.String |
getFirstPowerToken(java.lang.StringBuffer sb)
If a power token is specified (e.g., France), returns the token as a String. |
Power |
getPower(java.lang.String name)
Returns the power that matches name. |
Power |
getPowerMatching(java.lang.String powerName)
Returns the Power that matches the powerName. |
Power[] |
getPowers()
Returns an Array of all Powers. |
Province |
getProvince(java.lang.String name)
Returns the Province that matches name. |
Province |
getProvinceMatching(java.lang.String input)
Returns the Province that matches the input name. |
Province[] |
getProvinces()
Returns an Array of all Provinces. |
java.util.Collection |
getProvincesMatchingClosest(java.lang.String input)
Finds the Province(s) that best match the given input. |
Location |
parseLocation(java.lang.String input)
Parses text into a Location. |
void |
replaceProvinceNames(java.lang.StringBuffer sb)
Searches the input string for any province names that contain hyphens or whitespace ('-' or ' ') and replaces it with a short name. |
Province |
reverseIndex(int i)
Given an index, returns the Province to which that index corresponds. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Map(Power[] powerArray, Province[] provinceArray)
Method Detail |
public final Power[] getPowers()
public Power getPower(java.lang.String name)
The match must be exact, but is case-insensitive.
public Power getClosestPower(java.lang.String powerName)
This is different from getPowerMatching() in that this method assumes a priori that the input is a power; it therefore has looser parsing requirements. Likewise, if used on non-power tokens (e.g., Provinces), it may be sufficiently close to a Power that it will match; such improper (mis)matches would occur much LESS often with getPowerMatching().
As few as a single character can be matched (if it's unique); e.g., "E" for England.
public Power getPowerMatching(java.lang.String powerName)
This will match the closest power but requires at least 5 characters for a match.
public final Province[] getProvinces()
public Province getProvince(java.lang.String name)
The match must be exact, but is case-insensitive.
public Province getProvinceMatching(java.lang.String input)
This will match the closest power but requires at least 3 characters for a match. Ties result in no match at all. This method uses the Levenshtein distance algorithm to determine closeness.
public java.util.Collection getProvincesMatchingClosest(java.lang.String input)
This method uses the Levenshtein distance algorithm to determine closeness.
public Location parseLocation(java.lang.String input)
public void replaceProvinceNames(java.lang.StringBuffer sb)
This is a special-purpose method for Order parsing.
public void filterPowerNames(java.lang.StringBuffer sb)
NOTE: assumes StringBuffer is all lower-case.
This is a special-purpose method for Order parsing.
public java.lang.String getFirstPowerToken(java.lang.StringBuffer sb)
NOTE: assumes StringBuffer is all lower-case, is trimmed, and that power names DO NOT contain whitespace.
This is a special-purpose method for Order parsing.
examples:
France: xxx-yyy // returns "France"
Fra: xxx-yyy // returns "Fra" (assumed; it's before the colon)
Fra xxx-yyy // returns null (Fra not recognized)
xxx-yyy // returns null (xxx doesn't match a power)
public Power getFirstPower(java.lang.String input)
NOTE: assumes StringBuffer is all lower-case, is trimmed, and that power names DO NOT contain whitespace.
This is a special-purpose method for Order parsing.
examples:
France: xxx-yyy // returns "France"
Fra: xxx-yyy // returns "France" (assumed; it's before the colon)
Fra xxx-yyy // returns null (Fra not recognized)
xxx-yyy // returns null (xxx doesn't match a power)
public final Province reverseIndex(int i)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |