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