01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package net.ar.webonswing.render.markup;
19:
20: import java.util.*;
21:
22: import net.ar.webonswing.visitor.*;
23:
24: public class MarkupContainer extends MarkupElement {
25: Vector theElements;
26:
27: public MarkupContainer() {
28: theElements = new Vector();
29: }
30:
31: public void addAll(MarkupContainer aContainer) {
32: for (Iterator i = aContainer.getTheElements().iterator(); i
33: .hasNext();)
34: addElement((MarkupElement) i.next());
35: }
36:
37: public void addElement(MarkupElement anElement) {
38: theElements.add(anElement);
39: }
40:
41: public void removeElement(MarkupElement anElement) {
42: theElements.remove(anElement);
43: }
44:
45: public List getTheElements() {
46: return theElements;
47: }
48:
49: public void setTheElements(Vector anElements) {
50: this .theElements = anElements;
51: }
52:
53: public void accept(Visitor aMarkupVisitor) {
54: ((MarkupVisitor) aMarkupVisitor)
55: .visitMarkupContainerBegin(this );
56:
57: for (Iterator i = getTheElements().iterator(); i.hasNext();)
58: ((MarkupElement) i.next()).accept(aMarkupVisitor);
59:
60: ((MarkupVisitor) aMarkupVisitor).visitMarkupContainerEnd(this );
61: }
62:
63: public boolean isEmpty() {
64: return theElements.isEmpty();
65: }
66:
67: public void clear() {
68: theElements.clear();
69: }
70:
71: public Object clone() throws CloneNotSupportedException {
72: MarkupContainer theContainer = (MarkupContainer) super .clone();
73:
74: theContainer.theElements = new Vector();
75: for (Iterator i = theElements.iterator(); i.hasNext();)
76: theContainer.theElements.add(i.next());
77:
78: return theContainer;
79: }
80:
81: }
|