001 package com.thaiopensource.relaxng.parse.sax; 002 003 import org.xml.sax.DTDHandler; 004 import org.xml.sax.SAXException; 005 import org.relaxng.datatype.ValidationContext; 006 007 import java.util.Hashtable; 008 009 public abstract class DtdContext implements DTDHandler, ValidationContext { 010 private final Hashtable notationTable; 011 private final Hashtable unparsedEntityTable; 012 013 public DtdContext() { 014 notationTable = new Hashtable(); 015 unparsedEntityTable = new Hashtable(); 016 } 017 018 public DtdContext(DtdContext dc) { 019 notationTable = dc.notationTable; 020 unparsedEntityTable = dc.unparsedEntityTable; 021 } 022 023 public void notationDecl(String name, 024 String publicId, 025 String systemId) 026 throws SAXException { 027 notationTable.put(name, name); 028 } 029 030 public void unparsedEntityDecl(String name, 031 String publicId, 032 String systemId, 033 String notationName) 034 throws SAXException { 035 unparsedEntityTable.put(name, name); 036 } 037 038 public boolean isNotation(String notationName) { 039 return notationTable.get(notationName) != null; 040 } 041 042 public boolean isUnparsedEntity(String entityName) { 043 return unparsedEntityTable.get(entityName) != null; 044 } 045 046 public void clearDtdContext() { 047 notationTable.clear(); 048 unparsedEntityTable.clear(); 049 } 050 }