Class SCMPMessage

java.lang.Object
org.serviceconnector.scmp.SCMPMessage
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SCMPCompositeReceiver, SCMPCompositeSender, SCMPKeepAlive, SCMPMessageFault, SCMPPart

public class SCMPMessage extends Object implements Serializable
Service Connector Message Protocol. Data container for one message.
Author:
JTraber
See Also:
  • Field Details

    • SC_VERSION

      public static final SCVersion SC_VERSION
      The actual SC_VERSION.
  • Constructor Details

    • SCMPMessage

      public SCMPMessage(SCMPVersion scmpVersion)
      Instantiates a new SCMP.
      Parameters:
      scmpVersion - the SCMP version of current message
    • SCMPMessage

      public SCMPMessage(SCMPMessage toCopyObject)
      Instantiates a new SCMP. Copy constructor. Make a copy of given object. Pay attention the body of type object is not properly copied here. Copying an instance of type object is not possible. SCMPVersion and SCVersion are not copied as well knowing that runtime changes are forbidden anyway.
      Parameters:
      toCopyObject - the object to be copied
    • SCMPMessage

      public SCMPMessage(SCMPVersion scmpVersion, Map<String,String> baseHeader)
      Instantiates a new SCMP message with given message key.
      Parameters:
      scmpVersion - the SCMP version of current message
      baseHeader - the base header
  • Method Details

    • getSCMPVersion

      public SCMPVersion getSCMPVersion()
      Gets the SCMP version.
      Returns:
      the SCMP version
    • setMessageType

      public void setMessageType(SCMPMsgType messageType)
      Sets the message type.
      Parameters:
      messageType - the new message type
    • setMessageType

      public void setMessageType(String messageTypeValue)
      Sets the message type.
      Parameters:
      messageTypeValue - the new message type
    • getMessageType

      public String getMessageType()
      Gets the message type.
      Returns:
      the message type
    • getMessageSequenceNr

      public String getMessageSequenceNr()
      Gets the message sequence number.
      Returns:
      the message sequence number
    • getCacheId

      public String getCacheId()
      Gets the cache id.
      Returns:
      the cache id
    • setCacheId

      public void setCacheId(String cacheId)
      Sets the cache id.
      Parameters:
      cacheId - the new cache id
    • isCached

      public boolean isCached()
      Checks if is cached.
      Returns:
      true, if is cached
    • setCached

      public void setCached()
      Sets the cached flag if messages is has been cached.
    • isFault

      public boolean isFault()
      Checks if the message is a fault.
      Returns:
      true, if is fault
    • isPart

      public boolean isPart()
      Checks if the message is a part.
      Returns:
      true, if is part
    • isPollRequest

      public boolean isPollRequest()
      Checks if the message is a poll request in large message sequence.
      Returns:
      true, if is poll
    • isKeepAlive

      public boolean isKeepAlive()
      Checks if is keep alive.
      Returns:
      true, if is keep alive
    • isBodyOffset

      public boolean isBodyOffset()
      Is true if there is an offset to use when accessing body data.
      Returns:
      true, if there is body offset
    • getBodyOffset

      public int getBodyOffset()
      Gets the body offset.
      Returns:
      the body offset
    • isComposite

      public boolean isComposite()
      Checks if the message is a composite.
      Returns:
      true, if is composite
    • isByteArray

      public boolean isByteArray()
      Checks if the body is of type byte array.
      Returns:
      true, if body is of type byte array
    • isString

      public boolean isString()
      Checks if the body is of type string.
      Returns:
      true, if body is of type string
    • isLargeMessage

      public boolean isLargeMessage()
      Checks if this is a large message.
      Returns:
      true, if is a large message
    • isCompressed

      public boolean isCompressed()
      Checks if is compressed.
      Returns:
      true, if is compressed
    • removeHeader

      public void removeHeader(String name)
      Removes the attribute with the specified name from the header.
      Parameters:
      name - the name
    • removeHeader

      public void removeHeader(SCMPHeaderAttributeKey headerType)
      Removes the attribute with the specified type from the header.
      Parameters:
      headerType - the header type
    • setHeader

      public void setHeader(String attributeName, String attributeValue)
      Sets the header attribute by name and value.
      Parameters:
      attributeName - the name of the attribute
      attributeValue - the value of the attribute
    • setHeader

      public void setHeader(SCMPHeaderAttributeKey headerType, String attributeValue)
      Sets the header attribute by type and value.
      Parameters:
      headerType - the header type
      attributeValue - the value
    • setHeaderCheckNull

      public void setHeaderCheckNull(SCMPHeaderAttributeKey headerType, String attributeValue)
      Sets the header check null value. If value is null header is not set!
      Parameters:
      headerType - the header type
      attributeValue - the attribute value
    • setHeader

      public void setHeader(SCMPHeaderAttributeKey headerType, boolean attributeValue)
      Sets the header attribute by type and value.
      Parameters:
      headerType - the header attribute
      attributeValue - the value
    • setHeader

      public void setHeader(SCMPHeaderAttributeKey headerType, int attributeValue)
      Sets the header by type and value.
      Parameters:
      headerType - the header attribute
      attributeValue - the value
    • setHeader

      public void setHeader(SCMPHeaderAttributeKey headerType, long attributeValue)
      Sets the header by type and value.
      Parameters:
      headerType - the header attribute
      attributeValue - the value
    • setHeader

      public void setHeader(SCMPMessage sourceMessage)
      Copies the header from another message.
      Parameters:
      sourceMessage - the message with header header to be copied
    • setHeader

      public void setHeader(SCMPMessage sourceMessage, SCMPHeaderAttributeKey headerType)
      Copies a header attribute from another message.
      Parameters:
      sourceMessage - the source message from which header header should be copied
      headerType - the key to be copied. If the key does not exist in the source message, attribute is not set.
    • getHeader

      public String getHeader(String attributeName)
      Returns the value of the header attribute.
      Parameters:
      attributeName - the name of the attribute
      Returns:
      the attribute value
    • getHeader

      public String getHeader(SCMPHeaderAttributeKey headerType)
      Returns the value of the header attribute.
      Parameters:
      headerType - the header type
      Returns:
      the attribute value
    • getHeaderBoolean

      public Boolean getHeaderBoolean(SCMPHeaderAttributeKey headerType)
      Returns the boolean value of the header attribute. Be careful if header field is not set - null is returned and if you unbox return value automatically into boolean than a NullPointerException will be thrown.
      Parameters:
      headerType - the header attribute
      Returns:
      the boolean attribute value
    • getHeaderFlag

      public boolean getHeaderFlag(SCMPHeaderAttributeKey headerKey)
      Gets the header flag. Gets a header flag if header contains header key. Value totally irrelevant in this case.
      Parameters:
      headerKey - the header key
      Returns:
      the header flag
    • getHeaderInt

      public Integer getHeaderInt(SCMPHeaderAttributeKey headerType)
      Returns the integer value of the header attribute.
      Parameters:
      headerType - the header attribute
      Returns:
      the integer attribute value
    • getSessionId

      public String getSessionId()
      Gets the session id.
      Returns:
      the session id
    • getServiceName

      public String getServiceName()
      Gets the service name.
      Returns:
      the service name
    • setServiceName

      public void setServiceName(String serviceName)
      Sets the service name.
      Parameters:
      serviceName - the new service name
    • setSessionId

      public void setSessionId(String sessionId)
      Sets the session id.
      Parameters:
      sessionId - the new session id
    • getHeader

      public Map<String,String> getHeader()
      Gets the whole header.
      Returns:
      the whole header
    • setHeader

      public void setHeader(Map<String,String> header)
      Sets the whole header.
      Parameters:
      header - the whole header
    • setHeaderFlag

      public void setHeaderFlag(SCMPHeaderAttributeKey headerKey)
      Sets the header flag. Sets a headerKey with value null.
      Parameters:
      headerKey - the new header flag
    • setBody

      public void setBody(Object body)
      Sets the body.
      Parameters:
      body - the new body
    • setBody

      public void setBody(byte[] buffer, int offset, int length)
      Sets the body.
      Parameters:
      buffer - the buffer
      offset - the offset
      length - the length
    • getBodyType

      public SCMPBodyType getBodyType()
      Gets the body type.
      Returns:
      the body type
    • getBody

      public Object getBody()
      Gets the body.
      Returns:
      the body
    • getBodyLength

      public int getBodyLength()
      Gets the body length.
      Returns:
      the body length
    • isReqCompleteAfterMarshallingPart

      public boolean isReqCompleteAfterMarshallingPart()
      Checks if is request. Marks if this SCMP is a complete or completing part of a request. Last part SCMP of a request returns true.
      Returns:
      true, if is final request part
    • setIsReqCompleteAfterMarshallingPart

      public void setIsReqCompleteAfterMarshallingPart(boolean isReqCompleteAfterMarshallingPart)
      Sets the checks if is request complete after marshalling part.
      Parameters:
      isReqCompleteAfterMarshallingPart - the new checks if is request complete after marshalling part
    • isReply

      public boolean isReply()
      Checks if this message is a reply.
      Returns:
      true, if is reply
    • setIsReply

      public void setIsReply(boolean isReply)
      Sets the the reply flag in the message.
      Parameters:
      isReply - the reply flag value
    • getPartSize

      public int getPartSize()
      Returns:
      the size of the parts in which message will be broken when it is large
    • setPartSize

      public void setPartSize(int partSize)
      Parameters:
      partSize - the size in which message will be broken when it is large check done in SCMessage
    • getHttpUrlFileQualifier

      public String getHttpUrlFileQualifier()
      Returns:
      the HTTP URL qualifier.
    • setHttpUrlFileQualifier

      public void setHttpUrlFileQualifier(String httpUrlFileQualifier)
      Parameters:
      httpUrlFileQualifier - the HTTP URL file qualifier which is added to the URL when communicating to a HTTP server.
    • toString

      public String toString()
      Overrides:
      toString in class Object