1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.xmerge.converter.xml.sxw.aportisdoc;
25 
26 import org.openoffice.xmerge.Document;
27 import org.openoffice.xmerge.ConvertData;
28 import org.openoffice.xmerge.DocumentMerger;
29 import org.openoffice.xmerge.DocumentMergerFactory;
30 import org.openoffice.xmerge.DocumentSerializer;
31 import org.openoffice.xmerge.DocumentSerializerFactory;
32 import org.openoffice.xmerge.DocumentDeserializer;
33 import org.openoffice.xmerge.DocumentDeserializerFactory;
34 import org.openoffice.xmerge.ConverterCapabilities;
35 import org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory;
36 import org.openoffice.xmerge.converter.palm.PalmDocument;
37 import org.openoffice.xmerge.util.registry.ConverterInfo;
38 import java.io.IOException;
39 import java.io.InputStream;
40 
41 /**
42  *  <p>AportisDoc implementation of the <code>PluginFactory</code>.
43  *  This encapsulates conversion of StarWriter XML format to and from
44  *  AportisDoc format.</p>
45  *
46  *  <p>The superclass produces a particular
47  *  {@link org.openoffice.xmerge.Document Document}
48  *  object, i.e. {@link
49  *  org.openoffice.xmerge.converter.xml.sxw.SxwDocument
50  *  SxwDocument} that the converters in this class works with.	Thus,
51  *  this class only implements the methods that produces the converters,
52  *  i.e. {@link
53  *  org.openoffice.xmerge.DocumentSerializer
54  *  DocumentSerializer} and {@link
55  *  org.openoffice.xmerge.DocumentDeserializer
56  *  DocumentDeserializer};
57  *  as well as the {@link
58  *  org.openoffice.xmerge.ConverterCapabilities
59  *  ConverterCapabilities} object that is specific to this format
60  *  conversion.  That superclass also  produces a {@link
61  *  org.openoffice.xmerge.DocumentMerger DocumentMerger}
62  *  object, i.e. {@link
63  *  org.openoffice.xmerge.converter.xml.sxw.aportisdoc.DocumentMergerImpl
64  *  DocumentMergerImpl} which this class derives the functionality.</p>
65  *
66  *  @author   Herbie Ong
67  */
68 public final class PluginFactoryImpl extends SxwPluginFactory
69     implements DocumentDeserializerFactory, DocumentSerializerFactory,
70     DocumentMergerFactory {
71 
PluginFactoryImpl(ConverterInfo ci)72 	public PluginFactoryImpl (ConverterInfo ci) {
73 		super(ci);
74 	}
75 
76     /** ConverterCapabilities object for this type of conversion. */
77     private final static ConverterCapabilities converterCap =
78         new ConverterCapabilitiesImpl();
79 
80 
81     /**
82      *  Returns an instance of <code>DocumentSerializerImpl</code>,
83      *  which is an implementation of the <code>DocumentSerializer</code>
84      *  interface.
85      *
86      *  @param  doc  <code>Document</code> object to be
87      *               converted/serialized.
88      *
89      *  @return  A <code>DocumentSerializerImpl</code> object.
90      */
createDocumentSerializer(Document doc)91     public DocumentSerializer createDocumentSerializer(Document doc) {
92 
93         return new DocumentSerializerImpl(doc);
94     }
95 
96 
97     /**
98      *  Returns an instance of <code>DocumentDeserializerImpl</code>,
99      *  which is an implementation of the <code>DocumentDeserializer</code>
100      *  interface.
101      *
102      *  @param  cd   <code>ConvertData</code> object for reading data
103      *               which will be converted back to a
104      *               <code>Document</code> object.
105      *
106      *  @return  A DocumentDeserializerImpl object.
107      */
createDocumentDeserializer(ConvertData cd)108     public DocumentDeserializer createDocumentDeserializer(ConvertData cd) {
109 
110         return new DocumentDeserializerImpl(cd);
111     }
112 
113 
114     /**
115      *  Returns an instance of <code>DocumentMergerImpl</code>,
116      *  which is an implementation of the <code>DocumentMerger</code>
117      *  interface.
118      *
119      *  @param  doc  <code>Document</code> to merge.
120      *
121      *  @return  A DocumentMergerImpl object.
122      */
createDocumentMerger(Document doc)123     public DocumentMerger createDocumentMerger(Document doc) {
124 
125         ConverterCapabilities cc = converterCap;
126         DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc);
127         return merger;
128     }
129 
createDeviceDocument(String name, InputStream is)130     public Document createDeviceDocument(String name, InputStream is)
131     throws IOException {
132 
133         PalmDocument palmDoc = new PalmDocument(is);
134         return palmDoc;
135     }
136 }
137 
138