HelpToString.java
Created with JBuilder

package listFW.visitor;

import listFW.*;

/**
 * Helper visitor to compute the String representation of a host that is the
 * rest of an enclosing list.
 * @author D.X. Nguyen
 */
public class HelpToString implements IListAlgo {
    public static final HelpToString Singleton = new HelpToString ();

    private HelpToString() {
    }

    /**
    * Returns ")" because we are the end of the list here.
    * @param host  not used
    * @param input not used
    * @return String
    */
    public Object emptyCase (IEmptyList host, Object input) {
        return ")";
    }

    /**
    * Concatenates a space with the host's first and the recursive computation
    * of the String representation of the host's rest.
    * @param host a non-empty list that is the rest of an enclosing list.
    * @param input not used
    * @return String
    */
    public Object nonEmptyCase (INEList host, Object input) {
        return " " + host.getFirst() + host.getRest().execute(this, null);
    }
}



HelpToString.java
Created with JBuilder