KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > transcoder > image > ReaderTest


1 /*
2
3    Copyright 2001-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.transcoder.image;
19
20 import java.io.IOException JavaDoc;
21 import java.io.InputStreamReader JavaDoc;
22 import java.io.Reader JavaDoc;
23 import java.net.URL JavaDoc;
24
25 import org.apache.batik.transcoder.TranscoderInput;
26
27 /**
28  * Test the ImageTranscoder input with a Reader.
29  *
30  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
31  * @version $Id: ReaderTest.java,v 1.5 2004/08/18 07:17:13 vhardy Exp $
32  */

33 public class ReaderTest extends AbstractImageTranscoderTest {
34
35     /** The URI of the input image. */
36     protected String JavaDoc inputURI;
37
38     /** The URI of the reference image. */
39     protected String JavaDoc refImageURI;
40
41     /**
42      * Constructs a new <tt>ReaderTest</tt>.
43      *
44      * @param inputURI the URI of the input image
45      * @param the URI of the reference image
46      */

47     public ReaderTest(String JavaDoc inputURI, String JavaDoc refImageURI) {
48     this.inputURI = inputURI;
49     this.refImageURI = refImageURI;
50     }
51
52     /**
53      * Creates the <tt>TranscoderInput</tt>.
54      */

55     protected TranscoderInput createTranscoderInput() {
56     try {
57         URL JavaDoc url = resolveURL(inputURI);
58         Reader JavaDoc reader = new InputStreamReader JavaDoc(url.openStream());
59         TranscoderInput input = new TranscoderInput(reader);
60         input.setURI(url.toString()); // Needed for external resources
61
return input;
62     } catch (IOException JavaDoc ex) {
63             throw new IllegalArgumentException JavaDoc(inputURI);
64     }
65     }
66
67     /**
68      * Returns the reference image for this test.
69      */

70     protected byte [] getReferenceImageData() {
71     return createBufferedImageData(resolveURL(refImageURI));
72     }
73 }
74
Popular Tags