private void routeMessage ( Message message ) { Class messageClass = message . getClass ( ) ; // Dispatch message to all specific listeners for the message class type if ( messageListenerMap . containsKey ( messageClass ) ) { dispatchMessage ( messageListenerMap . get ( messageClass ) , message ) ; } // Dispatch message to all generic listeners if ( messageListenerMap . containsKey ( Message . class ) ) { dispatchMessage ( messageListenerMap . get ( Message . class ) , message ) ; } }
Route a Message object built from data over the SerialPort communication line to a corresponding MessageListener array designed to handle and interpret the object for processing in the client code .