KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xml > serializer > Serializer


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: Serializer.java,v 1.2 2004/02/17 04:18:19 minchau Exp $
18  */

19 package org.apache.xml.serializer;
20 import java.io.Writer JavaDoc;
21 import java.io.OutputStream JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.util.Properties JavaDoc;
24
25 import org.apache.xml.serializer.DOMSerializer;
26
27 import org.xml.sax.ContentHandler JavaDoc;
28
29 /**
30  * The Serializer interface is implemented by Serializers to publish methods to
31  * get and set streams and writers, to set the output properties, and get the
32  * Serializer as a ContentHandler or DOMSerializer.
33  */

34 public interface Serializer {
35
36     /**
37      * Specifies an output stream to which the document should be
38      * serialized. This method should not be called while the
39      * serializer is in the process of serializing a document.
40      * <p>
41      * The encoding specified in the output {@link Properties} is used, or
42      * if no encoding was specified, the default for the selected
43      * output method.
44      *
45      * @param output The output stream
46      */

47     public void setOutputStream(OutputStream JavaDoc output);
48
49     /**
50      * Get the output stream where the events will be serialized to.
51      *
52      * @return reference to the result stream, or null of only a writer was
53      * set.
54      */

55     public OutputStream JavaDoc getOutputStream();
56
57     /**
58      * Specifies a writer to which the document should be serialized.
59      * This method should not be called while the serializer is in
60      * the process of serializing a document.
61      * <p>
62      * The encoding specified for the output {@link Properties} must be
63      * identical to the output format used with the writer.
64      *
65      * @param writer The output writer stream
66      */

67     public void setWriter(Writer JavaDoc writer);
68
69     /**
70      * Get the character stream where the events will be serialized to.
71      *
72      * @return Reference to the result Writer, or null.
73      */

74     public Writer JavaDoc getWriter();
75
76     /**
77      * Specifies an output format for this serializer. It the
78      * serializer has already been associated with an output format,
79      * it will switch to the new format. This method should not be
80      * called while the serializer is in the process of serializing
81      * a document.
82      *
83      * @param format The output format to use
84      */

85     public void setOutputFormat(Properties JavaDoc format);
86
87     /**
88      * Returns the output format properties for this serializer.
89      *
90      * @return The output format in use
91      */

92     public Properties JavaDoc getOutputFormat();
93
94     /**
95      * Return a {@link ContentHandler} interface into this serializer.
96      * If the serializer does not support the {@link ContentHandler}
97      * interface, it should return null.
98      *
99      * @return A {@link ContentHandler} interface into this serializer,
100      * or null if the serializer is not SAX 2 capable
101      * @throws IOException An I/O exception occured
102      */

103     public ContentHandler JavaDoc asContentHandler() throws IOException JavaDoc;
104
105     /**
106      * Return a {@link DOMSerializer} interface into this serializer.
107      * If the serializer does not support the {@link DOMSerializer}
108      * interface, it should return null.
109      *
110      * @return A {@link DOMSerializer} interface into this serializer,
111      * or null if the serializer is not DOM capable
112      * @throws IOException An I/O exception occured
113      */

114     public DOMSerializer asDOMSerializer() throws IOException JavaDoc;
115
116     /**
117      * Resets the serializer. If this method returns true, the
118      * serializer may be used for subsequent serialization of new
119      * documents. It is possible to change the output format and
120      * output stream prior to serializing, or to use the existing
121      * output format and output stream.
122      *
123      * @return True if serializer has been reset and can be reused
124      */

125     public boolean reset();
126 }
127
128
Popular Tags