KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > content > transform > ContentTransformer


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.content.transform;
18
19 import java.util.Map JavaDoc;
20
21 import org.alfresco.service.cmr.repository.ContentIOException;
22 import org.alfresco.service.cmr.repository.ContentReader;
23 import org.alfresco.service.cmr.repository.ContentWriter;
24
25 /**
26  * Interface for class that allow content transformation from one mimetype to another.
27  *
28  * @author Derek Hulley
29  */

30 public interface ContentTransformer
31 {
32     /**
33      * Provides the approximate accuracy with which this transformer can
34      * transform from one mimetype to another.
35      * <p>
36      * This method is used to determine, up front, which of a set of
37      * transformers will be used to perform a specific transformation.
38      *
39      * @param sourceMimetype the source mimetype
40      * @param targetMimetype the target mimetype
41      * @return Returns a score 0.0 to 1.0. 0.0 indicates that the
42      * transformation cannot be performed at all. 1.0 indicates that
43      * the transformation can be performed perfectly.
44      */

45     public double getReliability(String JavaDoc sourceMimetype, String JavaDoc targetMimetype);
46     
47     /**
48      * Provides an estimate, usually a worst case guess, of how long a transformation
49      * will take.
50      * <p>
51      * This method is used to determine, up front, which of a set of
52      * equally reliant transformers will be used for a specific transformation.
53      *
54      * @return Returns the approximate number of milliseconds per transformation
55      */

56     public long getTransformationTime();
57     
58     /**
59      * @see #transform(ContentReader, ContentWriter, Map)
60      */

61     public void transform(ContentReader reader, ContentWriter writer) throws ContentIOException;
62     
63     /**
64      * Transforms the content provided by the reader and source mimetype
65      * to the writer and target mimetype.
66      * <p>
67      * The transformation viability can be determined by an up front call
68      * to {@link #getReliability(String, String)}.
69      * <p>
70      * The source and target mimetypes <b>must</b> be available on the
71      * {@link org.alfresco.service.cmr.repository.ContentAccessor#getMimetype()} methods of
72      * both the reader and the writer.
73      * <p>
74      * Both reader and writer will be closed after the transformation completes.
75      *
76      * @param reader the source of the content
77      * @param writer the destination of the transformed content
78      * @param options options to pass to the transformer. These are transformer dependent
79      * and may be null.
80      * @throws ContentIOException if an IO exception occurs
81      */

82     public void transform(
83             ContentReader reader,
84             ContentWriter writer,
85             Map JavaDoc<String JavaDoc, Object JavaDoc> options) throws ContentIOException;
86 }
87
Popular Tags