// 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/api/interfaces/IFluentElementStylable.java
// public interface IFluentElementStylable <S>{
// 
// 	/**
// 	 * This method returns style for the element. The element knows who is his style class, but the style doesn't.
// 	 * This method will do this:
// 	 * 	1) set up the itself to the style class
// 	 *      this.getStyle().setElement(this); //, Heading1.class
// 	 *  2) Return the style class    
// 	 *	return this.getStyle();
// 	 *
// 	 */
// 	public S withStyle();
// 	
// }
// 
// Path: java2word/src/main/java/word/w2004/style/HeadingStyle.java
// public class HeadingStyle extends AbstractStyle implements ISuperStylin{
// 
//     /**
//      * Default align is left
//      */
//     private Align align = Align.LEFT;
//     private boolean bold = false;
//     private boolean italic = false;
// 
//     //we could abstract this or not... if we want to apply style to one word inside a the Heading, you can NOT apply align JUSTIFIED, for example.
//     //For this reason I will leave this here for instance...
//     public enum Align {
//         CENTER("center"), LEFT("left"), RIGHT("right"), JUSTIFIED("both");
// 
//         private String value;
// 
//         Align(String value) {
//             this.value = value;
//         }
// 
//         public String getValue() {
//             return value;
//         }
//     }
// 
// 
//     //This method holds the logic to replace all place holders for styling.
//     //I also noticed if you don't replace the place holder, it doesn't cause any error!
//     //But we should try to replace in order to keep the result xml clean.
//     @Override
//     public String getNewContentWithStyle(String txt) {
//         String alignValue = "\n            	<w:jc w:val=\"" + align.getValue()+ "\" />";
//         txt = txt.replace("{styleAlign}", alignValue);
// 
//         StringBuilder sbText = new StringBuilder("");
// 
//         applyBoldAndItalic(sbText);
// 
//         if(!"".equals(sbText.toString())) {
//             sbText.insert(0, "\n	 <w:rPr>");
//             sbText.append("\n	 </w:rPr>");
//         }
// 
//         txt = txt.replace("{styleText}", sbText.toString());//Convention: apply styles
//         txt = txt.replaceAll("[{]style(.*)[}]", ""); //Convention: remove unused styles after...
// 
//         return txt;
//     }
// 
// 
//     private void applyBoldAndItalic(StringBuilder sbText) {
//         if(bold) {
//             sbText.append("\n            	<w:b/><w:b-cs/>");
//         }
//         if(italic) {
//             sbText.append("\n            	<w:i/>");
//         }
//     }
// 
// 
//     //### Getters  setters... ###
// 
//     /**
//      * Heading alignment
//      * @param align
//      * @return fluent @HeadingStyle
//      */
//     public HeadingStyle align(Align align) {
//         this.align = align;
//         return this;
//     }
// 
//     /**
//      * Set Heading font to bold
//      * @return fluent @HeadingStyle
//      */
//     public HeadingStyle bold() {
//         bold = true;
//         return this;
//     }
// 
//     /**
//      * Set Heading font to italic
//      * @return fluent @HeadingStyle
//      */
//     public HeadingStyle italic() {
//         italic = true;
//         return this;
//     }
// 
// 
// }


import word.api.interfaces.IElement;
import word.api.interfaces.IFluentElementStylable;
import word.w2004.style.HeadingStyle;
package word.w2004.elements;


/**
 * @author leonardo
 * @param <E>
 * Heading is utilized to organize documents the same way you do for web pages.
 * You can use Heading1 to 3.
 */
public abstract class AbstractHeading<E> implements IElement,  IFluentElementStylable<E>{

    /**
     * this is actual heading1, heading2 or heading3.
     */
    private String headingType;
    private String value; //value/text for the Heading

    protected AbstractHeading(String headingType, String value){
        this.headingType = headingType;
        this.value = value;
    }

