/* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.qetest.xsl; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; /** * Cheap-o LexicalHandler for use by API tests. This is a wrapper LexicalHandler. * It always delegate the lexical analysis to wrapped LexicalHandler. */ public class CheckingLexicalHandler implements LexicalHandler { /** * Default handler */ private final LexicalHandler defaultHandler; /** * Default constructor. */ public CheckingLexicalHandler() { defaultHandler = null; } /** * Constructor by setting LexicalHandler. * @param lh a delegated LexicalHandler. */ public CheckingLexicalHandler(LexicalHandler lh) { defaultHandler = lh; } ////////////////// Implement LexicalHandler ////////////////// @Override public void startDTD(String name, String publicId, String systemId) throws SAXException { if(null != defaultHandler) defaultHandler.startDTD(name, publicId, systemId); } @Override public void endDTD() throws SAXException { if(null != defaultHandler) defaultHandler.endDTD(); } @Override public void startEntity(String name) throws SAXException { if(null != defaultHandler) defaultHandler.startEntity(name); } @Override public void endEntity(String name) throws SAXException { if(null != defaultHandler) defaultHandler.endEntity(name); } @Override public void startCDATA() throws SAXException { if(null != defaultHandler) defaultHandler.startCDATA(); } @Override public void endCDATA() throws SAXException { if(null != defaultHandler) defaultHandler.endCDATA(); } @Override public void comment(char ch[], int start, int length) throws SAXException { if(null != defaultHandler) defaultHandler.comment(ch, start, length); } }