Processes the given path. @param __p The file to process. @throws IOException On read/write errors. @throws NullPointerException On null arguments. @since 2018/01/15
(Path __p)
| 113 | * @since 2018/01/15 |
| 114 | */ |
| 115 | private void __process(Path __p) |
| 116 | throws IOException, NullPointerException |
| 117 | { |
| 118 | if (__p == null) |
| 119 | throw new NullPointerException("NARG"); |
| 120 | |
| 121 | // Read in all bytes from the file since they will be managed and |
| 122 | // handled specially depending on which error codes were found |
| 123 | // Treat as string to extract all the error codes |
| 124 | String sdata = new String(Files.readAllBytes(__p), "utf-8"); |
| 125 | |
| 126 | // The first character of the prefix |
| 127 | String projectprefix = this.projectprefix; |
| 128 | char firstchar = projectprefix.charAt(0); |
| 129 | |
| 130 | // The output string |
| 131 | StringBuilder out = new StringBuilder(sdata.length()); |
| 132 | |
| 133 | // Go through all bytes to find sequences for replacing |
| 134 | boolean replacedsomething = false, |
| 135 | replacedthiserrorcode = false, |
| 136 | firstrun = true; |
| 137 | Code replaceme = new Code(projectprefix, 0), |
| 138 | withthis = new Code(projectprefix, 0), |
| 139 | nextcode = this._nextcode; |
| 140 | char reallylastchar = 0; |
| 141 | for (int i = 0, n = sdata.length(); i < n; i++) |
| 142 | { |
| 143 | char c = sdata.charAt(i), |
| 144 | lastchar = reallylastchar; |
| 145 | reallylastchar = c; |
| 146 | |
| 147 | // Potentially a code to be replaced |
| 148 | if (i + 4 < n && c == firstchar && |
| 149 | !Character.isAlphabetic(lastchar) && |
| 150 | !Character.isDigit(lastchar) && lastchar != '_') |
| 151 | { |
| 152 | // Replacing code |
| 153 | if (sdata.substring(i, i + 4). |
| 154 | equalsIgnoreCase(replaceme.toString())) |
| 155 | { |
| 156 | replacedsomething = true; |
| 157 | out.append(withthis.toString()); |
| 158 | i += 3; |
| 159 | |
| 160 | // Mark for debugging |
| 161 | replacedthiserrorcode = true; |
| 162 | } |
| 163 | |
| 164 | // Copy as is |
| 165 | else |
| 166 | out.append(c); |
| 167 | } |
| 168 | |
| 169 | // Declaration of a new prefix to replace |
| 170 | else if (c == '@') |
| 171 | { |
| 172 | // This is an error declaration |
no test coverage detected