jaxp/src/com/sun/org/apache/xml/internal/serialize/Serializer.java
author joehw
Tue, 29 Jul 2014 20:52:36 -0700
changeset 25834 aba3efbf4ec5
parent 12457 c348e06f0e82
permissions -rw-r--r--
8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer. Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
25834
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     8
 * this work for additional information regarding copyright ownership.
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
package com.sun.org.apache.xml.internal.serialize;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import java.io.IOException;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import java.io.OutputStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import java.io.Writer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import org.xml.sax.ContentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import org.xml.sax.DocumentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * Interface for a DOM serializer implementation, factory for DOM and SAX
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 * serializers, and static methods for serializing DOM documents.
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * To serialize a document using SAX events, create a compatible serializer
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * and pass it around as a {@link
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * org.xml.sax.DocumentHandler}. If an I/O error occurs while serializing, it will
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * be thrown by {@link DocumentHandler#endDocument}. The SAX serializer
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * may also be used as {@link org.xml.sax.DTDHandler}, {@link org.xml.sax.ext.DeclHandler} and
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * {@link org.xml.sax.ext.LexicalHandler}.
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * To serialize a DOM document or DOM element, create a compatible
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * serializer and call it's {@link
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * DOMSerializer#serialize(Document)} or {@link DOMSerializer#serialize(Element)} methods.
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * Both methods would produce a full XML document, to serizlie only
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * the portion of the document use {@link OutputFormat#setOmitXMLDeclaration}
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * and specify no document type.
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * <p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * The {@link OutputFormat} dictates what underlying serialized is used
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * to serialize the document based on the specified method. If the output
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 * format or method are missing, the default is an XML serializer with
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 * UTF-8 encoding and now indentation.
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * @author <a href="mailto:Scott_Boag/CAM/Lotus@lotus.com">Scott Boag</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 * @see DocumentHandler
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
 * @see ContentHandler
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
 * @see OutputFormat
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
 * @see DOMSerializer
25834
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    64
 *
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    65
 * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    66
 * is replaced by that of Xalan. Main class
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    67
 * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    68
 * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
public interface Serializer
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
     * Specifies an output stream to which the document should be
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
     * serialized. This method should not be called while the
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
     * serializer is in the process of serializing a document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
    public void setOutputByteStream(OutputStream output);
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
     * Specifies a writer to which the document should be serialized.
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
     * This method should not be called while the serializer is in
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
     * the process of serializing a document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    public void setOutputCharStream( Writer output );
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     * Specifies an output format for this serializer. It the
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
     * serializer has already been associated with an output format,
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
     * it will switch to the new format. This method should not be
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
     * called while the serializer is in the process of serializing
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
     * a document.
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     * @param format The output format to use
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    public void setOutputFormat( OutputFormat format );
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
     * Return a {@link DocumentHandler} interface into this serializer.
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
     * If the serializer does not support the {@link DocumentHandler}
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
     * interface, it should return null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
    public DocumentHandler asDocumentHandler()
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
        throws IOException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
     * Return a {@link ContentHandler} interface into this serializer.
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
     * If the serializer does not support the {@link ContentHandler}
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     * interface, it should return null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
    public ContentHandler asContentHandler()
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
        throws IOException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
     * Return a {@link DOMSerializer} interface into this serializer.
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
     * If the serializer does not support the {@link DOMSerializer}
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
     * interface, it should return null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
    public DOMSerializer asDOMSerializer()
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
        throws IOException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
}