View Javadoc

1   /*
2    * $Id: ITranslator.java,v 1.2 2005/05/31 20:25:08 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8    
9   package com.bbn.swede.tools.translator;
10  
11  import java.io.File;
12  import java.io.OutputStream;
13  
14  import org.eclipse.core.resources.IFile;
15  
16  /***
17   * This is the interface that must be implemented by all translators 
18   * in order to function with SWeDE's translation extension point.
19   * 
20   * The default implementation, which is intended to be subclassed is 
21   * {@link AbstractTranslator}.  
22   * 
23   * @author aperezlo
24   */
25  public interface ITranslator
26  {
27     /***
28      * This is the method that is invoked to perform a translation.
29      * <br><br>
30      * The <code>inputFile</code> is a java.io.File that represents the 
31      * source of the translation, and it is encoded in the format specified 
32      * by the string <code>inputFormatExtension</code>.  Similiarly, the ouputStream is 
33      * the resource to which translation results should be written in the format 
34      * specified by <code>outputFormatExtension</code>.  These format strings will be 
35      * the case-sensitive extensions of the resources to be translated, and are to be 
36      * specified by translator implementers in their <code>plugin.xml</code> files.  
37      * 
38      * For an example of an implemented translator, which is derived from 
39      * {@link AbstractTranslator}, see {@link JenaTranslator}.
40      * 
41      * @param inputFile the file where the source content resides 
42      * @param outputStream the stream to which the translation results should be output
43      * @param inputFormatExtension the extension identifying the input content
44      * @param outputFormatExtension the extension identifying the output content
45      * @return <code>null</code> if translation completed successfully, 
46      *         otherwise an error message describing the problem 
47      * @throws Exception if an error occurs during translation
48      * @see AbstractTranslator
49      * @see JenaTranslator
50      */
51     String doTranslation(File inputFile, OutputStream outputStream,
52        String inputFormatExtension, String outputFormatExtension)
53        throws Exception;
54  
55     /***
56      * Same as with {@link #doTranslation(File, OutputStream, String, String)},
57      * except with an Eclipse IFile instead of a java.io.File.
58      * 
59      * @param inputFile the file where the source content resides 
60      * @param outputStream the stream to which the translation results should be output
61      * @param inputFormatExtension the extension identifying the input content
62      * @param outputFormatExtension the extension identifying the output content
63      * @return <code>null</code> if translation completed successfully, 
64      *         otherwise an error message describing the problem 
65      * @throws Exception if an error occurs during translation
66      */
67     String doTranslation(IFile inputFile, OutputStream outputStream,
68        String inputFormatExtension, String outputFormatExtension)
69        throws Exception;
70     
71     
72  }