| 165 | } |
| 166 | |
| 167 | public static void main(String args[]) { |
| 168 | try { |
| 169 | Map<String, Byte> tagMap = new HashMap<String, Byte>(); |
| 170 | tagMap.put("a", (byte) 10); |
| 171 | tagMap.put("root", (byte) 11); |
| 172 | tagMap.put("href", (byte) 20); |
| 173 | tagMap.put("target", (byte) 21); |
| 174 | tagMap.put("name", (byte) 50); |
| 175 | tagMap.put("id", (byte) 51); |
| 176 | |
| 177 | QuestionString encoder = new QuestionString(tagMap); |
| 178 | String input; |
| 179 | byte[] output; |
| 180 | |
| 181 | input = "<root></root>"; |
| 182 | output = encoder.encode(input.toCharArray()); |
| 183 | print(output); |
| 184 | |
| 185 | input = "<root id=a />"; |
| 186 | output = encoder.encode(input.toCharArray()); |
| 187 | print(output); |
| 188 | |
| 189 | input = "<root><a href=abc id=xyz></a><a></a></root>"; |
| 190 | output = encoder.encode(input.toCharArray()); |
| 191 | print(output); |
| 192 | } catch (Exception ex) { |
| 193 | System.out.println(ex); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | public static void print(byte[] output) { |
| 198 | for (byte b : output) { |