public class ObjectType extends java.lang.Object implements java.io.Serializable, Marshallable
Entity
and
AOObject
objects by their basic type. ObjectTypes have
a string name and a short id. The name and id must be unique.
All plugins must use the same names and ids.
Object types may have one or more "base types". The base types
are BASE_STRUCTURE
, BASE_MOB
, and BASE_PLAYER
.
Methods isStructure()
, isMob()
, and isPlayer()
reflect the base type.
Applications should use the ObjectTypes defined in ObjectTypes
rather than defining their own.
Applications create ObjectTypes using intern()
.
Multiple calls to intern() in the same process with the same
parameters will return the same instance.
Modifier and Type | Class and Description |
---|---|
static class |
ObjectType.PersistenceDelegate
Internal use only.
|
Modifier and Type | Field and Description |
---|---|
static int |
BASE_MOB
Mob base type.
|
static int |
BASE_PLAYER
Player base type.
|
static int |
BASE_STRUCTURE
Structure base type.
|
Constructor and Description |
---|
ObjectType()
No-arg constructor required for marshalling.
|
Modifier and Type | Method and Description |
---|---|
int |
getBaseType()
Get the object base type.
|
static ObjectType |
getObjectType(short typeId)
Get object type.
|
static ObjectType |
getObjectType(java.lang.String typeName)
Get object type.
|
short |
getTypeId()
Get the object type number.
|
java.lang.String |
getTypeName()
Get the object type name.
|
static ObjectType |
intern(short typeId,
java.lang.String typeName)
Get or create an ObjectType.
|
static ObjectType |
intern(short typeId,
java.lang.String typeName,
int baseType)
Get or create an ObjectType.
|
boolean |
isA(ObjectType objectType)
True if object type is a given object type, or object base type 'is a' given ObjectType.
|
boolean |
isMob()
True if object base type is a mob.
|
boolean |
isPlayer()
True if object base type is a player.
|
boolean |
isStructure()
True if object base type is a structure.
|
void |
marshalObject(AOByteBuffer buf)
Internal use only.
|
java.lang.String |
toString() |
java.lang.Object |
unmarshalObject(AOByteBuffer buf)
Internal use only.
|
public static final int BASE_STRUCTURE
public static final int BASE_MOB
public static final int BASE_PLAYER
public static ObjectType intern(short typeId, java.lang.String typeName)
typeId
- Unique type number.typeName
- Unique type name.public static ObjectType intern(short typeId, java.lang.String typeName, int baseType)
typeId
- Unique type number.typeName
- Unique type name.baseType
- Bitwise OR of BASE_STRUCTURE
, BASE_MOB
, and BASE_PLAYER
.public static ObjectType getObjectType(short typeId)
typeId
does not exist (use intern() to
create the object type.)public static ObjectType getObjectType(java.lang.String typeName)
typeName
does not exist (use intern() to
create the object type.)public java.lang.String toString()
toString
in class java.lang.Object
public short getTypeId()
public java.lang.String getTypeName()
public boolean isStructure()
public boolean isA(ObjectType objectType)
public boolean isMob()
public boolean isPlayer()
public int getBaseType()
public void marshalObject(AOByteBuffer buf)
marshalObject
in interface Marshallable
buf
- The byte bufferpublic java.lang.Object unmarshalObject(AOByteBuffer buf)
unmarshalObject
in interface Marshallable