Class CipReply

    • Constructor Summary

      Constructors 
      Constructor Description
      CipReply()
      Externalizable support requires a public no-arg constructor.
      CipReply​(int service, int status, short... extraCodes)
      Construct an empty reply from scratch.
      CipReply​(int service, int status, java.nio.ByteBuffer source, short... extraCodes)
      Construct a reply with payload from scratch
      CipReply​(int service, CipException e)
      Construct an empty reply from an exception.
      CipReply​(int service, CipException e, java.nio.ByteBuffer source)
      Construct a reply from an exception plus payload
      CipReply​(int service, java.nio.ByteBuffer source)
      Construct a success reply with a payload.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int bytes()  
      static CipReply decode​(java.nio.ByteBuffer source, CipReplyConsumer callback)  
      CipException getException()  
      short[] getExtras()  
      java.nio.ByteBuffer getPayload()
      Clients typically want to decode the payload into their own field(s).
      CipRequest getRequest()  
      int getServiceCode()
      CIP messages always have a service code, either requesting or replying.
      int getStatusCode()  
      byte[] payloadBytes()
      Encode the message payload for transmission and return it as an array of bytes.
      int payloadLength()
      Subclasses must override this unless they populate the payload field.
      java.lang.String payloadString()  
      void put​(java.nio.ByteBuffer dest)
      Encode the entire message for transmission.
      void putPayload​(java.nio.ByteBuffer dest)
      Subclasses that encode fields into their payloads must override this.
      void readExternal​(java.io.ObjectInput in)
      CIP replies are read by decoding their CIP Message Router Response Format byte array.
      CipReply readResolve()  
      CipReply set​(java.nio.ByteBuffer source)  
      void setException​(CipException exc)
      Allow a response's exception to be modified, especially to support adjusting the extra words.
      void setPayload​(java.nio.ByteBuffer source)
      Subclasses should override this method to permit reparsing of protocol packets into the desired request type.
      void setRequest​(CipRequest request)  
      byte[] toBytes()
      Encode the entire message for transmission and return it as an array of bytes.
      java.lang.String toString()  
      void writeExternal​(java.io.ObjectOutput out)
      CIP replies may be placed "on the wire" in serialized form, but ancillary data like connection objects or exception tracebacks are discarded.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CipReply

        public CipReply()
        Externalizable support requires a public no-arg constructor.
      • CipReply

        public CipReply​(int service,
                        int status,
                        short... extraCodes)
        Construct an empty reply from scratch.
        Parameters:
        service -
        status -
        extraCodes -
      • CipReply

        public CipReply​(int service,
                        CipException e)
        Construct an empty reply from an exception.
        Parameters:
        service -
        e -
      • CipReply

        public CipReply​(int service,
                        CipException e,
                        java.nio.ByteBuffer source)
        Construct a reply from an exception plus payload
        Parameters:
        service -
        e -
        source -
      • CipReply

        public CipReply​(int service,
                        java.nio.ByteBuffer source)
        Construct a success reply with a payload.
        Parameters:
        service -
        source -
      • CipReply

        public CipReply​(int service,
                        int status,
                        java.nio.ByteBuffer source,
                        short... extraCodes)
        Construct a reply with payload from scratch
        Parameters:
        service -
        status -
        source -
        extraCodes -
    • Method Detail

      • set

        public CipReply set​(java.nio.ByteBuffer source)
      • setRequest

        public void setRequest​(CipRequest request)
      • getServiceCode

        public int getServiceCode()
        Description copied from interface: CipMessage
        CIP messages always have a service code, either requesting or replying. In the protocol, replies have bit seven turned on. In reply classes implementing this interface, the bit is stripped.
        Specified by:
        getServiceCode in interface CipMessage
        Returns:
        The unsigned byte service code as an integer.
      • getStatusCode

        public int getStatusCode()
      • getExtras

        public short[] getExtras()
      • put

        public void put​(java.nio.ByteBuffer dest)
        Description copied from interface: CipMessage
        Encode the entire message for transmission.
        Specified by:
        put in interface CipMessage
        Parameters:
        dest - Destination buffer for the encoded message.
      • bytes

        public int bytes()
        Specified by:
        bytes in interface CipMessage
        Returns:
        The total byte length of the encoded message.
      • setPayload

        public void setPayload​(java.nio.ByteBuffer source)
        Subclasses should override this method to permit reparsing of protocol packets into the desired request type.
        Specified by:
        setPayload in interface CipMessage
        Parameters:
        source - Source buffer containing the encoded new payload.
      • getPayload

        public java.nio.ByteBuffer getPayload()
        Clients typically want to decode the payload into their own field(s).
        Returns:
        A buffer containing the payload ready to read. Callers should deliver it to ByteBuffersSoftCache.release() if known to not be used further.
      • putPayload

        public void putPayload​(java.nio.ByteBuffer dest)
        Subclasses that encode fields into their payloads must override this.
        Specified by:
        putPayload in interface CipMessage
        Parameters:
        dest - Destination buffer for the encoded payload.
      • payloadLength

        public int payloadLength()
        Subclasses must override this unless they populate the payload field.
        Specified by:
        payloadLength in interface CipMessage
        Returns:
        The byte length of the encoded payload only.
      • payloadString

        public java.lang.String payloadString()
      • payloadBytes

        public byte[] payloadBytes()
        Description copied from interface: CipMessage
        Encode the message payload for transmission and return it as an array of bytes.
        Specified by:
        payloadBytes in interface CipMessage
        Returns:
        The encoded payload as a byte array.
      • toBytes

        public byte[] toBytes()
        Description copied from interface: CipMessage
        Encode the entire message for transmission and return it as an array of bytes.
        Specified by:
        toBytes in interface CipMessage
        Returns:
        The entire encoded message as a byte array.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        CIP replies are read by decoding their CIP Message Router Response Format byte array.
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        CIP replies may be placed "on the wire" in serialized form, but ancillary data like connection objects or exception tracebacks are discarded.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readResolve

        public CipReply readResolve()
      • setException

        public void setException​(CipException exc)
        Allow a response's exception to be modified, especially to support adjusting the extra words.
        Parameters:
        exc -