- getTraceHandler().trace("", 4);
- }
- }
-
- /**
- * Start a bridge between 2 servers.
- *
- * @param args
- * an array containing:
- * <ul>
- * <li>The bridge name</li>
- * <li>The bridge port</li>
- * <li>TRUE for a ssl bridge, FALSE for plain text</li>
- * <li>The forward server host</li>
- * <li>The forward server port</li>
- * <li>TRUE for a ssl forward server, FALSE for plain text</li>
- * <li>(optional) a trace level</li>
- * </ul>
- */
- public static void main(String[] args) {
- final TraceHandler tracer = new TraceHandler(true, false, 0);
- try {
- if (args.length < 6) {
- tracer.error("Invalid syntax.\n"
- + "Syntax: [name] [port] [ssl] [fhost] [fport] [fssl] ([trace level])\n"
- + "\tname: the bridge name\n"
- + "\tport: the bridge port\n"
- + "\tssl: TRUE for an SSL bridge, FALSE for plain text\n"
- + "\tfhost: the forward server host\n"
- + "\tfport: the forward server port\n"
- + "\tfssl: TRUE for an SSL forward server, FALSE for plain text\n"
- + "\ttrace level: the optional trace level (default is 1)\n");
- return;
- }
-
- int i = 0;
- String name = args[i++];
- int port = Integer.parseInt(args[i++]);
- boolean ssl = Boolean.parseBoolean(args[i++]);
- String fhost = args[i++];
- int fport = Integer.parseInt(args[i++]);
- boolean fssl = Boolean.parseBoolean(args[i++]);
-
- int traceLevel = 1;
- if (args.length > 6) {
- traceLevel = Integer.parseInt(args[i++]);
+ InputStream stream = new ByteArrayInputStream(
+ StringUtils.getBytes(data));
+ try {
+ Object obj = new Importer().read(stream).getValue();
+ if (obj == null) {
+ getTraceHandler().trace("NULL", 2);
+ getTraceHandler().trace("NULL", 3);
+ getTraceHandler().trace("NULL", 4);
+ } else {
+ if (obj.getClass().isArray()) {
+ getTraceHandler().trace(
+ "(" + obj.getClass() + ") with "
+ + Array.getLength(obj)
+ + "element(s)", 3);
+ } else {
+ getTraceHandler().trace("(" + obj.getClass() + ")",
+ 2);
+ }
+ getTraceHandler().trace("" + obj.toString(), 3);
+ getTraceHandler().trace(data, 4);
+ }
+ } finally {
+ stream.close();
+ }
+ } catch (NoSuchMethodException e) {
+ getTraceHandler().trace("(not an object)", 2);
+ getTraceHandler().trace(data, 3);
+ getTraceHandler().trace("", 4);
+ } catch (NoSuchFieldException e) {
+ getTraceHandler().trace(
+ "(incompatible: " + e.getMessage() + ")", 2);
+ getTraceHandler().trace(data, 3);
+ getTraceHandler().trace("", 4);
+ } catch (ClassNotFoundException e) {
+ getTraceHandler().trace(
+ "(unknown object: " + e.getMessage() + ")", 2);
+ getTraceHandler().trace(data, 3);
+ getTraceHandler().trace("", 4);
+ } catch (Exception e) {
+ getTraceHandler().trace(
+ "(decode error: " + e.getMessage() + ")", 2);
+ getTraceHandler().trace(data, 3);
+ getTraceHandler().trace("", 4);