Esempio n. 1
0
  @Override
  public String writeContent(final XmlEmit xml, final Writer wtr, final String contentType)
      throws WebdavException {
    try {
      if ("application/vcard+json".equals(contentType)) {
        if (xml == null) {
          wtr.write(card.outputJson(debug, vcardVersion));
        } else {
          xml.cdataValue(card.outputJson(debug, vcardVersion));
        }
        return contentType;
      }

      if (xml == null) {
        wtr.write(card.output(vcardVersion));
        return "text/vcard";
      }

      xml.cdataValue(card.output(vcardVersion));
      return "application/vcard+xml";
    } catch (final WebdavException we) {
      throw we;
    } catch (Throwable t) {
      throw new WebdavException(t);
    }
  }
 /**
  * Exports the throughput times of all process instances in piList to a comma-seperated text-file.
  *
  * @param piList ArrayList: the process instances used
  * @param file File: the file to which the times are exported
  * @param divider long: the time divider used
  * @param sort String: the time sort used
  * @param fitOption int: the fit option used (how to deal with non-conformance)
  * @throws IOException
  */
 public void exportToFile(ArrayList piList, File file, long divider, String sort, int fitOption)
     throws IOException {
   Writer output = new BufferedWriter(new FileWriter(file));
   String line = "Log Trace,Throughput time (" + sort + ")\n";
   output.write(line);
   ListIterator lit = piList.listIterator();
   while (lit.hasNext()) {
     ExtendedLogTrace currentTrace = (ExtendedLogTrace) lit.next();
     try {
       double tp =
           (currentTrace.getEndDate().getTime() - currentTrace.getBeginDate().getTime())
               * 1.0
               / divider;
       if (fitOption == 0) {
         // times based on all traces
         line = currentTrace.getName() + "," + tp + "\n";
         // write line to the file
         output.write(line);
       }
       if (fitOption == 1
           && currentTrace.hasProperlyTerminated()
           && currentTrace.hasSuccessfullyExecuted()) {
         // times based on fitting traces only
         line = currentTrace.getName() + "," + tp + "\n";
         // write line to the file
         output.write(line);
       }
     } catch (NullPointerException npe) {
     }
   }
   // close the file
   output.close();
 }
