View Javadoc

1   /*
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
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
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.
16   */
17  package org.apache.tika.sax;
18  
19  import org.xml.sax.ContentHandler;
20  
21  /**
22   * Content handler decorator that prevents the {@link #startDocument()}
23   * and {@link #endDocument()} events from reaching the decorated handler.
24   * This is useful when you want to direct the results of parsing multiple
25   * different XML documents into a single target document without worrying
26   * about the {@link #startDocument()} and {@link #endDocument()} methods
27   * being called more than once.
28   */
29  public class EmbeddedContentHandler extends ContentHandlerDecorator {
30  
31      /**
32       * Created a decorator that prevents the given handler from
33       * receiving {@link #startDocument()} and {@link #endDocument()}
34       * events.
35       *
36       * @param handler the content handler to be decorated
37       */
38      public EmbeddedContentHandler(ContentHandler handler) {
39          super(handler);
40      }
41  
42      /**
43       * Ignored.
44       */
45      @Override
46      public void startDocument() {
47      }
48  
49      /**
50       * Ignored.
51       */
52      @Override
53      public void endDocument() {
54      }
55  
56  }