Package com.inesm.KeyManager.model
Class Message
java.lang.Object
com.inesm.KeyManager.model.Message
- All Implemented Interfaces:
NetworkResource,Resource,Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intFields inherited from interface com.inesm.KeyManager.model.NetworkResource
DIRECT_MODE, HIERARCHICAL_MODE -
Constructor Summary
ConstructorsConstructorDescriptionMessage()Message(long messageID, int operationID, String source, String destination, String issuerCitizenCard, String issuerFullname, String target, int status, String current, LocalDateTime time, SharedResource data, int mode, long groupID) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserialize(String data) Deserializes the resource from a data string generated by theResource.serialize()method.getData()Calls theResource.serialize()method for the Resource object inside the data field.Gets the destination of the network resource.longlongintgetMode()Gets the distribution mode of the network resource.Gets the nextHop of the network resource.intGets the station resource identifier.intbooleanChecks if the network resource is aMessage.booleanChecks if network resource is aReceipt.voidUpdates the fields in the current object instance with the ones from another object.Serializes a resource into a string.voidsetCreated(LocalDateTime created) voidsetCurrent(String current) voidsetData(SharedResource data) voidsetDataAsString(String string) Gets a string serialization of an object an deserializes it into to a java object.voidsetDestination(String destination) voidsetGroupID(long groupID) voidsetIssuerCitizenCard(String issuerCitizenCard) voidsetIssuerFullname(String issuerFullname) voidsetMessageID(long messageID) voidsetMode(int mode) voidsetNextHop(String nextHop) voidsetOperationID(int operationID) voidsetOperationName(String operationName) voidsetSignature(String signature) voidvoidsetStatus(int status) voidvoidsetTextData(String textData) voidsetUpdated(LocalDateTime updated) toString()
-
Field Details
-
STATUS_ACCEPTED
public static final int STATUS_ACCEPTED- See Also:
-
STATUS_WAITING
public static final int STATUS_WAITING- See Also:
-
STATUS_FAILURE
public static final int STATUS_FAILURE- See Also:
-
STATUS_INVALID
public static final int STATUS_INVALID- See Also:
-
STATUS_TRANSFORMED
public static final int STATUS_TRANSFORMED- See Also:
-
STATUS_PENDING
public static final int STATUS_PENDING- See Also:
-
STATUS_MANUAL
public static final int STATUS_MANUAL- See Also:
-
UNDEFINED
public static final int UNDEFINED- See Also:
-
-
Constructor Details
-
Message
public Message()
-
-
Method Details
-
toString
-
getDataAsString
Calls theResource.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 operationInvalidFormatException- if a deserialization error occurred
-
patch
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
Description copied from interface:ResourceSerializes a resource into a string.- Specified by:
serializein interfaceResource- Returns:
- the string representing the serialization of the resource.
- Throws:
IOException- if an error occurred during serialization
-
deserialize
Description copied from interface:ResourceDeserializes the resource from a data string generated by theResource.serialize()method.- Specified by:
deserializein interfaceResource- Parameters:
data- the serialized data as a string- Throws:
IOException- if an error occurred during the serialization processClassNotFoundException- if its was not possible to load the class data, or the class data was not found
-
getResourceID
Description copied from interface:ResourceGets the station resource identifier.- Specified by:
getResourceIDin interfaceResource- 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
-
setOperationName
-
getSource
-
setSource
-
getDestination
Description copied from interface:NetworkResourceGets the destination of the network resource.- Specified by:
getDestinationin interfaceNetworkResource- Returns:
- the path of the destination station
-
setDestination
-
getIssuerCitizenCard
-
setIssuerCitizenCard
-
getIssuerFullname
-
setIssuerFullname
-
getTarget
-
setTarget
-
getStatus
public int getStatus() -
setStatus
public void setStatus(int status) -
getCurrent
-
setCurrent
-
getCreated
-
setCreated
-
getUpdated
-
setUpdated
-
getData
-
getMode
public int getMode()Description copied from interface:NetworkResourceGets the distribution mode of the network resource.- Specified by:
getModein interfaceNetworkResource- Returns:
- the distribution mode flag between
NetworkResource.DIRECT_MODEandNetworkResource.HIERARCHICAL_MODE.
-
setMode
public void setMode(int mode) -
getGroupID
public long getGroupID() -
setGroupID
public void setGroupID(long groupID) -
getSignature
-
setSignature
-
getNextHop
Description copied from interface:NetworkResourceGets the nextHop of the network resource.- Specified by:
getNextHopin interfaceNetworkResource- Returns:
- the path of the next-hop station
-
setNextHop
-
getTextData
-
setTextData
-
isMessage
public boolean isMessage()Description copied from interface:NetworkResourceChecks if the network resource is aMessage.- Specified by:
isMessagein interfaceNetworkResource- Returns:
- true if it is, false otherwise
-
isReceipt
public boolean isReceipt()Description copied from interface:NetworkResourceChecks if network resource is aReceipt.- Specified by:
isReceiptin interfaceNetworkResource- Returns:
- true if it is, false otherwise
-