2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org
.apache
.tika
.sax
;
19 import org
.xml
.sax
.Attributes
;
20 import org
.xml
.sax
.ContentHandler
;
21 import org
.xml
.sax
.Locator
;
22 import org
.xml
.sax
.SAXException
;
23 import org
.xml
.sax
.helpers
.DefaultHandler
;
26 * Decorator base class for the {@link ContentHandler} interface. This class
27 * simply delegates all SAX events calls to an underlying decorated handler
28 * instance. Subclasses can provide extra decoration by overriding one or more
29 * of the SAX event methods.
31 public class ContentHandlerDecorator
extends DefaultHandler
{
34 * Decorated SAX event handler.
36 private final ContentHandler handler
;
39 * Creates a decorator for the given SAX event handler.
41 * @param handler SAX event handler to be decorated
43 public ContentHandlerDecorator(ContentHandler handler
) {
44 this.handler
= handler
;
47 public void startPrefixMapping(String prefix
, String uri
)
49 handler
.startPrefixMapping(prefix
, uri
);
52 public void endPrefixMapping(String prefix
) throws SAXException
{
53 handler
.endPrefixMapping(prefix
);
56 public void processingInstruction(String target
, String data
)
58 handler
.processingInstruction(target
, data
);
61 public void setDocumentLocator(Locator locator
) {
62 handler
.setDocumentLocator(locator
);
65 public void startDocument() throws SAXException
{
66 handler
.startDocument();
69 public void endDocument() throws SAXException
{
70 handler
.endDocument();
73 public void startElement(String uri
, String localName
, String name
,
74 Attributes atts
) throws SAXException
{
75 handler
.startElement(uri
, localName
, name
, atts
);
78 public void endElement(String uri
, String localName
, String name
)
80 handler
.endElement(uri
, localName
, name
);
83 public void characters(char[] ch
, int start
, int length
)
85 handler
.characters(ch
, start
, length
);
88 public void ignorableWhitespace(char[] ch
, int start
, int length
)
90 handler
.ignorableWhitespace(ch
, start
, length
);
93 public void skippedEntity(String name
) throws SAXException
{
94 handler
.skippedEntity(name
);
97 public String
toString() {
98 return handler
.toString();