MockParser.java revision cc05ad238516f1303687aba4a978e24e57c0c07a
1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package tests.api.org.xml.sax.support;
18
19import java.io.IOException;
20import java.util.Locale;
21
22import org.xml.sax.DTDHandler;
23import org.xml.sax.DocumentHandler;
24import org.xml.sax.EntityResolver;
25import org.xml.sax.ErrorHandler;
26import org.xml.sax.InputSource;
27import org.xml.sax.Parser;
28import org.xml.sax.SAXException;
29
30@SuppressWarnings("deprecation")
31public class MockParser implements Parser {
32
33    private MethodLogger logger;
34
35    public MockParser(MethodLogger logger) {
36        super();
37        this.logger = logger;
38    }
39
40    public void parse(InputSource source) throws SAXException, IOException {
41        logger.add("parse", source);
42    }
43
44    public void parse(String systemId) throws SAXException, IOException {
45        logger.add("parse", systemId);
46    }
47
48    public void setDTDHandler(DTDHandler handler) {
49        logger.add("setDTDHandler", handler);
50    }
51
52    public void setDocumentHandler(DocumentHandler handler) {
53        logger.add("setDocumentHandler", handler);
54    }
55
56    public void setEntityResolver(EntityResolver resolver) {
57        logger.add("setEntityResolver", resolver);
58    }
59
60    public void setErrorHandler(ErrorHandler handler) {
61        logger.add("setErrorHandler", handler);
62    }
63
64    public void setLocale(Locale locale) throws SAXException {
65        logger.add("setLocale", locale);
66    }
67
68}
69