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