Package marauroa.common.game
Class RPClass
java.lang.Object
marauroa.common.game.RPClass
- All Implemented Interfaces:
Serializable
An RPClass is a entity that define the attributes, events and slots of an
Object.
TODO: Creating a new RPClass does in fact add it to a global list of RPClasses.
Search for a way of making this in a different way so test added for equality works.
The idea behind RPClass is not define members as a OOP language but to save bandwidth usage by replacing these members text definitions with a short integer.
Also RPClass define a set of properties over attributes, events and slots, like being private, hidden or volatile.
It is very important that if you extend a class with isA, you completely
define the superclass before calling isA method.
For example:
RPClass foo=new RPClass("foo");
foo.add(....)
foo.add(....)
foo.add(....)
RPClass bar=new RPClass("bar");
bar.isA(foo);
bar.add(....)
bar.add(....)
- Author:
- miguel
- See Also:
Definition
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Definition.DefinitionClass clazz, String name, byte flags)Adds a definition of an event or rplink with the given flags.voidadd(Definition.DefinitionClass clazz, String name, int capacity, byte flags)Adds a definition of an slot with the given capacity and flags.voidadd(Definition.DefinitionClass clazz, String name, String value, byte flags)Adds a static definition of an attribute that will be set for any object of the class.voidadd(Definition.DefinitionClass clazz, String name, Definition.Type type)Adds a definition of an attribute with the given type and with the standard flags ( STORABLE and VISIBLE )voidadd(Definition.DefinitionClass clazz, String name, Definition.Type type, byte flags)Adds a definition of an attribute with the given type and flags.voidaddAttribute(String name, Definition.Type type)Adds a definition of an attribute with the given type and standard flags: VISIBLE and STORABLE.voidaddAttribute(String name, Definition.Type type, byte flags)Adds a definition of an attribute with the given type and flags.voidaddRPEvent(String name, byte flags)Adds a definition of an event with the given flags.voidAdds a definition of a rplink with the given flags.voidAdds a definition of an slot with the given capacity and standard flags: VISIBLE and STORABLEvoidAdds a definition of an slot with the given capacity and flags.voidaddStaticAttribute(String name, String value, byte flags)Adds a static definition of an attribute that will be set for any object of the class.voidbake()Bakes the RPClass by including copies of all the definitions of the parent class to improve performance.static voidbakeAll()Bales all RPClasses to optimize performance.booleanReturns true if two objects are exactly equalstatic RPClassReturns a default rpclass for lazy developers.shortgetCode(Definition.DefinitionClass clazz, String name)Returns the code of the attribute/event/slot whose name is name for this rpclassgetDefinition(Definition.DefinitionClass clazz, String name)Returns the definition object itself.Returns a list of all definitions of this class (not including parent classes)getName()Returns the name of the rpclassgetName(Definition.DefinitionClass clazz, short code)Returns the name of the attribute whose code is code for this rpclassgets the parent class ornullif this is a root class.static RPClassgetRPClass(String name)Returns the name rpclass from the global listbooleanhasDefinition(Definition.DefinitionClass clazz, String name)Returns true if name attributes, slot, event or rplink exists in this RPClass or any of its ancestors.inthashCode()static booleanhasRPClass(String name)Returns true if the global list contains the name rpclassvoidThis method sets the parent of this rpclassvoidThis method sets the parent of this rpclassiterator()Iterates over the global list of rpclassesvoidFill the object from data deserialized from the serializerstatic intsize()Returns the size of the rpclass global listbooleansubclassOf(String parentClass)This method returns true if it is a subclass of parentClass or if it is the class itself.toString()voidwriteObject(OutputSerializer out)Serialize the object into the output
-
Constructor Details
-
RPClass
public RPClass()Constructor Only used in serialization. -
RPClass
Constructor. It adds the RPClass to a global list of rp classes.- Parameters:
name- the class name
-
-
Method Details
-
toString
-
hasRPClass
Returns true if the global list contains the name rpclass- Parameters:
name- the class name to query- Returns:
- true if the global list contains the name rpclass
-
getRPClass
Returns the name rpclass from the global list- Parameters:
name- the name of the class- Returns:
- the class or null if it doesn't exist.
-
isA
This method sets the parent of this rpclass- Parameters:
parent- the super class of this class.
-
isA
This method sets the parent of this rpclass- Parameters:
parent- the super class of this class.
-
subclassOf
This method returns true if it is a subclass of parentClass or if it is the class itself.- Parameters:
parentClass- the super class of this class- Returns:
- true if it is a subclass of parentClass or if it is the class itself.
-
getName
Returns the name of the rpclass- Returns:
- the name of the rpclass
-
getParent
gets the parent class ornullif this is a root class.- Returns:
- RPClass or
null.
-
add
Adds a definition of an attribute with the given type and with the standard flags ( STORABLE and VISIBLE )- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definitiontype- type or capacity if it is an slot
-
add
Adds a definition of an attribute with the given type and flags.- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definitiontype- type or capacity if it is an slotflags- like visibility, storability, etc...
-
add
Adds a definition of an event or rplink with the given flags.- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definitionflags- like visibility, storability, etc...
-
add
Adds a definition of an slot with the given capacity and flags.- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definitioncapacity- capacity if it is an slotflags- like visibility, storability, etc...
-
add
Adds a static definition of an attribute that will be set for any object of the class. Its value must be set as a string, but it can be accessed later using Attributes.get method. NOTE: This type of attributes can't be set.- Parameters:
clazz- It must be DefinitionClass.STATICname- name of the static attributevalue- value of the attributeflags- like visibility, storability, etc...
-
addAttribute
Adds a definition of an attribute with the given type and flags.- Parameters:
name- name of the definitiontype- type or capacity if it is an slotflags- like visibility, storability, etc...
-
addAttribute
Adds a definition of an attribute with the given type and standard flags: VISIBLE and STORABLE.- Parameters:
name- name of the definitiontype- type or capacity if it is an slot
-
addStaticAttribute
Adds a static definition of an attribute that will be set for any object of the class. Its value must be set as a string, but it can be accessed later using Attributes.get method. NOTE: This type of attributes can't be set.- Parameters:
name- name of the static attributevalue- value of the attributeflags- like visibility, storability, etc...
-
addRPSlot
Adds a definition of an slot with the given capacity and flags.- Parameters:
name- name of the definitioncapacity- capacity if it is an slotflags- like visibility, storability, etc...
-
addRPSlot
Adds a definition of an slot with the given capacity and standard flags: VISIBLE and STORABLE- Parameters:
name- name of the definitioncapacity- capacity if it is an slot
-
addRPLink
Adds a definition of a rplink with the given flags.- Parameters:
name- name of the definitionflags- like visibility, storability, etc...
-
addRPEvent
Adds a definition of an event with the given flags.- Parameters:
name- name of the definitionflags- like visibility, storability, etc...
-
getDefinition
Returns the definition object itself.- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definition- Returns:
- this definition object or null if it is not found
-
getDefinitions
Returns a list of all definitions of this class (not including parent classes)- Returns:
- list of definitions
-
bake
public void bake()Bakes the RPClass by including copies of all the definitions of the parent class to improve performance. -
bakeAll
public static void bakeAll()Bales all RPClasses to optimize performance. -
hasDefinition
Returns true if name attributes, slot, event or rplink exists in this RPClass or any of its ancestors.- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definition- Returns:
- returns true if name attributes, slot, event or rplink exists in this RPClass or any of its ancestors.
-
getCode
Returns the code of the attribute/event/slot whose name is name for this rpclass- Parameters:
clazz- type of definition ( attribute, event or slot )name- name of the definition- Returns:
- definition code
- Throws:
SyntaxException- if the definition is not found.
-
getName
Returns the name of the attribute whose code is code for this rpclass- Parameters:
clazz- type of definition ( attribute, event or slot )code- definition code- Returns:
- name of the definition
- Throws:
SyntaxException- if the definition is not found.
-
writeObject
Serialize the object into the output- Specified by:
writeObjectin interfaceSerializable- Parameters:
out- the output serializer- Throws:
IOException- if there is any problem serializing.
-
readObject
Fill the object from data deserialized from the serializer- Specified by:
readObjectin interfaceSerializable- Parameters:
in- input serializer- Throws:
IOException- if there is any problem in the serialization.
-
iterator
Iterates over the global list of rpclasses- Returns:
- an iterator
-
size
public static int size()Returns the size of the rpclass global list- Returns:
- number of defined classes.
-
getBaseRPObjectDefault
Returns a default rpclass for lazy developers. You won't get any advantages on the engine by using it.- Returns:
- RPClass
-
hashCode
public int hashCode() -
equals
Returns true if two objects are exactly equal
-