| 98 | List<String> exceptions = new ArrayList<String>(); |
| 99 | |
| 100 | public Source(Class<?> _clazz, File _rootDir) { |
| 101 | clazz = _clazz; |
| 102 | String srcName = clazz.getPackage().getName().replace(".", "/") + "/" + clazz + ".java"; |
| 103 | file = new File(_rootDir, srcName); |
| 104 | try { |
| 105 | BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); |
| 106 | |
| 107 | state = STATE.JAVA; |
| 108 | List<String> openclSection = null; |
| 109 | for (String line = reader.readLine(); line != null; line = reader.readLine()) { |
| 110 | all.add(line); |
| 111 | String trimmedLine = line.trim(); |
| 112 | switch (state) { |
| 113 | case JAVA: |
| 114 | if (trimmedLine.equals(OpenCLStart)) { |
| 115 | state = STATE.OPENCL; |
| 116 | openclSection = new ArrayList<String>(); |
| 117 | opencl.add(openclSection); |
| 118 | |
| 119 | } else if (trimmedLine.startsWith(ThrowsStart) && trimmedLine.endsWith(ThrowsEnd)) { |
| 120 | exceptions.add(trimmedLine.substring(ThrowsStart.length(), trimmedLine.length() - ThrowsEnd.length())); |
| 121 | } else if (trimmedLine.equals(DocStart)) { |
| 122 | state = STATE.DOC; |
| 123 | } else { |
| 124 | java.add(line); |
| 125 | } |
| 126 | break; |
| 127 | case OPENCL: |
| 128 | if (trimmedLine.equals(OpenCLEnd)) { |
| 129 | state = STATE.JAVA; |
| 130 | } else { |
| 131 | openclSection.add(line); |
| 132 | } |
| 133 | break; |
| 134 | case DOC: |
| 135 | if (trimmedLine.equals(DocEnd)) { |
| 136 | state = STATE.JAVA; |
| 137 | } else { |
| 138 | doc.add(line); |
| 139 | } |
| 140 | break; |
| 141 | |
| 142 | } |
| 143 | } |
| 144 | } catch (FileNotFoundException e) { |
| 145 | // TODO Auto-generated catch block |
| 146 | e.printStackTrace(); |
| 147 | } catch (IOException e) { |
| 148 | // TODO Auto-generated catch block |
| 149 | e.printStackTrace(); |
| 150 | } |
| 151 | |
| 152 | } |
| 153 | |
| 154 | private String listToString(List<String> list) { |
| 155 | StringBuilder stringBuilder = new StringBuilder(); |