Esempio n. 3
0
 protected void drawHtmlPreSubsForm(Writer out) throws IOException {
   out.write(
       "<form action=\"" //$NON-NLS-1$
           + this.getAction()
           + "\" name=\"mgnlFormMain\" method=\"post\" enctype=\"multipart/form-data\">\n"); //$NON-NLS-1$
   out.write(
       new Hidden("mgnlDialog", this.getConfigValue("dialog"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   out.write(
       new Hidden("mgnlRepository", this.getConfigValue("repository"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   out.write(
       new Hidden("mgnlPath", this.getConfigValue("path"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   out.write(
       new Hidden("mgnlNodeCollection", this.getConfigValue("nodeCollection"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   out.write(
       new Hidden("mgnlNode", this.getConfigValue("node"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   out.write(
       new Hidden("mgnlJsCallback", this.getCallbackJavascript(), false).getHtml()); // $NON-NLS-1$
   out.write(
       new Hidden("mgnlRichE", this.getConfigValue("richE"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   out.write(
       new Hidden("mgnlRichEPaste", this.getConfigValue("richEPaste"), false)
           .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   if (this.getConfigValue("paragraph").indexOf(",") == -1) { // $NON-NLS-1$ //$NON-NLS-2$
     out.write(
         new Hidden("mgnlParagraph", this.getConfigValue("paragraph"), false)
             .getHtml()); //$NON-NLS-1$ //$NON-NLS-2$
   } // else multiple paragraph selection -> radios for selection
 }
Esempio n. 4
0
  /**
   * Creates a new journal that omits redundant information. This replaces the current journal if it
   * exists.
   */
  private synchronized void rebuildJournal() throws IOException {
    if (journalWriter != null) {
      journalWriter.close();
    }

    Writer writer = new BufferedWriter(new FileWriter(journalFileTmp), IO_BUFFER_SIZE);
    writer.write(MAGIC);
    writer.write("\n");
    writer.write(VERSION_1);
    writer.write("\n");
    writer.write(Integer.toString(appVersion));
    writer.write("\n");
    writer.write(Integer.toString(valueCount));
    writer.write("\n");
    writer.write("\n");

    for (Entry entry : lruEntries.values()) {
      if (entry.currentEditor != null) {
        writer.write(DIRTY + ' ' + entry.key + '\n');
      } else {
        writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
      }
    }

    writer.close();
    journalFileTmp.renameTo(journalFile);
    journalWriter = new BufferedWriter(new FileWriter(journalFile, true), IO_BUFFER_SIZE);
  }
 private static File convertGLFile(File originalFile) throws IOException {
   // Now translate the file; remove commas, then convert "::" delimiter to comma
   File resultFile = new File(new File(System.getProperty("java.io.tmpdir")), "ratings.txt");
   if (resultFile.exists()) {
     resultFile.delete();
   }
   Writer writer = null;
   try {
     writer = new OutputStreamWriter(new FileOutputStream(resultFile), Charsets.UTF_8);
     for (String line : new FileLineIterable(originalFile, false)) {
       int lastDelimiterStart = line.lastIndexOf(COLON_DELIMTER);
       if (lastDelimiterStart < 0) {
         throw new IOException("Unexpected input format on line: " + line);
       }
       String subLine = line.substring(0, lastDelimiterStart);
       String convertedLine = COLON_DELIMITER_PATTERN.matcher(subLine).replaceAll(",");
       writer.write(convertedLine);
       writer.write('\n');
     }
   } catch (IOException ioe) {
     resultFile.delete();
     throw ioe;
   } finally {
     Closeables.close(writer, false);
   }
   return resultFile;
 }
Esempio n. 6
0
  private String runJob() throws Exception {
    OutputStream os = getFileSystem().create(new Path(getInputDir(), "text.txt"));
    Writer wr = new OutputStreamWriter(os);
    wr.write("hello1\n");
    wr.write("hello2\n");
    wr.write("hello3\n");
    wr.close();

    JobConf conf = createJobConf();
    conf.setJobName("mr");
    conf.setJobPriority(JobPriority.HIGH);

    conf.setInputFormat(TextInputFormat.class);

    conf.setMapOutputKeyClass(LongWritable.class);
    conf.setMapOutputValueClass(Text.class);

    conf.setOutputFormat(TextOutputFormat.class);
    conf.setOutputKeyClass(LongWritable.class);
    conf.setOutputValueClass(Text.class);

    conf.setMapperClass(org.apache.hadoop.mapred.lib.IdentityMapper.class);
    conf.setReducerClass(org.apache.hadoop.mapred.lib.IdentityReducer.class);

    FileInputFormat.setInputPaths(conf, getInputDir());
    FileOutputFormat.setOutputPath(conf, getOutputDir());

    return JobClient.runJob(conf).getID().toString();
  }
Esempio n. 7
0
    /** writer a column */
    public void write(String content) throws IOException {

      if (content == null) {
        content = "";
      }

      if (!firstColumn) {
        writer.write(Delimiter);
      }

      writer.write(TextQualifier);

      // support backslash mode
      if (EscapeMode == ESCAPE_MODE_BACKSLASH) {
        content = replace(content, "" + BACKSLASH, "" + BACKSLASH + BACKSLASH);
        content = replace(content, "" + TextQualifier, "" + BACKSLASH + TextQualifier);
      } else { // support double mode
        content = replace(content, "" + TextQualifier, "" + TextQualifier + TextQualifier);
      }

      writer.write(content);

      writer.write(TextQualifier);

      firstColumn = false;
    }
Esempio n. 8
0
  /** Prints a long. */
  public final void print(long v) {
    Writer out = this.out;
    if (out == null) return;

    if (v == 0x8000000000000000L) {
      print("-9223372036854775808");
      return;
    }

    try {
      if (v < 0) {
        out.write('-');
        v = -v;
      } else if (v == 0) {
        out.write('0');
        return;
      }

      int j = 31;

      while (v > 0) {
        _tempCharBuffer[--j] = (char) ((v % 10) + '0');
        v /= 10;
      }

      out.write(_tempCharBuffer, j, 31 - j);
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }
  }
  public boolean render(InternalContextAdapter internalContextAdapter, Writer writer, Node node)
      throws IOException, ResourceNotFoundException, ParseErrorException,
          MethodInvocationException {
    String trimAfter = "/";

    if (node.jjtGetNumChildren() == 2) {
      final Object nodeTwo = node.jjtGetChild(1).value(internalContextAdapter);
      if (nodeTwo != null) {
        trimAfter = nodeTwo.toString();
      }
    } else if (node.jjtGetNumChildren() != 1) {
      rsvc.error("#" + getName() + " - Wrong number of arguments");
      return false;
    }

    final Object nodeValue = node.jjtGetChild(0).value(internalContextAdapter);
    if (nodeValue == null) {
      // No need to do anything since the string is empty anyway
      writer.write("");
      return true;
    }
    String originalString = nodeValue.toString();
    int index = originalString.lastIndexOf(trimAfter);
    // trim away trailing separator if it exists
    if (index == originalString.length() - 1) {
      originalString = originalString.substring(0, originalString.length() - 1);
      index = originalString.lastIndexOf(trimAfter);
    }
    if (index == -1) {
      writer.write(originalString);
    } else {
      writer.write(originalString.substring(index + trimAfter.length(), originalString.length()));
    }
    return true;
  }
Esempio n. 10
0
  private void emitPolicyFileArtifact(
      TreeLogger logger, GeneratorContextExt context, String partialPath)
      throws UnableToCompleteException {
    try {
      String qualifiedSourceName = serviceIntf.getQualifiedSourceName();
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      Writer writer;
      writer =
          new OutputStreamWriter(
              baos, SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING);
      writer.write("serviceClass: " + qualifiedSourceName + "\n");
      writer.write("path: " + partialPath + "\n");
      writer.close();

      byte[] manifestBytes = baos.toByteArray();
      String md5 = Util.computeStrongName(manifestBytes);
      OutputStream os =
          context.tryCreateResource(logger, MANIFEST_ARTIFACT_DIR + "/" + md5 + ".txt");
      os.write(manifestBytes);

      GeneratedResource resource = context.commitResource(logger, os);
      // TODO: change to Deploy when possible
      resource.setVisibility(Visibility.LegacyDeploy);
    } catch (UnsupportedEncodingException e) {
      logger.log(
          TreeLogger.ERROR,
          SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING + " is not supported",
          e);
      throw new UnableToCompleteException();
    } catch (IOException e) {
      logger.log(TreeLogger.ERROR, null, e);
      throw new UnableToCompleteException();
    }
  }
 @Override
 public void encodeToWriter(
     char[] buf, int off, int len, Writer writer, EncodingState encodingState) throws IOException {
   if (buf == null || len <= 0) {
     return;
   }
   int n = Math.min(buf.length, off + len);
   int i;
   int startPos = -1;
   char prevChar = (char) 0;
   for (i = off; i < n; i++) {
     char ch = buf[i];
     if (startPos == -1) {
       startPos = i;
     }
     String escaped = escapeCharacter(ch, prevChar);
     if (escaped != null) {
       if (i - startPos > 0) {
         writer.write(buf, startPos, i - startPos);
       }
       if (escaped.length() > 0) {
         writer.write(escaped);
       }
       startPos = -1;
     }
     prevChar = ch;
   }
   if (startPos > -1 && i - startPos > 0) {
     writer.write(buf, startPos, i - startPos);
   }
 }
Esempio n. 12
0
 protected void initWebXml() throws JasperException {
   try {
     if (webxmlLevel >= INC_WEBXML) {
       mapout = openWebxmlWriter(new File(webxmlFile));
       servletout = new CharArrayWriter();
       mappingout = new CharArrayWriter();
     } else {
       mapout = null;
       servletout = null;
       mappingout = null;
     }
     if (webxmlLevel >= ALL_WEBXML) {
       mapout.write(Localizer.getMessage("jspc.webxml.header"));
       mapout.flush();
     } else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
       mapout.write(Localizer.getMessage("jspc.webinc.header"));
       mapout.flush();
     }
   } catch (IOException ioe) {
     mapout = null;
     servletout = null;
     mappingout = null;
     throw new JasperException(ioe);
   }
 }
Esempio n. 13
0
  public boolean start(Writer writer) {
    boolean result = super.start(writer);

    String actualValue = null;

    if (value == null) {
      value = "top";
    } else {
      value = stripExpressionIfAltSyntax(value);
    }

    // exception: don't call findString(), since we don't want the
    //            expression parsed in this one case. it really
    //            doesn't make sense, in fact.
    actualValue = (String) getStack().findValue(value, String.class, throwExceptionOnELFailure);

    try {
      if (actualValue != null) {
        writer.write(prepare(actualValue));
      } else if (defaultValue != null) {
        writer.write(prepare(defaultValue));
      }
    } catch (IOException e) {
      LOG.info("Could not print out value '" + value + "'", e);
    }

    return result;
  }
Esempio n. 14
0
  protected void runToken(GranolaContext gctx, Writer os, Token tok, Context ctx)
      throws IOException {

    if (tok instanceof Echo) {
      os.write(((Echo) tok).getContent());
    }
    if (tok instanceof BlockCommand) {
      BlockCommand bc = ((BlockCommand) tok);

      TemplateCommand tc = gctx.getTemplateCommand(bc.getCommandName());

      List<INodeRunner> nodes =
          tc.exec(os, ctx, ListUtils.join(ListUtils.cdr(bc.getCommand().split(" ")), " "));

      for (INodeRunner node : nodes) {
        String nameName = node.getName();
        Slot<Token, String> sl = bc.getSlot(nameName);
        if (sl != null) {
          for (Token t : sl.getChildren()) {
            if (node.getOnInvoke() != null) node.getOnInvoke().run(ctx);
            runToken(gctx, os, t, ctx);
          }
        }
      }
    }
    if (tok instanceof Expression) {
      os.write(ctx.getObject(((Expression) tok).getContent(), "").toString());
    }
    if (tok instanceof InlineCommand) {
      os.write(((InlineCommand) tok).toString());
    }
  }
Esempio n. 15
0
 private void writeTextCollapseWhiteSpace(final int end, final int depth) throws IOException {
   // sets index to end
   // assert index < end
   boolean lastWasWhiteSpace = false;
   updateNextTag();
   while (index < end) {
     while (nextTag != null && index == nextTag.begin) {
       if (lastWasWhiteSpace) {
         writer.write(' ');
         lastWasWhiteSpace = false;
       }
       writeTag(nextTag, depth, end);
       if (index == end) return;
     }
     final char ch = sourceText.charAt(index++);
     if (Segment.isWhiteSpace(ch)) {
       lastWasWhiteSpace = true;
     } else {
       if (lastWasWhiteSpace) {
         writer.write(' ');
         lastWasWhiteSpace = false;
       }
       writer.write(ch);
     }
   }
   if (lastWasWhiteSpace) writer.write(' ');
 }
Esempio n. 16
0
 /**
  * For each port of the given entity, if the port's derived level is greater than 0 (i.e., it is
  * created automatically by the entity), store the persistent attributes of the port in a "port"
  * XML element.
  *
  * @param entity The entity whose ports are looked at.
  * @param output The output writer.
  * @param depth The depth for the MoML output.
  * @exception IOException If the output writer cannot be written to.
  */
 public static void exportPortProperties(GTEntity entity, Writer output, int depth)
     throws IOException {
   if (entity instanceof Entity) {
     Entity ptEntity = (Entity) entity;
     for (Object portObject : ptEntity.portList()) {
       Port port = (Port) portObject;
       if (port.getDerivedLevel() == 0) {
         continue;
       }
       boolean outputStarted = false;
       for (Object attributeObject : port.attributeList()) {
         Attribute attribute = (Attribute) attributeObject;
         if (attribute.isPersistent()) {
           if (!outputStarted) {
             output.write(
                 StringUtilities.getIndentPrefix(depth)
                     + "<port name=\""
                     + port.getName()
                     + "\">\n");
             outputStarted = true;
           }
           attribute.exportMoML(output, depth + 1);
         }
       }
       if (outputStarted) {
         output.write(StringUtilities.getIndentPrefix(depth) + "</port>\n");
       }
     }
   }
 }
Esempio n. 17
0
 public static void main(String args[]) throws Exception {
   // 为了简单起见,所有的异常都直接往外抛
   String host = "127.0.0.1"; // 要连接的服务端IP地址
   int port = 8899; // 要连接的服务端对应的监听端口
   // 与服务端建立连接
   Socket client = new Socket(host, port);
   // 建立连接后就可以往服务端写数据了
   Writer writer = new OutputStreamWriter(client.getOutputStream(), "UTF-8");
   writer.write("hello,server");
   writer.write("eof\n");
   writer.flush();
   // 写完以后进行读操作
   BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
   // 设置超时间为10秒
   client.setSoTimeout(10 * 1000);
   StringBuffer sb = new StringBuffer();
   String temp;
   int index;
   while ((temp = br.readLine()) != null) {
     if ((index = temp.indexOf("eof")) != -1) {
       sb.append(temp.substring(0, index));
       break;
     }
     sb.append(temp);
   }
   System.out.println("from server: " + sb);
   writer.close();
   br.close();
   client.close();
 }
Esempio n. 18
0
 public final void writeln(final Writer writer, final String data) throws IOException {
   int len = data.length() + PAD_BY;
   String result = String.format("%" + len + "s", data);
   writer.write(result);
   writer.write(NEW_LINE);
   writer.flush();
 }
Esempio n. 19
0
 public void writeLink(Writer out) throws Exception {
   out.write("<a href=\"group.jsp?g=");
   UtilityMethods.writeURLEncoded(out, tagName);
   out.write("\">");
   HTMLWriter.writeHtml(out, tagName);
   out.write("</a>");
 }
  public void exportText(TableBuilder tableBuilder, JRPrintText text, JRExporterGridCell gridCell)
      throws IOException {
    tableBuilder.buildCellHeader(
        styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan());

    JRStyledText styledText = getStyledText(text);

    int textLength = 0;

    if (styledText != null) {
      textLength = styledText.length();
    }

    tempBodyWriter.write("<text:p text:style-name=\"");
    tempBodyWriter.write(styleCache.getParagraphStyle(text));
    tempBodyWriter.write("\">");
    insertPageAnchor();
    if (text.getAnchorName() != null) {
      exportAnchor(JRStringUtil.xmlEncode(text.getAnchorName()));
    }

    boolean startedHyperlink = startHyperlink(text, true);

    if (textLength > 0) {
      exportStyledText(styledText, getTextLocale(text), startedHyperlink);
    }

    if (startedHyperlink) {
      endHyperlink(true);
    }

    tempBodyWriter.write("</text:p>\n");

    tableBuilder.buildCellFooter();
  }
Esempio n. 21
0
  /**
   * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is
   * added.
   *
   * <p>Warning: This method assumes that the data structure is acyclical.
   *
   * @return The writer.
   * @throws JSONException
   */
  public Writer write(Writer writer) throws JSONException {
    try {
      boolean b = false;
      int len = length();

      writer.write('[');

      for (int i = 0; i < len; i += 1) {
        if (b) {
          writer.write(',');
        }
        Object v = this.myArrayList.get(i);
        if (v instanceof JSONObject) {
          ((JSONObject) v).write(writer);
        } else if (v instanceof JSONArray) {
          ((JSONArray) v).write(writer);
        } else {
          writer.write(JSONObject.valueToString(v));
        }
        b = true;
      }
      writer.write(']');
      return writer;
    } catch (IOException e) {
      throw new JSONException(e);
    }
  }
  protected void exportStyledTextRun(
      Map<AttributedCharacterIterator.Attribute, Object> attributes,
      String text,
      Locale locale,
      boolean startedHyperlink)
      throws IOException {
    String textSpanStyleName = styleCache.getTextSpanStyle(attributes, text, locale);

    tempBodyWriter.write("<text:span");
    tempBodyWriter.write(" text:style-name=\"" + textSpanStyleName + "\"");
    tempBodyWriter.write(">");

    boolean localHyperlink = false;

    if (!startedHyperlink) {
      JRPrintHyperlink hyperlink = (JRPrintHyperlink) attributes.get(JRTextAttribute.HYPERLINK);
      if (hyperlink != null) {
        localHyperlink = startHyperlink(hyperlink, true);
      }
    }

    if (text != null) {
      tempBodyWriter.write(
          Utility.replaceNewLineWithLineBreak(
              JRStringUtil.xmlEncode(text))); // FIXMEODT try something nicer for replace
    }

    if (localHyperlink) {
      endHyperlink(true);
    }

    tempBodyWriter.write("</text:span>");
  }
Esempio n. 23
0
  protected void writeCssTo(Writer writer, Output output) throws IOException {
    Object[] results;
    Mapper mapper;
    Node node;

    if (output.getMuted()) {
      throw new IllegalArgumentException();
    }
    mapper = SSASS.newInstance();
    mapper.setErrorHandler(new ExceptionErrorHandler());
    for (int i = 0; i < nodes.size(); i++) {
      node = nodes.get(i);
      if (i > 0) {
        writer.write(LF);
      }
      if (!overallMinimize) {
        writer.write(type.comment(location(node)));
      }
      results = mapper.run(node);
      if (results == null) {
        throw new IOException(node.toString() + ": css/sass error");
      }
      output.setMuted(declarationsOnly.get(i));
      try {
        ((Stylesheet) results[0]).toCss(output);
      } catch (GenericException e) {
        throw new IOException(node.toString() + ": css generation failed: " + e.getMessage(), e);
      }
      if (output.getMuted() != declarationsOnly.get(i)) {
        throw new IllegalStateException();
      }
    }
  }
 protected void endHyperlink(boolean isText) throws IOException {
   if (isText) {
     tempBodyWriter.write("</text:a>");
   } else {
     tempBodyWriter.write("</draw:a>");
   }
 }
Esempio n. 25
0
  /**
   * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is
   * added.
   *
   * <p>Warning: This method assumes that the data structure is acyclical.
   *
   * @param writer Writer
   * @param indentFactor The number of spaces to add to each level of indentation.
   * @param indent The indention of the top level.
   * @return The writer.
   * @throws JSONException Error
   */
  Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
    try {
      boolean commanate = false;
      int length = this.length();
      writer.write('[');

      if (length == 1) {
        JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
      } else if (length != 0) {
        final int newindent = indent + indentFactor;

        for (int i = 0; i < length; i += 1) {
          if (commanate) {
            writer.write(',');
          }
          if (indentFactor > 0) {
            writer.write('\n');
          }
          JSONObject.indent(writer, newindent);
          JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, newindent);
          commanate = true;
        }
        if (indentFactor > 0) {
          writer.write('\n');
        }
        JSONObject.indent(writer, indent);
      }
      writer.write(']');
      return writer;
    } catch (IOException e) {
      throw new JSONException(e);
    }
  }
 private void reportWorkflowRunStdErrOut(String workflowRunAccession, int streamType)
     throws IOException {
   String title = "workflowrun_" + workflowRunAccession;
   if (streamType == 1) {
     title = title + "_STDOUT";
     initWriter(title);
     writer.write(metadata.getWorkflowRunReportStdOut(Integer.parseInt(workflowRunAccession)));
   } else if (streamType == 2) {
     title = title + "_STDERR";
     initWriter(title);
     writer.write(metadata.getWorkflowRunReportStdErr(Integer.parseInt(workflowRunAccession)));
   } else {
     Log.error(
         "Unknown stream type: "
             + streamType
             + " should be "
             + WorkflowRunReporter.STDERR
             + " for stderr or "
             + WorkflowRunReporter.STDOUT
             + " for stdout!");
     initWriter(title);
     writer.write(
         "Unknown stream type: "
             + streamType
             + " should be "
             + WorkflowRunReporter.STDERR
             + " for stderr or "
             + WorkflowRunReporter.STDOUT
             + " for stdout!");
   }
 }
  public void writeNN(String source, String target, boolean flag) {
    this.loadCorpus(source, target);
    try {
      Writer bw =
          new BufferedWriter(new OutputStreamWriter(new FileOutputStream(source + ".nn"), "UTF-8"));

      Writer bw1 =
          new BufferedWriter(new OutputStreamWriter(new FileOutputStream(target + ".nn"), "UTF-8"));
      if (flag)
        for (int i = 0; i < nelist.size(); i++) {
          String ne[] = nelist.get(i).split("\t");

          bw.write(this.formatStringCausal(ne[0]) + "\n");
          bw1.write(this.formatStringCausal(ne[1]) + "\n");
          bw.flush();
          bw1.flush();
        }
      else
        for (int i = 0; i < nelist.size(); i++) {
          String ne[] = nelist.get(i).split("\t");

          bw.write(ne[0] + "\n");
          bw1.write(ne[1] + "\n");
          bw.flush();
          bw1.flush();
        }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
 private void reportOnWorkflow(
     String workflowAccession, WorkflowRunStatus status, Date earlyDate, Date lateDate)
     throws IOException {
   String title = "";
   if (workflowAccession != null) {
     title = "workflow_" + workflowAccession;
   }
   if (status != null) {
     title += "status_" + status.name();
   }
   if (earlyDate != null) {
     title += "from" + dateFormat.format(earlyDate);
   }
   if (lateDate != null) {
     title += "to" + dateFormat.format(lateDate);
   }
   initWriter(title);
   String report;
   try {
     Integer workflowParameter = null;
     if (workflowAccession != null) {
       workflowParameter = Integer.parseInt(workflowAccession);
     }
     report = metadata.getWorkflowRunReport(workflowParameter, status, earlyDate, lateDate);
   } catch (RuntimeException e) {
     Log.fatal("Workflow not found", e);
     ret = new ReturnValue(ReturnValue.INVALIDPARAMETERS);
     return;
   }
   if (options.has("human")) {
     writer.write(TabExpansionUtil.expansion(report));
     return;
   }
   writer.write(report);
 }
Esempio n. 29
0
  protected void drawHtmlPostSubsButtons(Writer out) throws IOException {
    Messages msgs = MessagesManager.getMessages();

    out.write(
        "<div class=\""
            + CssConstants.CSSCLASS_TABSETSAVEBAR
            + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$

    Button save = new Button();
    String saveOnclick = this.getConfigValue("saveOnclick", "mgnlDialogFormSubmit();");
    String saveLabel = this.getConfigValue("saveLabel", msgs.get("buttons.save"));
    if (StringUtils.isNotEmpty(saveOnclick) && StringUtils.isNotEmpty("saveLabel")) {
      save.setOnclick(saveOnclick); // $NON-NLS-1$ //$NON-NLS-2$
      save.setLabel(saveLabel); // $NON-NLS-1$ //$NON-NLS-2$
      out.write(save.getHtml());
    }
    Button cancel = new Button();
    cancel.setOnclick(
        this.getConfigValue("cancelOnclick", "window.close();")); // $NON-NLS-1$ //$NON-NLS-2$
    cancel.setLabel(
        this.getConfigValue(
            "cancelLabel", msgs.get("buttons.cancel"))); // $NON-NLS-1$ //$NON-NLS-2$
    out.write(cancel.getHtml());

    out.write("</div>\n"); // $NON-NLS-1$
  }
Esempio n. 30
0
  /**
   * This method automatically closes a previous element (if not already closed).
   *
   * @throws IOException if an error occurs writing
   */
  private void closeStartIfNecessary() throws IOException {

    if (closeStart) {
      flushAttributes();
      writer.write('>');
      closeStart = false;
      if (isScriptOrStyle() && !scriptOrStyleSrc) {
        isXhtml = getContentType().equals(RIConstants.XHTML_CONTENT_TYPE);
        if (isXhtml) {
          if (!writingCdata) {
            if (isScript) {
              writer.write("\n//<![CDATA[\n");
            } else {
              writer.write("\n<![CDATA[\n");
            }
          }
        } else {
          if (isScriptHidingEnabled) {
            writer.write("\n<!--\n");
          }
        }
        origWriter = writer;
        if (scriptBuffer == null) {
          scriptBuffer = new FastStringWriter(1024);
        }
        scriptBuffer.reset();
        writer = scriptBuffer;
        isScript = false;
        isStyle = false;
      }
    }
  }