Parse Command method in real project on the Java

Member

letha

by letha , in category: Java , 21 days ago

Parse Command method in real project on the Java 😑

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
private String parseCommand(final String value) {
    final StringBuilder s = new StringBuilder();
    for (int i = 0; i < value.length(); i++) {
      final char c = value.charAt(i);
      switch (c) {
      case 'a':
        s.append("[A]");
        break;
      case 'b':
        s.append("[B]");
        break;
      case 'c':
        s.append("[C]");
        break;
      case 'x':
        s.append("[X]");
        break;
      case 'y':
        s.append("[Y]");
        break;
      case 'z':
        s.append("[Z]");
        break;
      case 'B':
        s.append("<Back>");
        break;
      case 'F':
        s.append("<Forward>");
        break;
      case 'D':
        s.append("<Down>");
        break;
      case 'U':
        s.append("<Up>");
        break;
      case '/':
        s.append(" HOLD ");
        break;
      case '~':
        s.append(" RELEASE ");
        break;
      case '$':
        s.append(" INMOVE ");
        break;
      case '+':
        s.append(" AND ");
        break;
      case '>':
        s.append(" START ");
        break;
      default:
        s.append(c);
      }
    }
    return s.toString();
  }
}


Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers