( String s, int lineNo, int context )
| 195 | Add HTML formatting to bold the target line. |
| 196 | */ |
| 197 | String showScriptContextHTML( String s, int lineNo, int context ) |
| 198 | { |
| 199 | StringBuffer sb = new StringBuffer(); |
| 200 | BufferedReader br = new BufferedReader( new StringReader(s) ); |
| 201 | |
| 202 | int beginLine = Math.max( 1, lineNo-context ); |
| 203 | int endLine = lineNo + context; |
| 204 | for( int i=1; i<=lineNo+context+1; i++ ) |
| 205 | { |
| 206 | if ( i < beginLine ) |
| 207 | { |
| 208 | try { |
| 209 | br.readLine(); |
| 210 | } catch ( IOException e ) { |
| 211 | throw new RuntimeException( e.toString() ); |
| 212 | } |
| 213 | continue; |
| 214 | } |
| 215 | if ( i > endLine ) |
| 216 | break; |
| 217 | |
| 218 | String line; |
| 219 | try { |
| 220 | line = br.readLine(); |
| 221 | } catch ( IOException e ) { |
| 222 | throw new RuntimeException( e.toString() ); |
| 223 | } |
| 224 | |
| 225 | if ( line == null ) |
| 226 | break; |
| 227 | if ( i == lineNo ) |
| 228 | sb.append( "<font color=\"red\">"+i+": "+line +"</font><br/>" ); |
| 229 | else |
| 230 | sb.append( i+": " +line +"<br/>" ); |
| 231 | } |
| 232 | |
| 233 | return sb.toString(); |
| 234 | } |
| 235 | public void doPost( |
| 236 | HttpServletRequest request, HttpServletResponse response) |
| 237 | throws ServletException, IOException |
no test coverage detected