1   package debugger.resources;
2   
3   import java.io.*;
4   import java.net.URL;
5   
6   /**
7    * Copyright (c) Ontos AG (http://www.ontosearch.com).
8    * This class is part of JAPE Debugger component for
9    * GATE (Copyright (c) "The University of Sheffield" see http://gate.ac.uk/) <br>
10   * @author Andrey Shafirin
11   */
12  
13  public class JapeFile {
14      private URL url;
15      private File file;
16      //String encoding;
17  
18      public JapeFile(URL url) {
19          this.url = url;
20          //this.encoding = encoding;
21          if (this.url.getFile().indexOf('!') == -1) {
22              // avaliable as File
23              file = new File(this.url.getFile());
24          }
25      }
26  
27      public Reader getReader() throws IOException {
28          if (null != file) {
29              return new FileReader(file);
30          } else {
31              return new InputStreamReader(url.openStream());
32          }
33      }
34  
35      public File getFile() {
36          return file;
37      }
38  
39      public boolean canWrite() {
40          return (null != file) ? file.canWrite() : false;
41      }
42  }
43