package net.afterlifelochie.fontbox.document;

import java.util.ArrayList;

public class Document {

	public ArrayList<Element> elements;

	public Document() {
		this.elements = new ArrayList<Element>();
	}

	public void push(Element element) {
		if (elements.contains(element))
			throw new IllegalArgumentException("Element already exists in tree!");
		elements.add(element);
	}

	public Element pop() {
		return elements.remove(elements.size() - 1);
	}

	public Element head() {
		return elements.get(0);
	}

	public Element tail() {
		return elements.get(elements.size() - 1);
	}

}

@@ -77,464 +77,1778 @@
 %0D%0A%0D%0A
-public class Document %7B%0D%0A%0D%0A%09public ArrayList%3CElement%3E elements;%0D%0A%0D%0A%09public Document() %7B%0D%0A%09%09this.elements = new ArrayList%3CElement%3E();%0D%0A%09%7D%0D%0A%0D%0A%09public void push(Element element) %7B%0D%0A%09%09if (elements.contains(element))%0D%0A%09%09%09throw new IllegalArgumentException(%22Element already exists in tree!%22);%0D%0A%09%09elements.add(element);%0D%0A%09%7D%0D%0A%0D%0A%09public Element pop() %7B%0D%0A%09%09return elements.remove(elements.size() - 1);%0D%0A%09%7D%0D%0A%0D%0A%09public Element head() %7B%0D%0A%09%09return elements.get(0);%0D%0A%09%7D%0D%0A
+/**%0D%0A * Document class. Used to contain an ordered list of Elements which are later%0D%0A * transformed into renderable Elements for the book renderer.%0D%0A * %0D%0A * @author AfterLifeLochie%0D%0A */%0D%0Apublic class Document %7B%0D%0A%0D%0A%09/** The list of elements in the document */%0D%0A%09public ArrayList%3CElement%3E elements;%0D%0A%0D%0A%09/**%0D%0A%09 * Creates a new blank Document%0D%0A%09 */%0D%0A%09public Document() %7B%0D%0A%09%09this.elements = new ArrayList%3CElement%3E();%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * %3Cp%3E%0D%0A%09 * Pushes an element onto the end of the document.%0D%0A%09 * %3C/p%3E%0D%0A%09 * %3Cp%3E%0D%0A%09 * The element must not already exist in the document. If the element%0D%0A%09 * already exists in the document, an %7B@link IllegalArgumentException%7D will%0D%0A%09 * be thrown.%0D%0A%09 * %3C/p%3E%0D%0A%09 * %0D%0A%09 * @param element%0D%0A%09 *            The element to add%0D%0A%09 */%0D%0A%09public void push(Element element) %7B%0D%0A%09%09if (elements.contains(element))%0D%0A%09%09%09throw new IllegalArgumentException(%22Element already exists in tree!%22);%0D%0A%09%09elements.add(element);%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * %3Cp%3E%0D%0A%09 * Removes an element from the end of the document and returns it. If the%0D%0A%09 * document is empty, null will be returned.%0D%0A%09 * %3C/p%3E%0D%0A%09 * %0D%0A%09 * @return The element on the end of the document, or null if the document%0D%0A%09 *         is empty%0D%0A%09 */%0D%0A%09public Element pop() %7B%0D%0A%09%09if (elements.size() == 0)%0D%0A%09%09%09return null;%0D%0A%09%09return elements.remove(elements.size() - 1);%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * %3Cp%3E%0D%0A%09 * Returns the element from the beginning of the document. If the document%0D%0A%09 * is empty, null is returned.%0D%0A%09 * %3C/p%3E%0D%0A%09 * %0D%0A%09 * @return The first element in the document, or null%0D%0A%09 */%0D%0A%09public Element head() %7B%0D%0A%09%09return elements.get(0);%0D%0A%09%7D%0D%0A%0D%0A%09/**%0D%0A%09 * %3Cp%3E%0D%0A%09 * Returns last element from the end of the document. If the document is%0D%0A%09 * empty, null is returned.%0D%0A%09 * %3C/p%3E%0D%0A%09 * %0D%0A%09 * @return The last element in the document, or null%0D%0A%09 */
 %0D%0A%09p

Add documentation