|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.pegacat.vcf.data.ResourceType
Stores information about a particular resource type, including the name, and the category i.e. cultural trade etc.
Note that this is a slightly weird class. As resource type information may be revealed from later surveys, after earlier surveys have already used a resource, we use a single object for all instances of a resource, and that object gets shared by all users. This means that if world A uses a resource R, and later world B also uses it, but determintes that R is a lifetype, then A's copy of R gets updated when B updates it's copy of R.
To facilitate this, you can't create new ResourceTypes with 'new', you have to call getResource() which returns a handle to a resource owned by the class. Creation date: (3/06/2001 9:08:02 PM)
Field Summary | |
static java.lang.String[] |
ATMOSNAMES
names of valid atmospheres - used to detect atmospheric resources |
static int |
ATMOSPHERE
|
static int |
CULTURAL
constants defining resource types |
static int |
LIFETYPE
|
protected java.lang.String |
name
|
static int |
NORMAL
|
protected static java.util.Map |
resmap
Hash of resources by (string) names. |
protected int |
type
|
static int |
UNDETERMINED
|
Constructor Summary | |
protected |
ResourceType(java.lang.String name,
int type)
constructor - note protected, usually construction is a side effect of getResource() calls. |
Method Summary | |
int |
compareTo(java.lang.Object o)
Compares this object with the specified object for order. |
boolean |
equals(java.lang.Object obj)
Compares two ResourceTypes for equality. |
java.lang.String |
getName()
|
static ResourceType |
getResource(java.lang.String name)
get a resource if it exists, otherwise returns null. |
static ResourceType |
getResource(java.lang.String name,
int type)
get a resource if it exists, otherwise add a resource & return it. |
int |
getType()
|
int |
hashCode()
Generates a hash code for the receiver. |
static boolean |
isAtmosphere(java.lang.String resname)
returns true if the specified resource name is an atmosphere type Creation date: (3/06/2001 9:54:49 PM) |
static boolean |
isCultural(java.lang.String resname)
returns true if the specified resource name is a cultural cargo type Creation date: (3/06/2001 9:54:49 PM) |
static boolean |
isLifetype(java.lang.String resname)
returns true if the specified resource name is a (numeric) life type Creation date: (3/06/2001 9:54:49 PM) |
void |
setName(java.lang.String newName)
|
void |
setType(int newType)
|
java.lang.String |
toString()
Returns a String that represents the value of this object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CULTURAL
public static final int ATMOSPHERE
public static final int LIFETYPE
public static final int NORMAL
public static final int UNDETERMINED
public static final java.lang.String[] ATMOSNAMES
protected static java.util.Map resmap
protected java.lang.String name
protected int type
Constructor Detail |
protected ResourceType(java.lang.String name, int type)
name
- java.lang.Stringtype
- intMethod Detail |
public static ResourceType getResource(java.lang.String name)
public static ResourceType getResource(java.lang.String name, int type)
public int compareTo(java.lang.Object o)
Sorts resources by type, then by name within type.
compareTo
in interface java.lang.Comparable
ClassCastException
- if the specified object's type prevents it
from being compared to this Object.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the ResourceType to compare withHashtable
public java.lang.String getName()
public int getType()
public int hashCode()
Note hash is just on name, not type, as names should be unique
hashCode
in class java.lang.Object
Hashtable
public static boolean isAtmosphere(java.lang.String resname)
public static boolean isCultural(java.lang.String resname)
public static boolean isLifetype(java.lang.String resname)
public void setName(java.lang.String newName)
public void setType(int newType)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |