Package marauroa.common.game
Class Definition
java.lang.Object
marauroa.common.game.Definition
- All Implemented Interfaces:
Serializable
This class stores the definition of an attributes, event or rpslot. This
definition contains:
- code used as index
- name
- type of the attribute or event.
It must be one of the following:
- STRING It is a 255 characters long string.
- LONG_STRING It is a 65536 characters long string.
- VERY_LONG_STRING It is 2^32 characters string. Handle this one with care.
- BYTE A 8 bits integer.
- SHORT A 16 bits integer
- INT A 32 bits integer
- LONG A 64 bits integer
- FLAG A value that is set or not set.
- capacity of the slot
- flags to decide the visibility of the atttribute, event or slot. It must be one of the
following:
- STANDARD It is an attribute that it is storable and visible.
- PRIVATE It is an attribute that only owner can know about.
- HIDDEN It is an attribute that none knows about.
- VOLATILE It is an attribute that it is not stored at persistence storage.
- Author:
- miguel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis enum determine to which entity the definition belogs: either attributes, event or slotstatic classDefine the possible types of an attribute or event -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic byteThe attribute is invisible and so only server relatedstatic byteThe attribute is ONLY visible for owner of the objectstatic byteThe attribute is visible and stored in databasestatic byteThe attribute should not be stored in the database -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor used for serialisationprotectedDefinition(Definition.DefinitionClass clazz)creates a new definition object bases on the provided definition class -
Method Summary
Modifier and TypeMethodDescriptionstatic DefinitiondefineAttribute(String name, Definition.Type type, byte flags)Creates an Attribute definitionstatic DefinitiondefineEvent(String name, byte flags)Creates an Event definitionstatic DefinitiondefineLink(String name, byte flags)Creates a RPLink definitionstatic DefinitiondefineSlot(String name, int capacity, byte flags)Creates a RPSLot definitionstatic DefinitiondefineStaticAttribute(String name, String value, byte flags)Creates an static attribute definition and give it a valueDeserializes an attribute or event from the input serializerbooleanintReturns the capacity of the definitionshortgetCode()Returns the code of this definitionReturns the DefinitionClassbytegetFlags()Returns the flags of the definitiongetName()Returns the name of the definitiongetType()Returns the type of the definitiongetValue()Returns the value of a static attribute.inthashCode()booleanisHidden()Returns true if the attribute is Hidden.booleanReturns true if the attribute is private.booleanReturn the storability of the attribute whose name is name for this rpclassbooleanReturns if this definition is visible ( it is not hidden nor private )voidFill the object from data deserialized from the serializervoidserialize(String value, OutputSerializer out)Serializes an attribute or even whose value is value into the output serializervoidsetCapacity(byte capacity)Sets the slot capacity.voidsetFlags(byte flags)Set the definition flags: VOLATILE, HIDDEN, PRIVATE, ...voidSets the value namevoidsetType(Definition.Type type)Sets the type of the definition: BYTE, INT, SHORT, STRING, ...toString()voidvalidatesvoidwriteObject(OutputSerializer out)Serialize the object into the output
-
Field Details
-
STANDARD
public static final byte STANDARDThe attribute is visible and stored in database- See Also:
- Constant Field Values
-
PRIVATE
public static final byte PRIVATEThe attribute is ONLY visible for owner of the object- See Also:
- Constant Field Values
-
HIDDEN
public static final byte HIDDENThe attribute is invisible and so only server related- See Also:
- Constant Field Values
-
VOLATILE
public static final byte VOLATILEThe attribute should not be stored in the database- See Also:
- Constant Field Values
-
-
Constructor Details
-
Definition
public Definition()Constructor used for serialisation -
Definition
creates a new definition object bases on the provided definition class- Parameters:
clazz- definition class
-
-
Method Details
-
toString
-
defineAttribute
Creates an Attribute definition- Parameters:
name- the name of the attributetype- the type of the attributeflags- flags options.- Returns:
- an Attribute Definition
-
defineStaticAttribute
Creates an static attribute definition and give it a value- Parameters:
name- the name of the attributevalue- the type of the attributeflags- flags options.- Returns:
- an Attribute Definition
-
defineEvent
Creates an Event definition- Parameters:
name- the name of the eventflags- flags options.- Returns:
- an Event Definition
-
defineSlot
Creates a RPSLot definition- Parameters:
name- the name of the slotcapacity- the capacity of the slotflags- flags options.- Returns:
- an RPSlot Definition
-
defineLink
Creates a RPLink definition- Parameters:
name- the name of the slotflags- flags options.- Returns:
- an RPSlot Definition
-
getCode
public short getCode()Returns the code of this definition- Returns:
- definition's code
-
getDefinitionClass
Returns the DefinitionClass- Returns:
- DefinitionClass
-
getName
Returns the name of the definition- Returns:
- definition's name
-
getValue
Returns the value of a static attribute.- Returns:
- the value of a static attribute.
-
getType
Returns the type of the definition- Returns:
- definition's type
-
getCapacity
public int getCapacity()Returns the capacity of the definition- Returns:
- definition's capacity
-
getFlags
public byte getFlags()Returns the flags of the definition- Returns:
- definition's flags
-
setName
Sets the value name- Parameters:
name- definition name
-
setType
Sets the type of the definition: BYTE, INT, SHORT, STRING, ...- Parameters:
type- the type of the definition
-
setCapacity
public void setCapacity(byte capacity)Sets the slot capacity. Use 0 for non limited.- Parameters:
capacity- its capacity.
-
setFlags
public void setFlags(byte flags)Set the definition flags: VOLATILE, HIDDEN, PRIVATE, ...- Parameters:
flags- the flags to set.
-
isVisible
public boolean isVisible()Returns if this definition is visible ( it is not hidden nor private )- Returns:
- true if it is visible
-
isPrivate
public boolean isPrivate()Returns true if the attribute is private.- Returns:
- true if it is private
-
isHidden
public boolean isHidden()Returns true if the attribute is Hidden.- Returns:
- true if it is hidden
-
isStorable
public boolean isStorable()Return the storability of the attribute whose name is name for this rpclass- Returns:
- true if is it storable
-
deserialize
Deserializes an attribute or event from the input serializer- Parameters:
in- the input serializer- Returns:
- the value
- Throws:
IOException- if there is any problem deserializing the object
-
serialize
Serializes an attribute or even whose value is value into the output serializer- Parameters:
value- the value of the event/attributeout- the output serializer- Throws:
IOException- if there is any problem on the serialization
-
validate
validates- Parameters:
value- the value of the event/attribute- Throws:
IllegalArgumentException- if there is any problem on the serialization
-
writeObject
Serialize the object into the output- Specified by:
writeObjectin interfaceSerializable- Parameters:
out- OutputSerializer to write the object to- Throws:
IOException- in case of an IO-error
-
readObject
Fill the object from data deserialized from the serializer- Specified by:
readObjectin interfaceSerializable- Parameters:
in- InputSerializer to read from- Throws:
IOException- in case of an IO-error
-
hashCode
public int hashCode() -
equals
-