Last change
on this file since 78 was
78,
checked in by psniegowski, 11 years ago
|
Add f0 parsing and f0->Model transformation.
|
File size:
1.4 KB
|
Line | |
---|
1 | package com.framsticks.parsers; |
---|
2 | |
---|
3 | import com.framsticks.params.SourceInterface; |
---|
4 | |
---|
5 | import java.io.*; |
---|
6 | |
---|
7 | |
---|
8 | public class FileSource implements SourceInterface { |
---|
9 | |
---|
10 | private BufferedReader reader; |
---|
11 | private String filename; |
---|
12 | |
---|
13 | public FileSource(String filename) throws IOException |
---|
14 | { |
---|
15 | this.filename = filename; |
---|
16 | reader = new BufferedReader(new FileReader(filename)); |
---|
17 | } |
---|
18 | |
---|
19 | public FileSource(InputStream stream) { |
---|
20 | filename = "<stream>"; |
---|
21 | reader = new BufferedReader(new InputStreamReader(stream)); |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | @Override |
---|
26 | public String readLine() |
---|
27 | { |
---|
28 | try |
---|
29 | { |
---|
30 | return reader.readLine(); |
---|
31 | } catch (IOException ignored) { |
---|
32 | |
---|
33 | } |
---|
34 | return null; |
---|
35 | } |
---|
36 | |
---|
37 | @Override |
---|
38 | public String getFilename() |
---|
39 | { |
---|
40 | return filename; |
---|
41 | } |
---|
42 | |
---|
43 | @Override |
---|
44 | public String demangleInclude(String include) |
---|
45 | { |
---|
46 | if (!include.contains(java.io.File.separator)) { |
---|
47 | String currentFilePath = (new java.io.File(filename)).getParent(); |
---|
48 | if (!String.valueOf( |
---|
49 | currentFilePath.charAt(currentFilePath.length() - 1)) |
---|
50 | .equals(java.io.File.separator)) { |
---|
51 | currentFilePath = currentFilePath + java.io.File.separator; |
---|
52 | } |
---|
53 | include = currentFilePath + include; |
---|
54 | } |
---|
55 | return include; |
---|
56 | } |
---|
57 | |
---|
58 | @Override |
---|
59 | public SourceInterface openInclude(String include) |
---|
60 | { |
---|
61 | try |
---|
62 | { |
---|
63 | return new FileSource(include); |
---|
64 | } |
---|
65 | catch(IOException e) |
---|
66 | { |
---|
67 | |
---|
68 | } |
---|
69 | return null; |
---|
70 | } |
---|
71 | |
---|
72 | @Override |
---|
73 | public void close() |
---|
74 | { |
---|
75 | try { |
---|
76 | reader.close(); |
---|
77 | } catch (IOException e) { |
---|
78 | |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.