1 package net.trajano.twiff.renderer; 2 3 import java.util.Collections; 4 import java.util.List; 5 6 /*** 7 * This is a simple element that has no components. 8 * 9 * @author Archimedes Trajano 10 */ 11 public class IncludeElement implements CompositePageElement { 12 /*** 13 * 14 */ 15 private int columnNumber; 16 17 /*** 18 * 19 */ 20 private int lineNumber; 21 22 /*** 23 * Constructs the element. 24 * 25 * @param includedElement 26 */ 27 public IncludeElement(final PageElement includedElement) { 28 this.includedElement = includedElement; 29 } 30 31 /*** 32 * 33 */ 34 private final PageElement includedElement; 35 36 /*** 37 * Accepts the visitor that was loaded. If the included element is a 38 * {@link DocumentElement} it will traverse the sub-elements and not visit 39 * the document element. 40 * 41 * @param visitor 42 * visitor. 43 */ 44 public void accept(final PageElementVisitor visitor) { 45 if (includedElement instanceof DocumentElement) { 46 DocumentElement documentElement = (DocumentElement) includedElement; 47 for (PageElement element : documentElement.getElements()) { 48 element.accept(visitor); 49 } 50 } else { 51 includedElement.accept(visitor); 52 } 53 } 54 55 /*** 56 * @param element 57 */ 58 public void addElement(final PageElement element) { 59 } 60 61 /*** 62 * @see net.trajano.twiff.renderer.PageElement#getColumnNumber() 63 */ 64 public int getColumnNumber() { 65 return columnNumber; 66 } 67 68 /*** 69 * @see net.trajano.twiff.renderer.PageElement#getLineNumber() 70 */ 71 public int getLineNumber() { 72 return lineNumber; 73 } 74 75 /*** 76 * @see net.trajano.twiff.renderer.CompositePageElement#getElements() 77 */ 78 public List<PageElement> getElements() { 79 return Collections.EMPTY_LIST; 80 } 81 }