01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the "License"). You may not use this file except
05: * in compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://jwsdp.dev.java.net/CDDLv1.0.html
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * HEADER in each file and include the License file at
14: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
15: * add the following below this CDDL HEADER, with the
16: * fields enclosed by brackets "[]" replaced with your
17: * own identifying information: Portions Copyright [yyyy]
18: * [name of copyright owner]
19: */
20:
21: package com.sun.xml.txw2;
22:
23: /**
24: * @author Kohsuke Kawaguchi
25: */
26: abstract class Content {
27: private Content next;
28:
29: /**
30: * Returns null if the next token has not decided yet.
31: */
32: final Content getNext() {
33: return next;
34: }
35:
36: /**
37: *
38: * @param doc
39: * A {@link Content} object is so light-weight that
40: * it doesn't even remember what document it belongs to.
41: * So the caller needs to "remind" a {@link Content}
42: * who its owner is.
43: */
44: final void setNext(Document doc, Content next) {
45: assert next != null;
46: assert this .next == null : "next of " + this
47: + " is already set to " + this .next;
48: this .next = next;
49: doc.run();
50: }
51:
52: /**
53: * Returns true if this content is ready to be committed.
54: */
55: boolean isReadyToCommit() {
56: return true;
57: }
58:
59: /**
60: * Returns true if this {@link Content} can guarantee that
61: * no more new namespace decls is necessary for the currently
62: * pending start tag.
63: */
64: abstract boolean concludesPendingStartTag();
65:
66: /**
67: * Accepts a visitor.
68: */
69: abstract void accept(ContentVisitor visitor);
70:
71: /**
72: * Called when this content is written to the output.
73: */
74: public void written() {
75: }
76: }
|