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