Execute template self and return how many characters it wrote to out. @return the number of characters written to out
(STWriter out, InstanceScope scope)
| 151 | */ |
| 152 | |
| 153 | public int exec(STWriter out, InstanceScope scope) { |
| 154 | final ST self = scope.st; |
| 155 | if ( trace ) System.out.println("exec("+self.getName()+")"); |
| 156 | try { |
| 157 | setDefaultArguments(out, scope); |
| 158 | return _exec(out, scope); |
| 159 | } |
| 160 | catch (Exception e) { |
| 161 | StringWriter sw = new StringWriter(); |
| 162 | PrintWriter pw = new PrintWriter(sw); |
| 163 | e.printStackTrace(pw); |
| 164 | pw.flush(); |
| 165 | errMgr.runTimeError(this, |
| 166 | scope, |
| 167 | ErrorType.INTERNAL_ERROR, "internal error: "+sw.toString()); |
| 168 | return 0; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | protected int _exec(STWriter out, InstanceScope scope) { |
| 173 | final ST self = scope.st; |
no test coverage detected