01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.dom;
16:
17: import java.io.PrintWriter;
18:
19: /**
20: * Representation of a document type. Note that technically, a Doctype isn't a node in an xml
21: * document; hence this doesn't extend node.
22: */
23: public class DTD {
24: private final String _name;
25:
26: private final String _publicId;
27:
28: private final String _systemId;
29:
30: public DTD(String name, String publicId, String systemId) {
31: _name = name;
32: _publicId = publicId;
33: _systemId = systemId;
34: }
35:
36: public String getName() {
37: return _name;
38: }
39:
40: public String getPublicId() {
41: return _publicId;
42: }
43:
44: public String getSystemId() {
45: return _systemId;
46: }
47:
48: public void toMarkup(PrintWriter writer) {
49: if (_publicId != null) {
50: if (_systemId != null) {
51: writer.printf("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">",
52: _name, _publicId, _systemId);
53: } else {
54: writer.printf("<!DOCTYPE %s PUBLIC \"%s\">", _name,
55: _publicId);
56: }
57: } else if (_systemId != null) {
58: writer.printf("<!DOCTYPE %s SYSTEM \"%s\">", _name,
59: _systemId);
60: }
61: }
62: }
|