+ public boolean writeAsFile = false;
+
+ @Override
+ public ContentBody formatForInput(RestJob rj)
+ throws UnsupportedEncodingException, NoValidInputDataException
+ {
+ AlignmentI alignment = rj.getAlignmentForInput(token, type);
+ if (writeAsFile)
+ {
+ try
+ {
+ File fa = File.createTempFile("jvmime", ".fa");
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(
+ new BufferedOutputStream(new FileOutputStream(fa)),
+ "UTF-8"));
+ pw.append(new FormatAdapter().formatSequences(format, alignment,
+ jvsuffix));
+ pw.close();
+ return new FileBody(fa, "text/plain");
+ } catch (Exception ex)
+ {
+ throw new NoValidInputDataException(
+ "Couldn't write out alignment to file.", ex);
+ }
+ }
+ else
+ {
+ FormatAdapter fa = new FormatAdapter();
+ fa.setNewlineString("\r\n");
+ return new StringBody(
+ (fa.formatSequences(format, alignment, jvsuffix)));
+ // ,
+ // "text/plain",Charset.forName("UTF-8"));
+ // , "text/plain", Charset.forName("UTF-8"));
+ // sb.getContentTypeParameters().put("filename", "alignment.fa");
+ }
+ }
+