NameChanger.java

public class NameChanger implements ControlObject
{
    private String newname;

    // XStream needs a default constructor.
    public NameChanger()
    {
        this("Bozoid");
    }

    public NameChanger(String newname)
    {
        this.newname = newname;
    }

    public void doFunction(Object o)
    {
        System.out.println(this + ".doFunction(" + o + ")");
        if (o instanceof Nameable)
            ((Nameable)o).rename(newname);
    }

    public String toString()
    {
        return "NameChanger[newname='" + newname + "']";
    }
}