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