    private String template =
        "\n<w:p wsp:rsidR=\"004429ED\" wsp:rsidRDefault=\"00000000\" wsp:rsidP=\"004429ED\">"
        +"\n	<w:pPr>"
        +"\n		<w:pStyle w:val=\"{heading}\" />"
        +"\n		{styleAlign}"
        +"\n	</w:pPr>"
        +"\n	<w:r>"
        +"\n		{styleText}"
        +"\n		<w:t>{value}</w:t>"
        +"\n	</w:r>"
        +"\n</w:p>";

// 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/api/interfaces/IFluentElementStylable.java
// public interface IFluentElementStylable <S>{
// 
// 	/**
// 	 * This method returns style for the element. The element knows who is his style class, but the style doesn't.
// 	 * This method will do this:
// 	 * 	1) set up the itself to the style class
// 	 *      this.getStyle().setElement(this); //, Heading1.class
// 	 *  2) Return the style class    
// 	 *	return this.getStyle();
// 	 *
// 	 */
// 	public S withStyle();
// 	
// }
// 
// Path: java2word/src/main/java/word/w2004/style/HeadingStyle.java
// public class HeadingStyle extends AbstractStyle implements ISuperStylin{
// 
//     /**
//      * Default align is left
//      */
//     private Align align = Align.LEFT;
//     private boolean bold = false;
//     private boolean italic = false;
// 
//     //we could abstract this or not... if we want to apply style to one word inside a the Heading, you can NOT apply align JUSTIFIED, for example.
//     //For this reason I will leave this here for instance...
//     public enum Align {
//         CENTER("center"), LEFT("left"), RIGHT("right"), JUSTIFIED("both");
// 
//         private String value;
// 
//         Align(String value) {
//             this.value = value;
//         }
// 
//         public String getValue() {
//             return value;
//         }
//     }
// 
// 
//     //This method holds the logic to replace all place holders for styling.
//     //I also noticed if you don't replace the place holder, it doesn't cause any error!
//     //But we should try to replace in order to keep the result xml clean.
//     @Override
//     public String getNewContentWithStyle(String txt) {
//         String alignValue = "\n            	<w:jc w:val=\"" + align.getValue()+ "\" />";
//         txt = txt.replace("{styleAlign}", alignValue);
// 
//         StringBuilder sbText = new StringBuilder("");
// 
//         applyBoldAndItalic(sbText);
// 
//         if(!"".equals(sbText.toString())) {
//             sbText.insert(0, "\n	 <w:rPr>");
//             sbText.append("\n	 </w:rPr>");
//         }
// 
//         txt = txt.replace("{styleText}", sbText.toString());//Convention: apply styles
//         txt = txt.replaceAll("[{]style(.*)[}]", ""); //Convention: remove unused styles after...
// 
//         return txt;
//     }
// 
// 
//     private void applyBoldAndItalic(StringBuilder sbText) {
//         if(bold) {
//             sbText.append("\n            	<w:b/><w:b-cs/>");
//         }
//         if(italic) {
//             sbText.append("\n            	<w:i/>");
//         }
//     }
// 
// 
//     //### Getters  setters... ###
// 
//     /**
//      * Heading alignment
//      * @param align
//      * @return fluent @HeadingStyle
//      */
//     public HeadingStyle align(Align align) {
//         this.align = align;
//         return this;
//     }
// 
//     /**
//      * Set Heading font to bold
//      * @return fluent @HeadingStyle
//      */
//     public HeadingStyle bold() {
//         bold = true;
//         return this;
//     }
// 
//     /**
//      * Set Heading font to italic
//      * @return fluent @HeadingStyle
//      */
//     public HeadingStyle italic() {
//         italic = true;
//         return this;
//     }
// 
// 
// }


// Path: java2word/src/main/java/word/w2004/elements/AbstractHeading.java
import word.api.interfaces.IElement;
import word.api.interfaces.IFluentElementStylable;
import word.w2004.style.HeadingStyle;

package word.w2004.elements;


/**
 * @author leonardo
 * @param <E>
 * Heading is utilized to organize documents the same way you do for web pages.
 * You can use Heading1 to 3.
 */
public abstract class AbstractHeading<E> implements IElement,  IFluentElementStylable<E>{

    /**
     * this is actual heading1, heading2 or heading3.
     */
    private String headingType;
    private String value; //value/text for the Heading

    protected AbstractHeading(String headingType, String value){
        this.headingType = headingType;
        this.value = value;
    }

    private String template =
        "\n<w:p wsp:rsidR=\"004429ED\" wsp:rsidRDefault=\"00000000\" wsp:rsidP=\"004429ED\">"
        +"\n	<w:pPr>"
        +"\n		<w:pStyle w:val=\"{heading}\" />"
        +"\n		{styleAlign}"
        +"\n	</w:pPr>"
        +"\n	<w:r>"
        +"\n		{styleText}"
        +"\n		<w:t>{value}</w:t>"
        +"\n	</w:r>"
        +"\n</w:p>";

    private HeadingStyle style = new HeadingStyle();