Source code: org/jdaemon/six/BuilderDelegator.java
1 /*
2 * BuilderDelegator.java
3 *
4 * Copyright (C) 2002 Jonathan Essex
5 * This program is distributed under the terms of the Lesser GNU General Public
6 * License (v2 or later) per the included COPYING.txt file, or see www.fsf.org.
7 *
8 * Created on 17 March 2002, 15:01
9 */
10
11 package org.jdaemon.six;
12
13 import org.jdaemon.util.AttributeList;
14
15 /** A Builder instance that delegates all calls to some other Builder (the delegate).
16 *
17 * This class is used as a base for other classes that enrich the functionality of some
18 * other builder. In itself it provides no worthwhile functionality.
19 *
20 * @author Jonathan Essex
21 * @version 0.1
22 */
23 public class BuilderDelegator implements Builder {
24
25 /** Builder instance that actually handles most method invocations */
26 protected Builder delegate;
27
28 /** Creates new BuilderDelegator.
29 * @param delegate Delegate builder object
30 */
31 public BuilderDelegator(Builder delegate) {
32 this.delegate = delegate;
33 }
34
35 /** End a document element; subsequent elements will be children of this element's parent.
36 *
37 * Invokes delegate.endElement(type).
38 *
39 * @param type String encoding the type of data represented by this element
40 */
41 public void endElement(String type) {
42 delegate.endElement(type);
43 }
44
45 /** Begin a document element; subsequent elements will be children of this element.
46 *
47 * Invokes delegate.startElement(type, attributes);
48 *
49 * @param type String encoding the type of data represented by this element
50 */
51 public void startElement(String type, AttributeList attributes) {
52 delegate.startElement(type, attributes);
53 }
54
55 /** Add content to a document element.
56 *
57 * Invokes delegate.writeObject(content);
58 *
59 * @param content Object containing content to be added to this element
60 */
61 public void writeObject(Object content) {
62 delegate.writeObject(content);
63 }
64
65 /** Finalise any processing handled by this Delegator; return the delegate.
66 *
67 * @return The delegate which was used by this Delegator
68 */
69 public Builder flush() {
70 return delegate;
71 }
72 }