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