// Path: java2word/src/main/java/word/api/interfaces/IElement.java
// public interface IElement {
// 
// 	/**
// 	 * <p>This method returns the content (XML or HTML) of the Element and the content.</p>
// 	 * <p>If you are using W2004, the return will be the XML required to generate the element.</p>
// 	 *
// 	 * <p>Important: Once you call this method, the Document value is cached an no elements can be added later.</p>
// 	 *
// 	 * @return this is the String value of the element ready to be appended/inserted in the Document.<br>
// 	 *
// 	 * <p>This is the XML that generates a <code>BreakLine</code>:</p>
// 	 * <code>
// 	 *  <w:p wsp:rsidR='008979E8' wsp:rsidRDefault='008979E8'/>
// 	 * </code>
// 	 */
// 	public String getContent();
// 
// }
// 
// Path: java2word/src/main/java/word/w2004/elements/tableElements/TableRow.java
// public class TableRow implements IElement, IFluentElementStylable<TableRowStyle>{
// 
// 	private StringBuilder txt = new StringBuilder("");
// 	private TableRowStyle style = new TableRowStyle();
// 	private final String tableRowTop = "\n <w:tr>{styleRowPh}";
// 	private final String tableRowBottom = "\n  </w:tr>";
// 	
// 	public TableRow(Object[] cols) {
//         txt.append(tableRowTop);
// 
//         for (int i = 0; i < cols.length; i++) {            
//         	//TableCell knows how to do the rest.
//         	txt.append( TableCell.with(cols[i]).create().getContent() );
//         }
// 		
//         txt.append(tableRowBottom);
// 	}
// 
// 	@Override
// 	public TableRowStyle withStyle() {
// 		style.setElement(this);
//         return style;
// 	}
// 
// 	@Override
// 	public String getContent() {
// 		String withStyle = style.getNewContentWithStyle(txt.toString());
// 		return withStyle;
// 	}
// 
// 	public static TableRow with(Object ... colls) {		
// 		return new TableRow(colls);
// 	}
// 
// }


import word.api.interfaces.IElement;
import word.w2004.elements.tableElements.TableRow;
package word.w2004.elements;


/**
 * @author leonardo_correa
 * 
 */
public class TableV2 implements IElement {

    private StringBuilder txt = new StringBuilder("");
    private boolean hasBeenCalledBefore = false;
    
    public String getContent() {
        if (hasBeenCalledBefore) {
            return txt.toString();
        } else {
            hasBeenCalledBefore = true;
        }
        
        if ("".equals(txt.toString())) {
            return "";
        }
        // here it goes
        txt.insert(0, tableTop);
        txt.append("\n" + tableBottom);
        
        //apply style

        return txt.toString();
    }

    /**
     * You always have to use TableRow to add new rows to the table. Eg.:
     * <code>
     * tbl.addRow( TableRowV2.with("Simple String cell") ); 
     * </code>
     * See documentation on method "TableRowV2.with" for very detailed information.
     *  
     * @param row
     * @return
     */
// Path: java2word/src/main/java/word/api/interfaces/IElement.java
// public interface IElement {
// 
// 	/**
// 	 * <p>This method returns the content (XML or HTML) of the Element and the content.</p>
// 	 * <p>If you are using W2004, the return will be the XML required to generate the element.</p>
// 	 *
// 	 * <p>Important: Once you call this method, the Document value is cached an no elements can be added later.</p>
// 	 *
// 	 * @return this is the String value of the element ready to be appended/inserted in the Document.<br>
// 	 *
// 	 * <p>This is the XML that generates a <code>BreakLine</code>:</p>
// 	 * <code>
// 	 *  <w:p wsp:rsidR='008979E8' wsp:rsidRDefault='008979E8'/>
// 	 * </code>
// 	 */
// 	public String getContent();
// 
// }
// 
// Path: java2word/src/main/java/word/w2004/elements/tableElements/TableRow.java
// public class TableRow implements IElement, IFluentElementStylable<TableRowStyle>{
// 
// 	private StringBuilder txt = new StringBuilder("");
// 	private TableRowStyle style = new TableRowStyle();
// 	private final String tableRowTop = "\n <w:tr>{styleRowPh}";
// 	private final String tableRowBottom = "\n  </w:tr>";
// 	
// 	public TableRow(Object[] cols) {
//         txt.append(tableRowTop);
// 
//         for (int i = 0; i < cols.length; i++) {            
//         	//TableCell knows how to do the rest.
//         	txt.append( TableCell.with(cols[i]).create().getContent() );
//         }
// 		
//         txt.append(tableRowBottom);
// 	}
// 
// 	@Override
// 	public TableRowStyle withStyle() {
// 		style.setElement(this);
//         return style;
// 	}
// 
// 	@Override
// 	public String getContent() {
// 		String withStyle = style.getNewContentWithStyle(txt.toString());
// 		return withStyle;
// 	}
// 
// 	public static TableRow with(Object ... colls) {		
// 		return new TableRow(colls);
// 	}
// 
// }


// Path: java2word/src/main/java/word/w2004/elements/TableV2.java
import word.api.interfaces.IElement;
import word.w2004.elements.tableElements.TableRow;

package word.w2004.elements;


/**
 * @author leonardo_correa
 * 
 */
public class TableV2 implements IElement {

    private StringBuilder txt = new StringBuilder("");
    private boolean hasBeenCalledBefore = false;
    
    public String getContent() {
        if (hasBeenCalledBefore) {
            return txt.toString();
        } else {
            hasBeenCalledBefore = true;
        }
        
        if ("".equals(txt.toString())) {
            return "";
        }
        // here it goes
        txt.insert(0, tableTop);
        txt.append("\n" + tableBottom);
        
        //apply style

        return txt.toString();
    }

    /**
     * You always have to use TableRow to add new rows to the table. Eg.:
     * <code>
     * tbl.addRow( TableRowV2.with("Simple String cell") ); 
     * </code>
     * See documentation on method "TableRowV2.with" for very detailed information.
     *  
     * @param row
     * @return
     */
    public TableRow addRow(TableRow row) {