View Javadoc

1   package net.trajano.twiff.renderer;
2   
3   import java.util.Collections;
4   import java.util.LinkedList;
5   import java.util.List;
6   
7   /***
8    * This is the document level element.
9    * 
10   * @author Archimedes Trajano
11   */
12  public class DocumentElement implements CompositePageElement {
13      /***
14       * List of sub-elements in this component. It it is recommended that a
15       * {@link LinkedList} is used as it would only be read in order.
16       */
17      private final List<PageElement> subElements = new LinkedList<PageElement>();
18  
19      /***
20       * This is a constructor used for testing.
21       */
22      public DocumentElement() {
23      }
24  
25      /***
26       * Accepts a visitor that should visit the page data.
27       * 
28       * @param visitor
29       *                   visitor.
30       */
31      public void accept(final PageElementVisitor visitor) {
32          visitor.startDocument(this);
33          for (PageElement element : subElements) {
34              element.accept(visitor);
35          }
36          visitor.endDocument(this);
37      }
38  
39      /***
40       * @param element
41       */
42      public void addElement(final PageElement element) {
43          subElements.add(element);
44      }
45  
46      /***
47       * Returns the sub-elements in the element.
48       * 
49       * @return sub-elements.
50       */
51      public List<PageElement> getElements() {
52          return Collections.unmodifiableList(subElements);
53      }
54  
55      /***
56       * @see net.trajano.twiff.renderer.PageElement#getColumnNumber()
57       */
58      public int getColumnNumber() {
59          return -1;
60      }
61  
62      /***
63       * @see net.trajano.twiff.renderer.PageElement#getLineNumber()
64       */
65      public int getLineNumber() {
66          return -1;
67      }
68  }