001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 /*
019 * $Id: EmptySerializer.java 471981 2006-11-07 04:28:00Z minchau $
020 */
021 package org.apache.xml.serializer;
022
023 import java.io.IOException;
024 import java.io.OutputStream;
025 import java.io.Writer;
026 import java.util.Hashtable;
027 import java.util.Properties;
028 import java.util.Vector;
029
030 import javax.xml.transform.SourceLocator;
031 import javax.xml.transform.Transformer;
032
033 import org.w3c.dom.Node;
034 import org.xml.sax.Attributes;
035 import org.xml.sax.ContentHandler;
036 import org.xml.sax.Locator;
037 import org.xml.sax.SAXException;
038 import org.xml.sax.SAXParseException;
039
040 /**
041 * This class is an adapter class. Its only purpose is to be extended and
042 * for that extended class to over-ride all methods that are to be used.
043 *
044 * This class is not a public API, it is only public because it is used
045 * across package boundaries.
046 *
047 * @xsl.usage internal
048 */
049 public class EmptySerializer implements SerializationHandler
050 {
051 protected static final String ERR = "EmptySerializer method not over-ridden";
052 /**
053 * @see SerializationHandler#asContentHandler()
054 */
055
056 protected void couldThrowIOException() throws IOException
057 {
058 return; // don't do anything.
059 }
060
061 protected void couldThrowSAXException() throws SAXException
062 {
063 return; // don't do anything.
064 }
065
066 protected void couldThrowSAXException(char[] chars, int off, int len) throws SAXException
067 {
068 return; // don't do anything.
069 }
070
071 protected void couldThrowSAXException(String elemQName) throws SAXException
072 {
073 return; // don't do anything.
074 }
075
076 protected void couldThrowException() throws Exception
077 {
078 return; // don't do anything.
079 }
080
081 void aMethodIsCalled()
082 {
083
084 // throw new RuntimeException(err);
085 return;
086 }
087
088
089 /**
090 * @see SerializationHandler#asContentHandler()
091 */
092 public ContentHandler asContentHandler() throws IOException
093 {
094 couldThrowIOException();
095 return null;
096 }
097 /**
098 * @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
099 */
100 public void setContentHandler(ContentHandler ch)
101 {
102 aMethodIsCalled();
103 }
104 /**
105 * @see SerializationHandler#close()
106 */
107 public void close()
108 {
109 aMethodIsCalled();
110 }
111 /**
112 * @see SerializationHandler#getOutputFormat()
113 */
114 public Properties getOutputFormat()
115 {
116 aMethodIsCalled();
117 return null;
118 }
119 /**
120 * @see SerializationHandler#getOutputStream()
121 */
122 public OutputStream getOutputStream()
123 {
124 aMethodIsCalled();
125 return null;
126 }
127 /**
128 * @see SerializationHandler#getWriter()
129 */
130 public Writer getWriter()
131 {
132 aMethodIsCalled();
133 return null;
134 }
135 /**
136 * @see SerializationHandler#reset()
137 */
138 public boolean reset()
139 {
140 aMethodIsCalled();
141 return false;
142 }
143 /**
144 * @see SerializationHandler#serialize(org.w3c.dom.Node)
145 */
146 public void serialize(Node node) throws IOException
147 {
148 couldThrowIOException();
149 }
150 /**
151 * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
152 */
153 public void setCdataSectionElements(Vector URI_and_localNames)
154 {
155 aMethodIsCalled();
156 }
157 /**
158 * @see SerializationHandler#setEscaping(boolean)
159 */
160 public boolean setEscaping(boolean escape) throws SAXException
161 {
162 couldThrowSAXException();
163 return false;
164 }
165 /**
166 * @see SerializationHandler#setIndent(boolean)
167 */
168 public void setIndent(boolean indent)
169 {
170 aMethodIsCalled();
171 }
172 /**
173 * @see SerializationHandler#setIndentAmount(int)
174 */
175 public void setIndentAmount(int spaces)
176 {
177 aMethodIsCalled();
178 }
179 /**
180 * @see SerializationHandler#setOutputFormat(java.util.Properties)
181 */
182 public void setOutputFormat(Properties format)
183 {
184 aMethodIsCalled();
185 }
186 /**
187 * @see SerializationHandler#setOutputStream(java.io.OutputStream)
188 */
189 public void setOutputStream(OutputStream output)
190 {
191 aMethodIsCalled();
192 }
193 /**
194 * @see SerializationHandler#setVersion(java.lang.String)
195 */
196 public void setVersion(String version)
197 {
198 aMethodIsCalled();
199 }
200 /**
201 * @see SerializationHandler#setWriter(java.io.Writer)
202 */
203 public void setWriter(Writer writer)
204 {
205 aMethodIsCalled();
206 }
207 /**
208 * @see SerializationHandler#setTransformer(javax.xml.transform.Transformer)
209 */
210 public void setTransformer(Transformer transformer)
211 {
212 aMethodIsCalled();
213 }
214 /**
215 * @see SerializationHandler#getTransformer()
216 */
217 public Transformer getTransformer()
218 {
219 aMethodIsCalled();
220 return null;
221 }
222 /**
223 * @see SerializationHandler#flushPending()
224 */
225 public void flushPending() throws SAXException
226 {
227 couldThrowSAXException();
228 }
229 /**
230 * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
231 */
232 public void addAttribute(
233 String uri,
234 String localName,
235 String rawName,
236 String type,
237 String value,
238 boolean XSLAttribute)
239 throws SAXException
240 {
241 couldThrowSAXException();
242 }
243 /**
244 * @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
245 */
246 public void addAttributes(Attributes atts) throws SAXException
247 {
248 couldThrowSAXException();
249 }
250 /**
251 * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String)
252 */
253 public void addAttribute(String name, String value)
254 {
255 aMethodIsCalled();
256 }
257
258 /**
259 * @see ExtendedContentHandler#characters(java.lang.String)
260 */
261 public void characters(String chars) throws SAXException
262 {
263 couldThrowSAXException();
264 }
265 /**
266 * @see ExtendedContentHandler#endElement(java.lang.String)
267 */
268 public void endElement(String elemName) throws SAXException
269 {
270 couldThrowSAXException();
271 }
272 /**
273 * @see ExtendedContentHandler#startDocument()
274 */
275 public void startDocument() throws SAXException
276 {
277 couldThrowSAXException();
278 }
279 /**
280 * @see ExtendedContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String)
281 */
282 public void startElement(String uri, String localName, String qName)
283 throws SAXException
284 {
285 couldThrowSAXException(qName);
286 }
287 /**
288 * @see ExtendedContentHandler#startElement(java.lang.String)
289 */
290 public void startElement(String qName) throws SAXException
291 {
292 couldThrowSAXException(qName);
293 }
294 /**
295 * @see ExtendedContentHandler#namespaceAfterStartElement(java.lang.String, java.lang.String)
296 */
297 public void namespaceAfterStartElement(String uri, String prefix)
298 throws SAXException
299 {
300 couldThrowSAXException();
301 }
302 /**
303 * @see ExtendedContentHandler#startPrefixMapping(java.lang.String, java.lang.String, boolean)
304 */
305 public boolean startPrefixMapping(
306 String prefix,
307 String uri,
308 boolean shouldFlush)
309 throws SAXException
310 {
311 couldThrowSAXException();
312 return false;
313 }
314 /**
315 * @see ExtendedContentHandler#entityReference(java.lang.String)
316 */
317 public void entityReference(String entityName) throws SAXException
318 {
319 couldThrowSAXException();
320 }
321 /**
322 * @see ExtendedContentHandler#getNamespaceMappings()
323 */
324 public NamespaceMappings getNamespaceMappings()
325 {
326 aMethodIsCalled();
327 return null;
328 }
329 /**
330 * @see ExtendedContentHandler#getPrefix(java.lang.String)
331 */
332 public String getPrefix(String uri)
333 {
334 aMethodIsCalled();
335 return null;
336 }
337 /**
338 * @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
339 */
340 public String getNamespaceURI(String name, boolean isElement)
341 {
342 aMethodIsCalled();
343 return null;
344 }
345 /**
346 * @see ExtendedContentHandler#getNamespaceURIFromPrefix(java.lang.String)
347 */
348 public String getNamespaceURIFromPrefix(String prefix)
349 {
350 aMethodIsCalled();
351 return null;
352 }
353 /**
354 * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
355 */
356 public void setDocumentLocator(Locator arg0)
357 {
358 aMethodIsCalled();
359 }
360 /**
361 * @see org.xml.sax.ContentHandler#endDocument()
362 */
363 public void endDocument() throws SAXException
364 {
365 couldThrowSAXException();
366 }
367 /**
368 * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
369 */
370 public void startPrefixMapping(String arg0, String arg1)
371 throws SAXException
372 {
373 couldThrowSAXException();
374 }
375 /**
376 * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
377 */
378 public void endPrefixMapping(String arg0) throws SAXException
379 {
380 couldThrowSAXException();
381 }
382 /**
383 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
384 */
385 public void startElement(
386 String arg0,
387 String arg1,
388 String arg2,
389 Attributes arg3)
390 throws SAXException
391 {
392 couldThrowSAXException();
393 }
394 /**
395 * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
396 */
397 public void endElement(String arg0, String arg1, String arg2)
398 throws SAXException
399 {
400 couldThrowSAXException();
401 }
402 /**
403 * @see org.xml.sax.ContentHandler#characters(char[], int, int)
404 */
405 public void characters(char[] arg0, int arg1, int arg2) throws SAXException
406 {
407 couldThrowSAXException(arg0, arg1, arg2);
408 }
409 /**
410 * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
411 */
412 public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
413 throws SAXException
414 {
415 couldThrowSAXException();
416 }
417 /**
418 * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
419 */
420 public void processingInstruction(String arg0, String arg1)
421 throws SAXException
422 {
423 couldThrowSAXException();
424 }
425 /**
426 * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
427 */
428 public void skippedEntity(String arg0) throws SAXException
429 {
430 couldThrowSAXException();
431 }
432 /**
433 * @see ExtendedLexicalHandler#comment(java.lang.String)
434 */
435 public void comment(String comment) throws SAXException
436 {
437 couldThrowSAXException();
438 }
439 /**
440 * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
441 */
442 public void startDTD(String arg0, String arg1, String arg2)
443 throws SAXException
444 {
445 couldThrowSAXException();
446 }
447 /**
448 * @see org.xml.sax.ext.LexicalHandler#endDTD()
449 */
450 public void endDTD() throws SAXException
451 {
452 couldThrowSAXException();
453 }
454 /**
455 * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
456 */
457 public void startEntity(String arg0) throws SAXException
458 {
459 couldThrowSAXException();
460 }
461 /**
462 * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
463 */
464 public void endEntity(String arg0) throws SAXException
465 {
466 couldThrowSAXException();
467 }
468 /**
469 * @see org.xml.sax.ext.LexicalHandler#startCDATA()
470 */
471 public void startCDATA() throws SAXException
472 {
473 couldThrowSAXException();
474 }
475 /**
476 * @see org.xml.sax.ext.LexicalHandler#endCDATA()
477 */
478 public void endCDATA() throws SAXException
479 {
480 couldThrowSAXException();
481 }
482 /**
483 * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
484 */
485 public void comment(char[] arg0, int arg1, int arg2) throws SAXException
486 {
487 couldThrowSAXException();
488 }
489 /**
490 * @see XSLOutputAttributes#getDoctypePublic()
491 */
492 public String getDoctypePublic()
493 {
494 aMethodIsCalled();
495 return null;
496 }
497 /**
498 * @see XSLOutputAttributes#getDoctypeSystem()
499 */
500 public String getDoctypeSystem()
501 {
502 aMethodIsCalled();
503 return null;
504 }
505 /**
506 * @see XSLOutputAttributes#getEncoding()
507 */
508 public String getEncoding()
509 {
510 aMethodIsCalled();
511 return null;
512 }
513 /**
514 * @see XSLOutputAttributes#getIndent()
515 */
516 public boolean getIndent()
517 {
518 aMethodIsCalled();
519 return false;
520 }
521 /**
522 * @see XSLOutputAttributes#getIndentAmount()
523 */
524 public int getIndentAmount()
525 {
526 aMethodIsCalled();
527 return 0;
528 }
529 /**
530 * @see XSLOutputAttributes#getMediaType()
531 */
532 public String getMediaType()
533 {
534 aMethodIsCalled();
535 return null;
536 }
537 /**
538 * @see XSLOutputAttributes#getOmitXMLDeclaration()
539 */
540 public boolean getOmitXMLDeclaration()
541 {
542 aMethodIsCalled();
543 return false;
544 }
545 /**
546 * @see XSLOutputAttributes#getStandalone()
547 */
548 public String getStandalone()
549 {
550 aMethodIsCalled();
551 return null;
552 }
553 /**
554 * @see XSLOutputAttributes#getVersion()
555 */
556 public String getVersion()
557 {
558 aMethodIsCalled();
559 return null;
560 }
561 /**
562 * @see XSLOutputAttributes#setCdataSectionElements
563 */
564 public void setCdataSectionElements(Hashtable h) throws Exception
565 {
566 couldThrowException();
567 }
568 /**
569 * @see XSLOutputAttributes#setDoctype(java.lang.String, java.lang.String)
570 */
571 public void setDoctype(String system, String pub)
572 {
573 aMethodIsCalled();
574 }
575 /**
576 * @see XSLOutputAttributes#setDoctypePublic(java.lang.String)
577 */
578 public void setDoctypePublic(String doctype)
579 {
580 aMethodIsCalled();
581 }
582 /**
583 * @see XSLOutputAttributes#setDoctypeSystem(java.lang.String)
584 */
585 public void setDoctypeSystem(String doctype)
586 {
587 aMethodIsCalled();
588 }
589 /**
590 * @see XSLOutputAttributes#setEncoding(java.lang.String)
591 */
592 public void setEncoding(String encoding)
593 {
594 aMethodIsCalled();
595 }
596 /**
597 * @see XSLOutputAttributes#setMediaType(java.lang.String)
598 */
599 public void setMediaType(String mediatype)
600 {
601 aMethodIsCalled();
602 }
603 /**
604 * @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
605 */
606 public void setOmitXMLDeclaration(boolean b)
607 {
608 aMethodIsCalled();
609 }
610 /**
611 * @see XSLOutputAttributes#setStandalone(java.lang.String)
612 */
613 public void setStandalone(String standalone)
614 {
615 aMethodIsCalled();
616 }
617 /**
618 * @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
619 */
620 public void elementDecl(String arg0, String arg1) throws SAXException
621 {
622 couldThrowSAXException();
623 }
624 /**
625 * @see org.xml.sax.ext.DeclHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
626 */
627 public void attributeDecl(
628 String arg0,
629 String arg1,
630 String arg2,
631 String arg3,
632 String arg4)
633 throws SAXException
634 {
635 couldThrowSAXException();
636 }
637 /**
638 * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(java.lang.String, java.lang.String)
639 */
640 public void internalEntityDecl(String arg0, String arg1)
641 throws SAXException
642 {
643 couldThrowSAXException();
644 }
645 /**
646 * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
647 */
648 public void externalEntityDecl(String arg0, String arg1, String arg2)
649 throws SAXException
650 {
651 couldThrowSAXException();
652 }
653 /**
654 * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
655 */
656 public void warning(SAXParseException arg0) throws SAXException
657 {
658 couldThrowSAXException();
659 }
660 /**
661 * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
662 */
663 public void error(SAXParseException arg0) throws SAXException
664 {
665 couldThrowSAXException();
666 }
667 /**
668 * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
669 */
670 public void fatalError(SAXParseException arg0) throws SAXException
671 {
672 couldThrowSAXException();
673 }
674 /**
675 * @see Serializer#asDOMSerializer()
676 */
677 public DOMSerializer asDOMSerializer() throws IOException
678 {
679 couldThrowIOException();
680 return null;
681 }
682
683 /**
684 * @see SerializationHandler#setNamespaceMappings(NamespaceMappings)
685 */
686 public void setNamespaceMappings(NamespaceMappings mappings) {
687 aMethodIsCalled();
688 }
689
690 /**
691 * @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
692 */
693 public void setSourceLocator(SourceLocator locator)
694 {
695 aMethodIsCalled();
696 }
697
698 /**
699 * @see ExtendedContentHandler#addUniqueAttribute(java.lang.String, java.lang.String, int)
700 */
701 public void addUniqueAttribute(String name, String value, int flags)
702 throws SAXException
703 {
704 couldThrowSAXException();
705 }
706
707 /**
708 * @see ExtendedContentHandler#characters(org.w3c.dom.Node)
709 */
710 public void characters(Node node) throws SAXException
711 {
712 couldThrowSAXException();
713 }
714
715 /**
716 * @see ExtendedContentHandler#addXSLAttribute(java.lang.String, java.lang.String, java.lang.String)
717 */
718 public void addXSLAttribute(String qName, String value, String uri)
719 {
720 aMethodIsCalled();
721 }
722
723 /**
724 * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
725 */
726 public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException
727 {
728 couldThrowSAXException();
729 }
730 /**
731 * @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
732 */
733 public void notationDecl(String arg0, String arg1, String arg2) throws SAXException
734 {
735 couldThrowSAXException();
736 }
737
738 /**
739 * @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
740 */
741 public void unparsedEntityDecl(
742 String arg0,
743 String arg1,
744 String arg2,
745 String arg3)
746 throws SAXException {
747 couldThrowSAXException();
748 }
749
750 /**
751 * @see SerializationHandler#setDTDEntityExpansion(boolean)
752 */
753 public void setDTDEntityExpansion(boolean expand) {
754 aMethodIsCalled();
755
756 }
757
758
759 public String getOutputProperty(String name) {
760 aMethodIsCalled();
761 return null;
762 }
763
764 public String getOutputPropertyDefault(String name) {
765 aMethodIsCalled();
766 return null;
767 }
768
769 public void setOutputProperty(String name, String val) {
770 aMethodIsCalled();
771
772 }
773
774 public void setOutputPropertyDefault(String name, String val) {
775 aMethodIsCalled();
776
777 }
778
779 /**
780 * @see org.apache.xml.serializer.Serializer#asDOM3Serializer()
781 */
782 public Object asDOM3Serializer() throws IOException
783 {
784 couldThrowIOException();
785 return null;
786 }
787 }