Class Definition

java.lang.Object
marauroa.common.game.Definition
All Implemented Interfaces:
Serializable

public class Definition extends Object implements 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
  • Field Details

    • STANDARD

      public static final byte STANDARD
      The attribute is visible and stored in database
      See Also:
      Constant Field Values
    • PRIVATE

      public static final byte PRIVATE
      The attribute is ONLY visible for owner of the object
      See Also:
      Constant Field Values
    • HIDDEN

      public static final byte HIDDEN
      The attribute is invisible and so only server related
      See Also:
      Constant Field Values
    • VOLATILE

      public static final byte VOLATILE
      The attribute should not be stored in the database
      See Also:
      Constant Field Values
  • Constructor Details

    • Definition

      public Definition()
      Constructor used for serialisation
    • Definition

      protected Definition(Definition.DefinitionClass clazz)
      creates a new definition object bases on the provided definition class
      Parameters:
      clazz - definition class
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • defineAttribute

      public static Definition defineAttribute(String name, Definition.Type type, byte flags)
      Creates an Attribute definition
      Parameters:
      name - the name of the attribute
      type - the type of the attribute
      flags - flags options.
      Returns:
      an Attribute Definition
    • defineStaticAttribute

      public static Definition defineStaticAttribute(String name, String value, byte flags)
      Creates an static attribute definition and give it a value
      Parameters:
      name - the name of the attribute
      value - the type of the attribute
      flags - flags options.
      Returns:
      an Attribute Definition
    • defineEvent

      public static Definition defineEvent(String name, byte flags)
      Creates an Event definition
      Parameters:
      name - the name of the event
      flags - flags options.
      Returns:
      an Event Definition
    • defineSlot

      public static Definition defineSlot(String name, int capacity, byte flags)
      Creates a RPSLot definition
      Parameters:
      name - the name of the slot
      capacity - the capacity of the slot
      flags - flags options.
      Returns:
      an RPSlot Definition
    • defineLink

      public static Definition defineLink(String name, byte flags)
      Creates a RPLink definition
      Parameters:
      name - the name of the slot
      flags - flags options.
      Returns:
      an RPSlot Definition
    • getCode

      public short getCode()
      Returns the code of this definition
      Returns:
      definition's code
    • getDefinitionClass

      public Definition.DefinitionClass getDefinitionClass()
      Returns the DefinitionClass
      Returns:
      DefinitionClass
    • getName

      public String getName()
      Returns the name of the definition
      Returns:
      definition's name
    • getValue

      public String getValue()
      Returns the value of a static attribute.
      Returns:
      the value of a static attribute.
    • getType

      public Definition.Type 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

      public void setName(String name)
      Sets the value name
      Parameters:
      name - definition name
    • setType

      public void setType(Definition.Type type)
      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

      public String deserialize(InputSerializer in) throws IOException
      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

      public void serialize(String value, OutputSerializer out) throws IOException
      Serializes an attribute or even whose value is value into the output serializer
      Parameters:
      value - the value of the event/attribute
      out - the output serializer
      Throws:
      IOException - if there is any problem on the serialization
    • validate

      public void validate(String value) throws IllegalArgumentException
      validates
      Parameters:
      value - the value of the event/attribute
      Throws:
      IllegalArgumentException - if there is any problem on the serialization
    • writeObject

      public void writeObject(OutputSerializer out) throws IOException
      Serialize the object into the output
      Specified by:
      writeObject in interface Serializable
      Parameters:
      out - OutputSerializer to write the object to
      Throws:
      IOException - in case of an IO-error
    • readObject

      public void readObject(InputSerializer in) throws IOException
      Fill the object from data deserialized from the serializer
      Specified by:
      readObject in interface Serializable
      Parameters:
      in - InputSerializer to read from
      Throws:
      IOException - in case of an IO-error
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object ot)
      Overrides:
      equals in class Object