1 /*
2 * #%L
3 * JRst :: Api
4 * %%
5 * Copyright (C) 2004 - 2012 CodeLutin
6 * %%
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Lesser Public License for more details.
16 *
17 * You should have received a copy of the GNU General Lesser Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20 * #L%
21 */
22 package org.nuiton.jrst;
23
24 import org.codehaus.plexus.component.annotations.Component;
25 import org.dom4j.Document;
26 import org.nuiton.jrst.legacy.JRSTReader;
27
28 import java.io.File;
29 import java.io.InputStreamReader;
30 import java.io.Reader;
31 import java.net.URL;
32
33 /**
34 * Old mecanism to transform rst file to xml format using {@link JRSTReader}.
35 *
36 * @author tchemit <chemit@codelutin.com>
37 * @since 2.0.1
38 */
39 @Component(role = JRSTToXmlStrategy.class, hint = "legacy",
40 description = "Transform a RST model (using jrst java api), " +
41 "to a xml format.")
42 public class JRSTToXmlStrategyJRSTReader implements JRSTToXmlStrategy {
43
44 @Override
45 public Document generateRstToXml(File fileIn, String encoding) throws Exception {
46 URL url = fileIn.toURI().toURL();
47 Reader in = new InputStreamReader(url.openStream(), encoding);
48
49 // parse rst file
50 JRSTReader jrst = new JRSTReader();
51 return jrst.read(in);
52 }
53 }