6
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Copyright 1999-2002,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 |
|
|
22 |
package com.sun.org.apache.xml.internal.serialize;
|
|
23 |
|
|
24 |
|
|
25 |
import java.io.IOException;
|
|
26 |
import java.io.OutputStream;
|
|
27 |
import java.io.Writer;
|
|
28 |
|
|
29 |
import org.xml.sax.ContentHandler;
|
|
30 |
import org.xml.sax.DocumentHandler;
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Interface for a DOM serializer implementation, factory for DOM and SAX
|
|
35 |
* serializers, and static methods for serializing DOM documents.
|
|
36 |
* <p>
|
|
37 |
* To serialize a document using SAX events, create a compatible serializer
|
|
38 |
* and pass it around as a {@link
|
|
39 |
* org.xml.sax.DocumentHandler}. If an I/O error occurs while serializing, it will
|
|
40 |
* be thrown by {@link DocumentHandler#endDocument}. The SAX serializer
|
|
41 |
* may also be used as {@link org.xml.sax.DTDHandler}, {@link org.xml.sax.ext.DeclHandler} and
|
|
42 |
* {@link org.xml.sax.ext.LexicalHandler}.
|
|
43 |
* <p>
|
|
44 |
* To serialize a DOM document or DOM element, create a compatible
|
|
45 |
* serializer and call it's {@link
|
|
46 |
* DOMSerializer#serialize(Document)} or {@link DOMSerializer#serialize(Element)} methods.
|
|
47 |
* Both methods would produce a full XML document, to serizlie only
|
|
48 |
* the portion of the document use {@link OutputFormat#setOmitXMLDeclaration}
|
|
49 |
* and specify no document type.
|
|
50 |
* <p>
|
|
51 |
* The {@link OutputFormat} dictates what underlying serialized is used
|
|
52 |
* to serialize the document based on the specified method. If the output
|
|
53 |
* format or method are missing, the default is an XML serializer with
|
|
54 |
* UTF-8 encoding and now indentation.
|
|
55 |
*
|
|
56 |
*
|
|
57 |
* @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
|
|
58 |
* @author <a href="mailto:Scott_Boag/CAM/Lotus@lotus.com">Scott Boag</a>
|
|
59 |
* @see DocumentHandler
|
|
60 |
* @see ContentHandler
|
|
61 |
* @see OutputFormat
|
|
62 |
* @see DOMSerializer
|
|
63 |
*/
|
|
64 |
public interface Serializer
|
|
65 |
{
|
|
66 |
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Specifies an output stream to which the document should be
|
|
70 |
* serialized. This method should not be called while the
|
|
71 |
* serializer is in the process of serializing a document.
|
|
72 |
*/
|
|
73 |
public void setOutputByteStream(OutputStream output);
|
|
74 |
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Specifies a writer to which the document should be serialized.
|
|
78 |
* This method should not be called while the serializer is in
|
|
79 |
* the process of serializing a document.
|
|
80 |
*/
|
|
81 |
public void setOutputCharStream( Writer output );
|
|
82 |
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Specifies an output format for this serializer. It the
|
|
86 |
* serializer has already been associated with an output format,
|
|
87 |
* it will switch to the new format. This method should not be
|
|
88 |
* called while the serializer is in the process of serializing
|
|
89 |
* a document.
|
|
90 |
*
|
|
91 |
* @param format The output format to use
|
|
92 |
*/
|
|
93 |
public void setOutputFormat( OutputFormat format );
|
|
94 |
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Return a {@link DocumentHandler} interface into this serializer.
|
|
98 |
* If the serializer does not support the {@link DocumentHandler}
|
|
99 |
* interface, it should return null.
|
|
100 |
*/
|
|
101 |
public DocumentHandler asDocumentHandler()
|
|
102 |
throws IOException;
|
|
103 |
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Return a {@link ContentHandler} interface into this serializer.
|
|
107 |
* If the serializer does not support the {@link ContentHandler}
|
|
108 |
* interface, it should return null.
|
|
109 |
*/
|
|
110 |
public ContentHandler asContentHandler()
|
|
111 |
throws IOException;
|
|
112 |
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Return a {@link DOMSerializer} interface into this serializer.
|
|
116 |
* If the serializer does not support the {@link DOMSerializer}
|
|
117 |
* interface, it should return null.
|
|
118 |
*/
|
|
119 |
public DOMSerializer asDOMSerializer()
|
|
120 |
throws IOException;
|
|
121 |
|
|
122 |
|
|
123 |
}
|