Пример #1
0
 public static Command parse(String line) {
   String[] tokens = line.split(",");
   Command cmd = new Command();
   Action action = Action.valueOf(tokens[0]);
   cmd.setAction(action);
   cmd.setChannel(tokens[1]);
   ChannelType type = ChannelType.translate(tokens[2]);
   cmd.setType(type);
   if (!"null".equals(tokens[3])) {
     String[] hostPort = tokens[3].split(":");
     int port = Integer.parseInt(hostPort[1]);
     InetSocketAddress addr = new InetSocketAddress(hostPort[0], port);
     cmd.setAddress(addr);
   }
   int payloadSize = Integer.parseInt(tokens[4]);
   cmd.setPayloadSize(payloadSize);
   boolean isNeedPlayback = Boolean.parseBoolean(tokens[5]);
   cmd.setNeedsPlayback(isNeedPlayback);
   return cmd;
 }