1 | /** |
2 | * BSD-style license; for more info see http://xradar.sourceforge.net/license.html |
3 | */ |
4 | package org.sourceforge.xradar.ant; |
5 | |
6 | import java.io.InputStream; |
7 | import java.io.OutputStream; |
8 | |
9 | import org.apache.tools.ant.BuildException; |
10 | import org.sourceforge.xradar.AbstractProcess; |
11 | import org.sourceforge.xradar.XRadarException; |
12 | import org.sourceforge.xradar.util.StreamUtils; |
13 | |
14 | /** |
15 | * <p>An utility class to allow to extract file using the so called |
16 | * XRadar protocol, from the "outside" of XRadar. This is mostly |
17 | * aims to allow Ant to extract some Ant scripts, in order to execute |
18 | * them, from XRadar jar before actually calling XRadar to agregate |
19 | * the subconsequent results.</p> |
20 | * <p>FIXME: This class could probably be removed if we find a way |
21 | * to move the resolver registering outside of AbstractProcess.</p> |
22 | * |
23 | * |
24 | * @author Romain PELISSE, belaran@gmail.com |
25 | * |
26 | */ |
27 | public class LoaderHelper extends AbstractProcess { |
28 | /** |
29 | * <p>Default constructor.</p> |
30 | * @param online, define if the Loader |
31 | */ |
32 | public LoaderHelper(boolean online) { |
33 | super.initializedXmlCatalog((!online)); |
34 | } |
35 | |
36 | /** |
37 | * <p>The method that justify the ALL class :) </p> |
38 | * |
39 | * @param input |
40 | * @param to |
41 | * @throws Exception |
42 | */ |
43 | void extractFrom(InputStream input, OutputStream to) { |
44 | try { |
45 | StreamUtils.copy(input,to); |
46 | } catch (XRadarException e) { |
47 | throw new BuildException(e); |
48 | } |
49 | } |
50 | } |