code: public static Message fromString(String messageFrame) throws InvalidMessageException {
          String prefix = null;
          String trailing = null;
  
          messageFrame = messageFrame.trim();
  
          /* Remove prefix */
          if (messageFrame.startsWith(":")) {
              int splitPoint = messageFrame.indexOf(' ');
              prefix = messageFrame.substring(1, splitPoint);
              messageFrame = messageFrame.substring(splitPoint + 1).trim();
          }
  
          /* Remove trailing part */
          int trailingPoint = messageFrame.indexOf(':');
          if (trailingPoint != -1) {
              trailing = messageFrame.substring(trailingPoint + 1);
              messageFrame = messageFrame.substring(0, trailingPoint).trim();
          }
  
          /* Remove type */
          int endTypePoint = messageFrame.indexOf(' ');
          String typeString;
          if (endTypePoint == -1) {
              typeString = messageFrame;
              messageFrame = "";
          } else {
              typeString = messageFrame.substring(0, endTypePoint);
              messageFrame = messageFrame.substring(endTypePoint + 1).trim();
          }
  
          /* Attempt a type lookup for the message type */
          MessageType type = MessageType.fromString(typeString);
          if (type == null) {
              throw new InvalidMessageException("invalid type: " + typeString);
          }
  
          /*
           * Split the remaining args into an arguments list and append the
           * trailing argument if it exists
           */
          LinkedList<String> argsList = new LinkedList<String>();
          while (messageFrame.length() > 0) {
              int nextSpace = messageFrame.indexOf(' ');
              if (nextSpace == -1) {
                  argsList.add(messageFrame);
                  break;
              } else {
                  argsList.add(messageFrame.substring(0, nextSpace));
                  messageFrame = messageFrame.substring(nextSpace + 1).trim();
              }
          }
  
          if (trailing != null) {
              argsList.add(trailing);
          }
  
          String[] args = new String[argsList.size()];
          return new Message(prefix, type, argsList.toArray(args));
      }
docs: Decode the given IRC message a string into an IRCMessage object
  
  @param messageFrame The message as read from the connection stream
  @return a new IRCMessage object
  @throws InvalidMessageException if the format of the message is
  invalid