Class Communicate


  • public class Communicate
    extends java.lang.Object
    This class opens a socket and contain methods for read and write to socket IS/OS.
    • Constructor Summary

      Constructors 
      Constructor Description
      Communicate​(java.lang.String host, int port)
      Constructor creates a socket on given port and saves the streams into class variables.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes a socket.
      void println​(java.lang.String line)
      Sends a line with request to agent.
      java.lang.String readResponse()
      Method that reads agent's response.
      private java.lang.String trimReadLine()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_VALUE_OK_RESULT

        public static final java.lang.String NO_VALUE_OK_RESULT
        See Also:
        Constant Field Values
      • NO_VALLUE_DONE_RESULT

        public static final java.lang.String NO_VALLUE_DONE_RESULT
        See Also:
        Constant Field Values
      • commSocket

        private java.net.Socket commSocket
      • commInput

        private java.io.BufferedReader commInput
      • commOutput

        private java.io.BufferedWriter commOutput
    • Constructor Detail

      • Communicate

        public Communicate​(java.lang.String host,
                           int port)
        Constructor creates a socket on given port and saves the streams into class variables.
        Parameters:
        host - host name
        port - port where we open the socket
    • Method Detail

      • close

        public void close()
        Closes a socket.
      • trimReadLine

        private java.lang.String trimReadLine()
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • readResponse

        public java.lang.String readResponse()
        Method that reads agent's response.
        Returns:
        "ERROR" in case of fail or corresponding bytes or class names
      • println

        public void println​(java.lang.String line)
                     throws java.io.IOException
        Sends a line with request to agent.
        Parameters:
        line - "CLASSES" or "BYTES className"
        Throws:
        java.io.IOException - if the write operation fails