1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.jaxp;
  23 
  24 import com.sun.org.apache.xerces.internal.xni.Augmentations;
  25 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
  26 import com.sun.org.apache.xerces.internal.xni.QName;
  27 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
  28 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  29 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  30 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
  31 import com.sun.org.apache.xerces.internal.xni.XMLString;
  32 import com.sun.org.apache.xerces.internal.xni.XNIException;
  33 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentFilter;
  34 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  35 
  36 /**
  37  * <p>XMLDocumentHandler which forks the pipeline to two other components.</p>
  38  *
  39  * @author Kohsuke Kawaguchi
  40  */
  41 class TeeXMLDocumentFilterImpl implements XMLDocumentFilter {
  42 
  43     /**
  44      * The next component in the pipeline who receives the event.
  45      * This component receives events after the "side" handler
  46      * receives them.
  47      */
  48     private XMLDocumentHandler next;
  49 
  50     /**
  51      * The component who intercepts events.
  52      */
  53     private XMLDocumentHandler side;
  54 
  55     /**
  56      * The source of the event.
  57      */
  58     private XMLDocumentSource source;
  59 
  60     public XMLDocumentHandler getSide() {
  61         return side;
  62     }
  63 
  64     public void setSide(XMLDocumentHandler side) {
  65         this.side = side;
  66     }
  67 
  68     public XMLDocumentSource getDocumentSource() {
  69         return source;
  70     }
  71 
  72     public void setDocumentSource(XMLDocumentSource source) {
  73         this.source = source;
  74     }
  75 
  76     public XMLDocumentHandler getDocumentHandler() {
  77         return next;
  78     }
  79 
  80     public void setDocumentHandler(XMLDocumentHandler handler) {
  81         next = handler;
  82     }
  83 
  84     //
  85     //
  86     //  XMLDocumentHandler implementation
  87     //
  88     //
  89 
  90     public void characters(XMLString text, Augmentations augs) throws XNIException {
  91         side.characters(text, augs);
  92         next.characters(text, augs);
  93     }
  94 
  95     public void comment(XMLString text, Augmentations augs) throws XNIException {
  96         side.comment(text, augs);
  97         next.comment(text, augs);
  98     }
  99 
 100     public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)
 101         throws XNIException {
 102         side.doctypeDecl(rootElement, publicId, systemId, augs);
 103         next.doctypeDecl(rootElement, publicId, systemId, augs);
 104     }
 105 
 106     public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
 107         side.emptyElement(element, attributes, augs);
 108         next.emptyElement(element, attributes, augs);
 109     }
 110 
 111     public void endCDATA(Augmentations augs) throws XNIException {
 112         side.endCDATA(augs);
 113         next.endCDATA(augs);
 114     }
 115 
 116     public void endDocument(Augmentations augs) throws XNIException {
 117         side.endDocument(augs);
 118         next.endDocument(augs);
 119     }
 120 
 121     public void endElement(QName element, Augmentations augs) throws XNIException {
 122         side.endElement(element, augs);
 123         next.endElement(element, augs);
 124     }
 125 
 126     public void endGeneralEntity(String name, Augmentations augs) throws XNIException {
 127         side.endGeneralEntity(name, augs);
 128         next.endGeneralEntity(name, augs);
 129     }
 130 
 131     public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
 132         side.ignorableWhitespace(text, augs);
 133         next.ignorableWhitespace(text, augs);
 134     }
 135 
 136     public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {
 137         side.processingInstruction(target, data, augs);
 138         next.processingInstruction(target, data, augs);
 139     }
 140 
 141     public void startCDATA(Augmentations augs) throws XNIException {
 142         side.startCDATA(augs);
 143         next.startCDATA(augs);
 144     }
 145 
 146     public void startDocument(
 147             XMLLocator locator,
 148             String encoding,
 149             NamespaceContext namespaceContext,
 150             Augmentations augs)
 151         throws XNIException {
 152         side.startDocument(locator, encoding, namespaceContext, augs);
 153         next.startDocument(locator, encoding, namespaceContext, augs);
 154     }
 155 
 156     public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
 157         side.startElement(element, attributes, augs);
 158         next.startElement(element, attributes, augs);
 159     }
 160 
 161     public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs)
 162         throws XNIException {
 163         side.startGeneralEntity(name, identifier, encoding, augs);
 164         next.startGeneralEntity(name, identifier, encoding, augs);
 165     }
 166 
 167     public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
 168         side.textDecl(version, encoding, augs);
 169         next.textDecl(version, encoding, augs);
 170     }
 171 
 172     public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
 173         side.xmlDecl(version, encoding, standalone, augs);
 174         next.xmlDecl(version, encoding, standalone, augs);
 175     }
 176 
 177 }