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.util; 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 * 38 * 39 * @author 40 * Kohsuke Kawaguchi 41 */ 42 public class TeeXMLDocumentFilterImpl implements XMLDocumentFilter { 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 61 62 public XMLDocumentHandler getSide() { 63 return side; 64 } 65 66 public void setSide(XMLDocumentHandler side) { 67 this.side = side; 68 } 69 70 public XMLDocumentSource getDocumentSource() { 71 return source; 72 } 73 74 public void setDocumentSource(XMLDocumentSource source) { 75 this.source = source; 76 } 77 78 public XMLDocumentHandler getDocumentHandler() { 79 return next; 80 } 81 82 public void setDocumentHandler(XMLDocumentHandler handler) { 83 next = handler; 84 } 85 86 // 87 // 88 // XMLDocumentHandler implementation 89 // 90 // 91 public void characters(XMLString text, Augmentations augs) throws XNIException { 92 side.characters(text, augs); 93 next.characters(text, augs); 94 } 95 96 public void comment(XMLString text, Augmentations augs) throws XNIException { 97 side.comment(text, augs); 98 next.comment(text, augs); 99 } 100 101 public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) 102 throws XNIException { 103 side.doctypeDecl(rootElement, publicId, systemId, augs); 104 next.doctypeDecl(rootElement, publicId, systemId, augs); 105 } 106 107 public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException { 108 side.emptyElement(element, attributes, augs); 109 next.emptyElement(element, attributes, augs); 110 } 111 112 public void endCDATA(Augmentations augs) throws XNIException { 113 side.endCDATA(augs); 114 next.endCDATA(augs); 115 } 116 117 public void endDocument(Augmentations augs) throws XNIException { 118 side.endDocument(augs); 119 next.endDocument(augs); 120 } 121 122 public void endElement(QName element, Augmentations augs) throws XNIException { 123 side.endElement(element, augs); 124 next.endElement(element, augs); 125 } 126 127 public void endGeneralEntity(String name, Augmentations augs) throws XNIException { 128 side.endGeneralEntity(name, augs); 129 next.endGeneralEntity(name, augs); 130 } 131 132 public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException { 133 side.ignorableWhitespace(text, augs); 134 next.ignorableWhitespace(text, augs); 135 } 136 137 public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException { 138 side.processingInstruction(target, data, augs); 139 next.processingInstruction(target, data, augs); 140 } 141 142 public void startCDATA(Augmentations augs) throws XNIException { 143 side.startCDATA(augs); 144 next.startCDATA(augs); 145 } 146 147 public void startDocument( 148 XMLLocator locator, 149 String encoding, 150 NamespaceContext namespaceContext, 151 Augmentations augs) 152 throws XNIException { 153 side.startDocument(locator, encoding, namespaceContext, augs); 154 next.startDocument(locator, encoding, namespaceContext, augs); 155 } 156 157 public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException { 158 side.startElement(element, attributes, augs); 159 next.startElement(element, attributes, augs); 160 } 161 162 public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) 163 throws XNIException { 164 side.startGeneralEntity(name, identifier, encoding, augs); 165 next.startGeneralEntity(name, identifier, encoding, augs); 166 } 167 168 public void textDecl(String version, String encoding, Augmentations augs) throws XNIException { 169 side.textDecl(version, encoding, augs); 170 next.textDecl(version, encoding, augs); 171 } 172 173 public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException { 174 side.xmlDecl(version, encoding, standalone, augs); 175 next.xmlDecl(version, encoding, standalone, augs); 176 } 177 178 }