java/ch/wlkl/wsm/Format.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.wlkl.wsm;

/**
 *
 * @author walter
 */
interface Format {

    /**
     * if this Format directly formats e return -1, otherwise return the
     * FormatIndex to recursively format e one level deeper
     *
     * @param f the Formatter doing the format
     * @param i the format index 0 for direct format of e by f or first choice
     * >=1 for subFormat i of this or chc number i
     * @param e the Formattable that should be formatted
     * @return <= 0: no more retries
     * > 0: format index for next chc to try
     */
    abstract public int format(Formatter f, int i, Formattable e);

    /**
     * return the code
     *
     * @return two dimension array of Codes [0] abstract Grammar for {begin, ele
     * Index 1...; end} [1..] lexx Grammar variants
     */
    abstract public String[][] code();
}