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
Modifier and TypeClassDescriptionstatic class
This enum determine to which entity the definition belogs: either attributes, event or slotstatic class
Define the possible types of an attribute or event -
Field Summary
Modifier and TypeFieldDescriptionstatic byte
The attribute is invisible and so only server relatedstatic byte
The attribute is ONLY visible for owner of the objectstatic byte
The attribute is visible and stored in databasestatic byte
The attribute should not be stored in the database -
Constructor Summary
ModifierConstructorDescriptionConstructor used for serialisationprotected
Definition(Definition.DefinitionClass clazz)
creates a new definition object bases on the provided definition class -
Method Summary
Modifier and TypeMethodDescriptionstatic Definition
defineAttribute(String name, Definition.Type type, byte flags)
Creates an Attribute definitionstatic Definition
defineEvent(String name, byte flags)
Creates an Event definitionstatic Definition
defineLink(String name, byte flags)
Creates a RPLink definitionstatic Definition
defineSlot(String name, int capacity, byte flags)
Creates a RPSLot definitionstatic Definition
defineStaticAttribute(String name, String value, byte flags)
Creates an static attribute definition and give it a valueDeserializes an attribute or event from the input serializerboolean
int
Returns the capacity of the definitionshort
getCode()
Returns the code of this definitionReturns the DefinitionClassbyte
getFlags()
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.int
hashCode()
boolean
isHidden()
Returns true if the attribute is Hidden.boolean
Returns true if the attribute is private.boolean
Return the storability of the attribute whose name is name for this rpclassboolean
Returns if this definition is visible ( it is not hidden nor private )void
Fill the object from data deserialized from the serializervoid
serialize(String value, OutputSerializer out)
Serializes an attribute or even whose value is value into the output serializervoid
setCapacity(byte capacity)
Sets the slot capacity.void
setFlags(byte flags)
Set the definition flags: VOLATILE, HIDDEN, PRIVATE, ...void
Sets the value namevoid
setType(Definition.Type type)
Sets the type of the definition: BYTE, INT, SHORT, STRING, ...toString()
void
validatesvoid
writeObject(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:
writeObject
in 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:
readObject
in interfaceSerializable
- Parameters:
in
- InputSerializer to read from- Throws:
IOException
- in case of an IO-error
-
hashCode
public int hashCode() -
equals
-