Beispiel #1
0
 protected String toString(UnsafeByteArrayOutputStream output) {
   if (outputEncoding != null && outputEncoding.length() > 0) {
     try {
       return new String(output.toByteArray(), outputEncoding);
     } catch (UnsupportedEncodingException e) {
       throw new IllegalStateException(e);
     }
   } else {
     return new String(output.toByteArray());
   }
 }
Beispiel #2
0
 public Object evaluate(Map<String, Object> parameters) throws ParseException {
   if (byte[].class.equals(getReturnType())) {
     UnsafeByteArrayOutputStream output = new UnsafeByteArrayOutputStream();
     try {
       render(parameters, output);
     } catch (IOException e) {
       throw new RuntimeException(e.getMessage(), e);
     }
     return output.toByteArray();
   } else {
     UnsafeStringWriter writer = new UnsafeStringWriter();
     try {
       render(parameters, writer);
     } catch (IOException e) {
       throw new RuntimeException(e.getMessage(), e);
     }
     return writer.toString();
   }
 }