1/*
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
3 */
4/*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements.  See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License.  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
21package com.sun.org.apache.xml.internal.serializer;
22
23import java.io.IOException;
24import java.io.OutputStream;
25import java.io.Writer;
26import java.util.ArrayList;
27import java.util.Properties;
28import javax.xml.transform.SourceLocator;
29import javax.xml.transform.Transformer;
30import org.w3c.dom.Node;
31import org.xml.sax.Attributes;
32import org.xml.sax.ContentHandler;
33import org.xml.sax.Locator;
34import org.xml.sax.SAXException;
35import org.xml.sax.SAXParseException;
36
37/**
38 * This class is an adapter class. Its only purpose is to be extended and
39 * for that extended class to over-ride all methods that are to be used.
40 *
41 * This class is not a public API, it is only public because it is used
42 * across package boundaries.
43 *
44 * @xsl.usage internal
45 */
46public class EmptySerializer implements SerializationHandler
47{
48    protected static final String ERR = "EmptySerializer method not over-ridden";
49
50    protected void couldThrowIOException() throws IOException {
51        return; // don't do anything.
52    }
53
54    protected void couldThrowSAXException() throws SAXException {
55        return; // don't do anything.
56    }
57
58    protected void couldThrowSAXException(char[] chars, int off, int len)
59        throws SAXException
60    {
61        return; // don't do anything.
62    }
63
64    protected void couldThrowSAXException(String elemQName)
65        throws SAXException
66    {
67        return; // don't do anything.
68    }
69
70    void aMethodIsCalled() {
71        // throw new RuntimeException(err);
72        return;
73    }
74
75    /**
76     * @see SerializationHandler#asContentHandler()
77     */
78    public ContentHandler asContentHandler() throws IOException {
79        couldThrowIOException();
80        return null;
81    }
82
83    /**
84     * @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
85     */
86    public void setContentHandler(ContentHandler ch) {
87        aMethodIsCalled();
88    }
89
90    /**
91     * @see SerializationHandler#close()
92     */
93    public void close() {
94        aMethodIsCalled();
95    }
96
97    /**
98     * @see SerializationHandler#getOutputFormat()
99     */
100    public Properties getOutputFormat() {
101        aMethodIsCalled();
102        return null;
103    }
104
105    /**
106     * @see SerializationHandler#getOutputStream()
107     */
108    public OutputStream getOutputStream() {
109        aMethodIsCalled();
110        return null;
111    }
112
113    /**
114     * @see SerializationHandler#getWriter()
115     */
116    public Writer getWriter() {
117        aMethodIsCalled();
118        return null;
119    }
120
121    /**
122     * @see SerializationHandler#reset()
123     */
124    public boolean reset() {
125        aMethodIsCalled();
126        return false;
127    }
128
129    /**
130     * @see SerializationHandler#serialize(org.w3c.dom.Node)
131     */
132    public void serialize(Node node) throws IOException {
133        couldThrowIOException();
134    }
135
136    /**
137     * @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
138     */
139    public void setCdataSectionElements(ArrayList<String> URI_and_localNames) {
140        aMethodIsCalled();
141    }
142
143    /**
144     * @see SerializationHandler#setEscaping(boolean)
145     */
146    public boolean setEscaping(boolean escape) throws SAXException {
147        couldThrowSAXException();
148        return false;
149    }
150
151    /**
152     * @see SerializationHandler#setIndent(boolean)
153     */
154    public void setIndent(boolean indent) {
155        aMethodIsCalled();
156    }
157
158    /**
159     * @see SerializationHandler#setIndentAmount(int)
160     */
161    public void setIndentAmount(int spaces) {
162        aMethodIsCalled();
163    }
164
165    /**
166     * @see SerializationHandler#setIsStandalone(boolean)
167     */
168    public void setIsStandalone(boolean isStandalone) {
169        aMethodIsCalled();
170    }
171
172    /**
173     * @see SerializationHandler#setOutputFormat(java.util.Properties)
174     */
175    public void setOutputFormat(Properties format) {
176        aMethodIsCalled();
177    }
178
179    /**
180     * @see SerializationHandler#setOutputStream(java.io.OutputStream)
181     */
182    public void setOutputStream(OutputStream output) {
183        aMethodIsCalled();
184    }
185
186    /**
187     * @see SerializationHandler#setVersion(java.lang.String)
188     */
189    public void setVersion(String version) {
190        aMethodIsCalled();
191    }
192
193    /**
194     * @see SerializationHandler#setWriter(java.io.Writer)
195     */
196    public void setWriter(Writer writer) {
197        aMethodIsCalled();
198    }
199
200    /**
201     * @see SerializationHandler#setTransformer(javax.xml.transform.Transformer)
202     */
203    public void setTransformer(Transformer transformer) {
204        aMethodIsCalled();
205    }
206
207    /**
208     * @see SerializationHandler#getTransformer()
209     */
210    public Transformer getTransformer() {
211        aMethodIsCalled();
212        return null;
213    }
214
215    /**
216     * @see SerializationHandler#flushPending()
217     */
218    public void flushPending() throws SAXException {
219        couldThrowSAXException();
220    }
221
222    /**
223     * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
224     */
225    public void addAttribute(String uri, String localName, String rawName,
226                             String type, String value, boolean XSLAttribute)
227        throws SAXException
228    {
229        couldThrowSAXException();
230    }
231
232    /**
233     * @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
234     */
235    public void addAttributes(Attributes atts) throws SAXException {
236        couldThrowSAXException();
237    }
238
239    /**
240     * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String)
241     */
242    public void addAttribute(String name, String value) {
243        aMethodIsCalled();
244    }
245
246    /**
247     * @see ExtendedContentHandler#characters(java.lang.String)
248     */
249    public void characters(String chars) throws SAXException {
250        couldThrowSAXException();
251    }
252
253    /**
254     * @see ExtendedContentHandler#endElement(java.lang.String)
255     */
256    public void endElement(String elemName) throws SAXException {
257        couldThrowSAXException();
258    }
259
260    /**
261     * @see ExtendedContentHandler#startDocument()
262     */
263    public void startDocument() throws SAXException {
264        couldThrowSAXException();
265    }
266
267    /**
268     * @see ExtendedContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String)
269     */
270    public void startElement(String uri, String localName, String qName)
271        throws SAXException
272    {
273        couldThrowSAXException(qName);
274    }
275
276    /**
277     * @see ExtendedContentHandler#startElement(java.lang.String)
278     */
279    public void startElement(String qName) throws SAXException {
280        couldThrowSAXException(qName);
281    }
282
283    /**
284     * @see ExtendedContentHandler#namespaceAfterStartElement(java.lang.String, java.lang.String)
285     */
286    public void namespaceAfterStartElement(String uri, String prefix)
287        throws SAXException
288    {
289        couldThrowSAXException();
290    }
291    /**
292     * @see ExtendedContentHandler#startPrefixMapping(java.lang.String, java.lang.String, boolean)
293     */
294    public boolean startPrefixMapping(String prefix, String uri,
295                                      boolean shouldFlush)
296        throws SAXException
297    {
298        couldThrowSAXException();
299        return false;
300    }
301
302    /**
303     * @see ExtendedContentHandler#entityReference(java.lang.String)
304     */
305    public void entityReference(String entityName) throws SAXException {
306        couldThrowSAXException();
307    }
308
309    /**
310     * @see ExtendedContentHandler#getNamespaceMappings()
311     */
312    public NamespaceMappings getNamespaceMappings() {
313        aMethodIsCalled();
314        return null;
315    }
316
317    /**
318     * @see ExtendedContentHandler#getPrefix(java.lang.String)
319     */
320    public String getPrefix(String uri) {
321        aMethodIsCalled();
322        return null;
323    }
324
325    /**
326     * @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
327     */
328    public String getNamespaceURI(String name, boolean isElement) {
329        aMethodIsCalled();
330        return null;
331    }
332
333    /**
334     * @see ExtendedContentHandler#getNamespaceURIFromPrefix(java.lang.String)
335     */
336    public String getNamespaceURIFromPrefix(String prefix) {
337        aMethodIsCalled();
338        return null;
339    }
340
341    /**
342     * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
343     */
344    public void setDocumentLocator(Locator arg0) {
345        aMethodIsCalled();
346    }
347
348    /**
349     * @see org.xml.sax.ContentHandler#endDocument()
350     */
351    public void endDocument() throws SAXException {
352        couldThrowSAXException();
353    }
354
355    /**
356     * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
357     */
358    public void startPrefixMapping(String arg0, String arg1)
359        throws SAXException
360    {
361        couldThrowSAXException();
362    }
363
364    /**
365     * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
366     */
367    public void endPrefixMapping(String arg0) throws SAXException {
368        couldThrowSAXException();
369    }
370
371    /**
372     * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
373     */
374    public void startElement(String arg0, String arg1, String arg2,
375                             Attributes arg3)
376        throws SAXException
377    {
378        couldThrowSAXException();
379    }
380
381    /**
382     * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
383     */
384    public void endElement(String arg0, String arg1, String arg2)
385        throws SAXException
386    {
387        couldThrowSAXException();
388    }
389
390    /**
391     * @see org.xml.sax.ContentHandler#characters(char[], int, int)
392     */
393    public void characters(char[] arg0, int arg1, int arg2) throws SAXException {
394        couldThrowSAXException(arg0, arg1, arg2);
395    }
396
397    /**
398     * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
399     */
400    public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
401        throws SAXException
402    {
403        couldThrowSAXException();
404    }
405
406    /**
407     * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
408     */
409    public void processingInstruction(String arg0, String arg1)
410        throws SAXException
411    {
412        couldThrowSAXException();
413    }
414
415    /**
416     * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
417     */
418    public void skippedEntity(String arg0) throws SAXException {
419        couldThrowSAXException();
420    }
421
422    /**
423     * @see ExtendedLexicalHandler#comment(java.lang.String)
424     */
425    public void comment(String comment) throws SAXException {
426        couldThrowSAXException();
427    }
428
429    /**
430     * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
431     */
432    public void startDTD(String arg0, String arg1, String arg2)
433        throws SAXException
434    {
435        couldThrowSAXException();
436    }
437
438    /**
439     * @see org.xml.sax.ext.LexicalHandler#endDTD()
440     */
441    public void endDTD() throws SAXException {
442        couldThrowSAXException();
443    }
444
445    /**
446     * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
447     */
448    public void startEntity(String arg0) throws SAXException {
449        couldThrowSAXException();
450    }
451
452    /**
453     * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
454     */
455    public void endEntity(String arg0) throws SAXException {
456        couldThrowSAXException();
457    }
458
459    /**
460     * @see org.xml.sax.ext.LexicalHandler#startCDATA()
461     */
462    public void startCDATA() throws SAXException {
463        couldThrowSAXException();
464    }
465
466    /**
467     * @see org.xml.sax.ext.LexicalHandler#endCDATA()
468     */
469    public void endCDATA() throws SAXException {
470        couldThrowSAXException();
471    }
472
473    /**
474     * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
475     */
476    public void comment(char[] arg0, int arg1, int arg2) throws SAXException {
477        couldThrowSAXException();
478    }
479
480    /**
481     * @see XSLOutputAttributes#getDoctypePublic()
482     */
483    public String getDoctypePublic() {
484        aMethodIsCalled();
485        return null;
486    }
487
488    /**
489     * @see XSLOutputAttributes#getDoctypeSystem()
490     */
491    public String getDoctypeSystem() {
492        aMethodIsCalled();
493        return null;
494    }
495
496    /**
497     * @see XSLOutputAttributes#getEncoding()
498     */
499    public String getEncoding() {
500        aMethodIsCalled();
501        return null;
502    }
503
504    /**
505     * @see XSLOutputAttributes#getIndent()
506     */
507    public boolean getIndent() {
508        aMethodIsCalled();
509        return false;
510    }
511
512    /**
513     * @see XSLOutputAttributes#getIndentAmount()
514     */
515    public int getIndentAmount() {
516        aMethodIsCalled();
517        return 0;
518    }
519
520    /**
521     * @see XSLOutputAttributes#getMediaType()
522     */
523    public String getMediaType() {
524        aMethodIsCalled();
525        return null;
526    }
527
528    /**
529     * @see XSLOutputAttributes#getOmitXMLDeclaration()
530     */
531    public boolean getOmitXMLDeclaration() {
532        aMethodIsCalled();
533        return false;
534    }
535
536    /**
537     * @see XSLOutputAttributes#getStandalone()
538     */
539    public String getStandalone() {
540        aMethodIsCalled();
541        return null;
542    }
543
544    /**
545     * @see XSLOutputAttributes#getVersion()
546     */
547    public String getVersion() {
548        aMethodIsCalled();
549        return null;
550    }
551
552    /**
553     * @see XSLOutputAttributes#setDoctype(java.lang.String, java.lang.String)
554     */
555    public void setDoctype(String system, String pub) {
556        aMethodIsCalled();
557    }
558
559    /**
560     * @see XSLOutputAttributes#setDoctypePublic(java.lang.String)
561     */
562    public void setDoctypePublic(String doctype) {
563        aMethodIsCalled();
564    }
565
566    /**
567     * @see XSLOutputAttributes#setDoctypeSystem(java.lang.String)
568     */
569    public void setDoctypeSystem(String doctype) {
570        aMethodIsCalled();
571    }
572
573    /**
574     * @see XSLOutputAttributes#setEncoding(java.lang.String)
575     */
576    public void setEncoding(String encoding) {
577        aMethodIsCalled();
578    }
579
580    /**
581     * @see XSLOutputAttributes#setMediaType(java.lang.String)
582     */
583    public void setMediaType(String mediatype) {
584        aMethodIsCalled();
585    }
586
587    /**
588     * @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
589     */
590    public void setOmitXMLDeclaration(boolean b) {
591        aMethodIsCalled();
592    }
593
594    /**
595     * @see XSLOutputAttributes#setStandalone(java.lang.String)
596     */
597    public void setStandalone(String standalone) {
598        aMethodIsCalled();
599    }
600
601    /**
602     * @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
603     */
604    public void elementDecl(String arg0, String arg1) throws SAXException {
605        couldThrowSAXException();
606    }
607
608    /**
609     * @see org.xml.sax.ext.DeclHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
610     */
611    public void attributeDecl(String arg0, String arg1, String arg2,
612                              String arg3, String arg4)
613        throws SAXException
614    {
615        couldThrowSAXException();
616    }
617
618    /**
619     * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(java.lang.String, java.lang.String)
620     */
621    public void internalEntityDecl(String arg0, String arg1)
622        throws SAXException
623    {
624        couldThrowSAXException();
625    }
626
627    /**
628     * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
629     */
630    public void externalEntityDecl(String arg0, String arg1, String arg2)
631        throws SAXException
632    {
633        couldThrowSAXException();
634    }
635
636    /**
637     * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
638     */
639    public void warning(SAXParseException arg0) throws SAXException {
640        couldThrowSAXException();
641    }
642
643    /**
644     * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
645     */
646    public void error(SAXParseException arg0) throws SAXException {
647        couldThrowSAXException();
648    }
649
650    /**
651     * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
652     */
653    public void fatalError(SAXParseException arg0) throws SAXException {
654        couldThrowSAXException();
655    }
656
657    /**
658     * @see Serializer#asDOMSerializer()
659     */
660    public DOMSerializer asDOMSerializer() throws IOException {
661        couldThrowIOException();
662        return null;
663    }
664
665    /**
666     * @see SerializationHandler#setNamespaceMappings(NamespaceMappings)
667     */
668    public void setNamespaceMappings(NamespaceMappings mappings) {
669        aMethodIsCalled();
670    }
671
672    /**
673     * @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
674     */
675    public void setSourceLocator(SourceLocator locator) {
676        aMethodIsCalled();
677    }
678
679    /**
680     * @see ExtendedContentHandler#addUniqueAttribute(java.lang.String, java.lang.String, int)
681     */
682    public void addUniqueAttribute(String name, String value, int flags)
683        throws SAXException
684    {
685        couldThrowSAXException();
686    }
687
688    /**
689     * @see ExtendedContentHandler#characters(org.w3c.dom.Node)
690     */
691    public void characters(Node node) throws SAXException {
692        couldThrowSAXException();
693    }
694
695    /**
696     * @see ExtendedContentHandler#addXSLAttribute(java.lang.String, java.lang.String, java.lang.String)
697     */
698    public void addXSLAttribute(String qName, String value, String uri) {
699        aMethodIsCalled();
700    }
701
702    /**
703     * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
704     */
705    public void addAttribute(String uri, String localName, String rawName,
706                             String type, String value) throws SAXException {
707        couldThrowSAXException();
708    }
709
710    /**
711     * @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
712     */
713    public void notationDecl(String arg0, String arg1, String arg2)
714        throws SAXException
715    {
716        couldThrowSAXException();
717    }
718
719    /**
720     * @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
721     */
722    public void unparsedEntityDecl(String arg0, String arg1, String arg2,
723                                   String arg3) throws SAXException {
724        couldThrowSAXException();
725    }
726
727    /**
728     * @see SerializationHandler#setDTDEntityExpansion(boolean)
729     */
730    public void setDTDEntityExpansion(boolean expand) {
731        aMethodIsCalled();
732    }
733
734    public String getOutputProperty(String name) {
735        aMethodIsCalled();
736        return null;
737    }
738
739    public String getOutputPropertyDefault(String name) {
740        aMethodIsCalled();
741        return null;
742    }
743
744    public void setOutputProperty(String name, String val) {
745        aMethodIsCalled();
746    }
747
748    public void setOutputPropertyDefault(String name, String val) {
749        aMethodIsCalled();
750    }
751
752    /**
753     * @see org.apache.xml.serializer.Serializer#asDOM3Serializer()
754     */
755    public Object asDOM3Serializer() throws IOException {
756        couldThrowIOException();
757        return null;
758    }
759}
760