Class Message

java.lang.Object
com.inesm.KeyManager.model.Message
All Implemented Interfaces:
NetworkResource, Resource, Serializable

public class Message extends Object implements Serializable, NetworkResource
Represents a message containing an operation to be distributed over the network and executed upon reaching its destination.

All the getters and setters are the default ones.

Details about the meaning of each field are provided in the source code.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • toString

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

      public String getDataAsString() throws IOException
      Calls the Resource.serialize() method for the Resource object inside the data field.
      Returns:
      a string serialization of the data field
      Throws:
      IOException - if an error occurred during serialization
    • setDataAsString

      public void setDataAsString(String string) throws BadOperationIDProvidedException, InvalidFormatException
      Gets a string serialization of an object an deserializes it into to a java object.
      Parameters:
      string - the string representation of the serialized data
      Throws:
      BadOperationIDProvidedException - if the operationID provided did not map to any known operation
      InvalidFormatException - if a deserialization error occurred
    • patch

      public void patch(Message upd)
      Updates the fields in the current object instance with the ones from another object. Will only update the fields that have been modified after the initialization.
      Parameters:
      upd - the object containing the fields to update the current instance with
    • serialize

      public String serialize() throws IOException
      Description copied from interface: Resource
      Serializes a resource into a string.
      Specified by:
      serialize in interface Resource
      Returns:
      the string representing the serialization of the resource.
      Throws:
      IOException - if an error occurred during serialization
    • deserialize

      public void deserialize(String data) throws IOException, ClassNotFoundException
      Description copied from interface: Resource
      Deserializes the resource from a data string generated by the Resource.serialize() method.
      Specified by:
      deserialize in interface Resource
      Parameters:
      data - the serialized data as a string
      Throws:
      IOException - if an error occurred during the serialization process
      ClassNotFoundException - if its was not possible to load the class data, or the class data was not found
    • getResourceID

      public String getResourceID()
      Description copied from interface: Resource
      Gets the station resource identifier.
      Specified by:
      getResourceID in interface Resource
      Returns:
      a string containing the resource identifier.
    • getMessageID

      public long getMessageID()
    • setMessageID

      public void setMessageID(long messageID)
    • getOperationID

      public int getOperationID()
    • setOperationID

      public void setOperationID(int operationID)
    • getOperationName

      public String getOperationName()
    • setOperationName

      public void setOperationName(String operationName)
    • getSource

      public String getSource()
    • setSource

      public void setSource(String source)
    • getDestination

      public String getDestination()
      Description copied from interface: NetworkResource
      Gets the destination of the network resource.
      Specified by:
      getDestination in interface NetworkResource
      Returns:
      the path of the destination station
    • setDestination

      public void setDestination(String destination)
    • getIssuerCitizenCard

      public String getIssuerCitizenCard()
    • setIssuerCitizenCard

      public void setIssuerCitizenCard(String issuerCitizenCard)
    • getIssuerFullname

      public String getIssuerFullname()
    • setIssuerFullname

      public void setIssuerFullname(String issuerFullname)
    • getTarget

      public String getTarget()
    • setTarget

      public void setTarget(String target)
    • getStatus

      public int getStatus()
    • setStatus

      public void setStatus(int status)
    • getCurrent

      public String getCurrent()
    • setCurrent

      public void setCurrent(String current)
    • getCreated

      public LocalDateTime getCreated()
    • setCreated

      public void setCreated(LocalDateTime created)
    • getUpdated

      public LocalDateTime getUpdated()
    • setUpdated

      public void setUpdated(LocalDateTime updated)
    • getData

      public SharedResource getData()
    • setData

      public void setData(SharedResource data)
    • getMode

      public int getMode()
      Description copied from interface: NetworkResource
      Gets the distribution mode of the network resource.
      Specified by:
      getMode in interface NetworkResource
      Returns:
      the distribution mode flag between NetworkResource.DIRECT_MODE and NetworkResource.HIERARCHICAL_MODE.
    • setMode

      public void setMode(int mode)
    • getGroupID

      public long getGroupID()
    • setGroupID

      public void setGroupID(long groupID)
    • getSignature

      public String getSignature()
    • setSignature

      public void setSignature(String signature)
    • getNextHop

      public String getNextHop()
      Description copied from interface: NetworkResource
      Gets the nextHop of the network resource.
      Specified by:
      getNextHop in interface NetworkResource
      Returns:
      the path of the next-hop station
    • setNextHop

      public void setNextHop(String nextHop)
    • getTextData

      public String getTextData()
    • setTextData

      public void setTextData(String textData)
    • isMessage

      public boolean isMessage()
      Description copied from interface: NetworkResource
      Checks if the network resource is a Message.
      Specified by:
      isMessage in interface NetworkResource
      Returns:
      true if it is, false otherwise
    • isReceipt

      public boolean isReceipt()
      Description copied from interface: NetworkResource
      Checks if network resource is a Receipt.
      Specified by:
      isReceipt in interface NetworkResource
      Returns:
      true if it is, false otherwise