KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > Util


1 package org.objectweb.fractal.julia;
2
3 import org.objectweb.fractal.api.Component;
4 import org.objectweb.fractal.api.NoSuchInterfaceException;
5 import org.objectweb.fractal.api.control.NameController;
6 import org.objectweb.fractal.api.control.SuperController;
7
8 /**
9  * Provides static utility methods related to {@link Component}.
10  */

11
12 public class Util {
13
14   private Util () {
15   }
16
17   /**
18    * Computes a string representation of the given component.
19    *
20    * @param component a component.
21    * @param buf the buffer to be used to store the result of this method.
22    */

23
24   public static void toString (
25     final Component component,
26     final StringBuffer JavaDoc buf)
27   {
28     try {
29       NameController nc =
30         (NameController)component.getFcInterface("name-controller");
31       try {
32         SuperController sc =
33           (SuperController)component.getFcInterface("super-controller");
34         Component[] superComponents = sc.getFcSuperComponents();
35         if (superComponents.length > 0) {
36           toString(superComponents[0], buf);
37         }
38       } catch (NoSuchInterfaceException ignored) {
39       }
40       buf.append('/');
41       buf.append(nc.getFcName());
42     } catch (NoSuchInterfaceException e) {
43       buf.append(component.toString());
44       return;
45     }
46   }
47 }
48
Popular Tags