001 /*
002 * Copyright (c) 2007 Henri Sivonen
003 * Copyright (c) 2008 Mozilla Foundation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a
006 * copy of this software and associated documentation files (the "Software"),
007 * to deal in the Software without restriction, including without limitation
008 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
009 * and/or sell copies of the Software, and to permit persons to whom the
010 * Software is furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
018 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
020 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
021 * DEALINGS IN THE SOFTWARE.
022 */
023
024 package nu.validator.saxtree;
025
026 import org.xml.sax.Locator;
027 import org.xml.sax.SAXException;
028
029 /**
030 * A doctype.
031 * @version $Id$
032 * @author hsivonen
033 */
034 public final class DTD extends ParentNode {
035
036 /**
037 * The name.
038 */
039 private final String name;
040
041 /**
042 * The public id.
043 */
044 private final String publicIdentifier;
045
046 /**
047 * The system id.
048 */
049 private final String systemIdentifier;
050
051 /**
052 * The constructor.
053 * @param locator the locator
054 * @param name the name
055 * @param publicIdentifier the public id
056 * @param systemIdentifier the system id
057 */
058 public DTD(Locator locator, String name, String publicIdentifier, String systemIdentifier) {
059 super(locator);
060 this.name = name;
061 this.publicIdentifier = publicIdentifier;
062 this.systemIdentifier = systemIdentifier;
063 }
064
065 /**
066 *
067 * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
068 */
069 @Override
070 void visit(TreeParser treeParser) throws SAXException {
071 treeParser.startDTD(name, publicIdentifier, systemIdentifier, this);
072 }
073
074 /**
075 * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
076 */
077 @Override
078 void revisit(TreeParser treeParser) throws SAXException {
079 treeParser.endDTD(endLocator);
080 }
081
082 /**
083 * Returns the name.
084 *
085 * @return the name
086 */
087 public String getName() {
088 return name;
089 }
090
091 /**
092 * Returns the publicIdentifier.
093 *
094 * @return the publicIdentifier
095 */
096 public String getPublicIdentifier() {
097 return publicIdentifier;
098 }
099
100 /**
101 * Returns the systemIdentifier.
102 *
103 * @return the systemIdentifier
104 */
105 public String getSystemIdentifier() {
106 return systemIdentifier;
107 }
108
109 /**
110 *
111 * @see nu.validator.saxtree.Node#getNodeType()
112 */
113 @Override
114 public NodeType getNodeType() {
115 return NodeType.DTD;
116 }
117
118 }