package com.treelight.krnl; import java.util.LinkedList; /** * A list of content objects (either text nodes or inline nodes). * * @version 0.1 * @author Eric Armstrong * @see ../NodesAndLists.html */ public abstract class ContentList extends AbstractList { static final String type = CONTENT_LIST; private LinkedList list = new LinkedList(); public void add(ContentNode node) list.add(node); } public void remove(ContentNode targetNode) throws ItemNotFoundException { Iterator lit = list.listIterator(); while (lit.hasNext()) { ContentNode currNode = (ContentNode) lit.next(); if (currNode.equals(targetNode)) { lit.remove(); return; // successful } } throw new ItemNotFoundException(); } public ContentNode get(int n) { return (ContentNode) list.get(n); } public void replace(int n, ContentNode node) { // ___TODO___ } /** * Return the list's content. */ public String getContent() { String content = ""; Iterator it = list.iterator(); while (it.hasNext()) { ContentNode node = (ContentNode) it.next(); content += node.getContent(); } return content; } }//ContentList