View Javadoc
1   package eu.simuline.m2latex.core;
2   
3   // TBD: make complete
4   // TBD: specify what a category is: options, invocation, file interface 
5   /**
6    * This enum represents categores of converters. 
7    * Two converters are in the same category,
8    * if they can used in the same command setting in {@link Settings} 
9    * and, if used as a maven plugin equivalently,
10   * a command setting in the configuration in the pom.
11   * So in a sense the category represents the commands settings. 
12   * Consequently, each category has a method {@link #getCommandFieldname()}
13   * returning the according field in the settings. 
14   *
15   */
16  // TBD: take advantage of the fact,
17  //that most entries are related to the fieldname: 
18  // lowercase and add 'Command'. 
19  enum ConverterCategory {
20  	// LaTeX: mostly to pdf but also to dvi
21  	// This is slightly inconsistent.
22  	// TBD: shall be Latex2dev
23  	LaTeX() {
24  		String getExtName() {
25  			return "latex2pdf";// TBD: bad name because also dvi and xdv 
26  		}
27  	},
28  	// TBD: clarify: not yet used really
29  	Latex2Html() {
30  		String getExtName() {
31  			throw new UnsupportedOperationException();
32  		}
33  	},
34  	// TBD: check: not used.
35  	// LaTeX2Odt() {
36  	// String getFieldname() {
37  	// throw new UnsupportedOperationException();
38  	// }
39  	// },
40  	LaTeX2Rtf() {
41  		String getExtName() {
42  			return "latex2rtf";
43  		}
44  	},
45  	BibTeX() {
46  		String getExtName() {
47  			return "bibtex";
48  		}
49  	},
50  	MakeIndex() {
51  		String getExtName() {
52  			return "makeIndex";
53  		}
54  	},
55  	MakeGlossaries() {
56  		String getExtName() {
57  			return "makeGlossaries";
58  		}
59  	},
60  	SplitIndex() {
61  		String getExtName() {
62  			return "splitIndex";
63  		}
64  	},
65  	Pythontex() {
66  		String getExtName() {
67  			return "pythontex";
68  		}
69  	},
70  	DePythontex() {
71  		String getExtName() {
72  			return "depythontex";
73  		}
74  	},
75  	LatexChk() {// TBD: eliminate inconsistency
76  		String getExtName() {
77  			return "chkTex";
78  		}
79  	},
80  	DiffPdf() {
81  		String getExtName() {
82  			return "diffPdf";
83  		}
84  	},
85    /**
86     * Converters transforming <code>dvi</code> files into pdf files. 
87     * Some of them can also convert <code>xdv</code> to <code>pdf</code>, 
88     * but this is immaterial, 
89     * because the <code>xdv</code> format is not supported. 
90     * The currently registered converters, {@link Converter#Dvipdfm}, 
91     * {@link Converter#Dvipdfmx}, {@link Converter#XDvipdfmx} 
92     * and {@link Converter#Dvipdft} 
93     * can all convert <code>xdv</code> files. 
94     * At least for texlive, 
95     * all of these converters can be run with filename including the extension 
96     * or without extension. 
97     * If both extensions, <code>dvi</code> and <code>xdv</code> are found, 
98     * the <code>xdv</code> is processed, else the file which is found. 
99     * Of course if neither extension is found an error is emitted. 
100    * <p>
101    * Note also, 
102    * that <code>dvipdf</code> is currently not among the {@link Converter}s, 
103    * and if it is it does not belong to this category 
104    * becausse it does not provide proper options. 
105    */
106 	Dvi2Pdf() {
107 		String getExtName() {
108 			return "dvi2pdf";
109 		}
110 	},
111   MetaInfoPdf() {
112     String getExtName() {
113 			return "pdfMetainfo";
114 		}
115   },
116 	MetaPost() {
117 		String getExtName() {
118 			return "metapost";
119 		}
120 	},
121 	Svg2Dev() {
122 		String getExtName() {
123 			return "svg2dev";
124 		}
125 	},
126 	Fig2Dev() {
127 		String getExtName() {
128 			return "fig2dev";
129 		}
130 	},
131 	Gnuplot2Dev() {
132 		String getExtName() {
133 			return "gnuplot";
134 		}
135 	},
136 	Odt2Doc() {
137 		String getExtName() {
138 			return "odt2doc";
139 		}
140 	},
141 	Pdf2Txt() {
142 		String getExtName() {
143 			return "pdf2txt";
144 		}
145 	},
146 	EbbCmd() {
147 		String getExtName() {
148 			return "ebb";
149 		}
150 	},
151 	Latexmk() {
152 		String getExtName() {
153 			return "latexmk";
154 		}
155 	},
156   StandardValidator() {
157 		String getExtName() {
158 			return "verifyStd";
159 		}
160   },
161 	// Those are not usable
162 	// TBD: clarify: For latex to html/odt
163 	// dvips: for conversion to ps??
164 	// gs
165 	// pdfinfo, exiftool
166 	// upmendex: right interface?
167 	// xindy
168 	// pythontex, depythontex
169 	Unspecific {
170 		String getExtName() {
171 			throw new UnsupportedOperationException();
172 		}
173 	},
174   /**
175    * Category of converters in an abstract sense 
176    * which are not configurable in the settings. 
177    * Currently, these are build tools, i.e. maven and ant 
178    * and programming languages like java, python and Perl. 
179    * Could be Environment. 
180    */
181   Unparametrized {
182 		String getExtName() {
183 			throw new UnsupportedOperationException();
184 		}
185 	};
186 
187 	// may throw UnsupportedOperationException
188   /**
189    * Returns the name of the field in the configuration 
190    * containing the command of the converter of this category. 
191    * 
192    * @return
193    *    the name of the field in the configuration 
194    *    containing the command of the converter of this category. 
195    *    This is just {@link #getExtName()} 
196    *    followed by the literal <code>Command</code>. 
197    */
198 	String getCommandFieldname() {
199 		return this.getExtName() + "Command";
200 	}
201 
202 	// may throw UnsupportedOperationException
203   /**
204    * Returns the name under which the category occurs in the configuration. 
205    * This applies at least to the command (see {@link #getCommandFieldname()}) 
206    * and to the options. 
207    * 
208    * @return
209    *    the name under which the category occurs in the configuration. 
210    * @throws UnsupportedOperationException
211    *    For categories {@link #Unparametrized} and {@link #Unspecific}
212    */
213 	abstract String getExtName();
214 
215 }