Ejemplo n.º 1
0
 private void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException {
   FileOutputStream fileOutputStream = new FileOutputStream(fileName);
   PrintStream printStream = new PrintStream(fileOutputStream);
   for (int i = 0; i < sql.length; i++) {
     printStream.println(sql[i] + getSqlDelimiter());
   }
 }
Ejemplo n.º 2
0
 public static void println(double[] p, PrintStream ps) {
   for (int i = 0; i < p.length; i++) {
     ps.print(i > 0 ? " " : "");
     ps.print(String.format("%.2f", p[i]));
   }
   ps.println();
 }
  /**
   * Prints a linkage specification block to a stream.
   *
   * @param spec The block to print.
   * @param stream The stream on which to print the block.
   */
  public static void defaultPrint(LinkageSpecification spec, OutputStream stream) {
    PrintStream p = new PrintStream(stream);

    p.print("extern \"");
    p.print(spec.calling_convention);
    p.print("\"\n{\n");
    Tools.printlnList(spec.children, stream);
    p.print("}");
  }
Ejemplo n.º 4
0
  /**
   * Prints a break statement to a stream.
   *
   * @param stmt The statement to print.
   * @param stream The stream on which to print the statement.
   */
  public static void defaultPrint(ReturnStatement stmt, OutputStream stream) {
    PrintStream p = new PrintStream(stream);

    p.print("return ");

    if (!stmt.children.isEmpty()) ((Printable) stmt.children.get(0)).print(stream);

    p.print(";");
  }
Ejemplo n.º 5
0
  public void save(File f) throws IOException {
    PrintStream ps = new PrintStream(new FileOutputStream(f));
    String[] genes = genes();

    Vector<Map<String, Double>> maps = new Vector<Map<String, Double>>();
    for (int j = 0; j < coefs.size(); j++) {
      maps.add(coefs.get(j).geneValues(args.compare));
    }

    ps.print("gene");
    for (int i = 0; i < coefs.size(); i++) {
      ps.print(" " + keys.get(i));
    }
    ps.println();

    for (int i = 0; i < genes.length; i++) {
      ps.print(String.format("%s", genes[i]));

      for (int j = 0; j < coefs.size(); j++) {
        Map<String, Double> map = maps.get(j);
        Double value = map.containsKey(genes[i]) ? map.get(genes[i]) : null;

        ps.print(String.format(" %s", value != null ? String.format("%.2f", value) : "N/A"));
      }

      ps.println();
    }

    ps.println();
    ps.close();
  }
Ejemplo n.º 6
0
  /**
   * Prints a __builtin_offsetof expression to a stream.
   *
   * @param expr The expression to print.
   * @param stream The stream on which to print the expression.
   */
  public static void defaultPrint(OffsetofExpression expr, OutputStream stream) {
    PrintStream p = new PrintStream(stream);

    p.print("__builtin_offsetof");

    p.print("(");
    Tools.printListWithSeparator(expr.specs, stream, " ");
    p.print(",");
    expr.getExpression().print(stream);
    p.print(")");
  }
Ejemplo n.º 7
0
  /**
   * Prints an array access expression to a stream.
   *
   * @param expr The array access to print.
   * @param stream The stream on which to print the array access.
   */
  public static void defaultPrint(ArrayAccess expr, OutputStream stream) {
    PrintStream p = new PrintStream(stream);

    Iterator<Traversable> iter = expr.children.iterator();

    iter.next().print(stream);

    while (iter.hasNext()) {
      p.print("[");

      Traversable o = iter.next();
      o.print(stream);

      p.print("]");
    }
  }
Ejemplo n.º 8
0
  public static void main(final String[] args) {

    File logdir = new File(LOG_DIR);
    if (!logdir.exists()) logdir.mkdirs();
    File log = new File(logdir, "client.log");
    // redirect all console output to the file
    try {
      PrintStream out = new PrintStream(new FileOutputStream(log, true), true);
      out.format("[%s] ===== Client started =====%n", timestampf.format(new Date()));
      System.setOut(out);
      System.setErr(out);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    /* Set up the error handler as early as humanly possible. */
    ThreadGroup g = new ThreadGroup("Haven main group");
    String ed;
    if (!(ed = Utils.getprop("haven.errorurl", "")).equals("")) {
      try {
        final haven.error.ErrorHandler hg = new haven.error.ErrorHandler(new java.net.URL(ed));
        hg.sethandler(
            new haven.error.ErrorGui(null) {
              public void errorsent() {
                hg.interrupt();
              }
            });
        g = hg;
      } catch (java.net.MalformedURLException e) {
      }
    }
    Thread main =
        new HackThread(
            g,
            new Runnable() {
              public void run() {
                main2(args);
              }
            },
            "Haven main thread");
    main.start();
  }
Ejemplo n.º 9
0
 public static synchronized void printDebugMsg(PrintStream out) {
   if (DEBUG == false) {
     return;
   }
   StringBuffer msg = new StringBuffer();
   msg.append("debug message in " + SimpleConnectionPool.class.getName());
   msg.append("\r\n");
   msg.append("total count is connection pool: " + getConnectionCount());
   msg.append("\r\n");
   msg.append("not used connection count: " + getNotUsedConnectionCount());
   msg.append("\r\n");
   msg.append("used connection, count: " + getUsedConnectionCount());
   out.println(msg);
   Iterator iterator = m_usedUsedConnection.iterator();
   while (iterator.hasNext()) {
     ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
     wrapper.debugInfo.printStackTrace(out);
   }
   out.println();
 }
Ejemplo n.º 10
0
  /**
   * ** Prints all the default values from <code>RTKey</code> and {@link RTConfig} ** to the
   * specified <code>PrintStream</code>. Used for debugging/testing ** @param out The <code>
   * PrintStream</code>
   */
  public static void printDefaults(PrintStream out) {

    /* print standard runtime entries */
    Set<String> keyList = new OrderedSet<String>();
    String keyGrp = null;

    for (Iterator<Entry> v = RTKey.getRuntimeEntryMap().values().iterator(); v.hasNext(); ) {
      Entry rtk = v.next();
      if (rtk.isHelp()) {
        out.println("");
        out.println("# ===== " + rtk.getHelp());
      } else {
        Object dft = rtk.getDefault();
        out.println("# --- " + rtk.getHelp());
        out.println("# " + rtk.toString(dft));
        String key = rtk.getKey();
        keyList.add(key);
        if (!key.equals(CONFIG_FILE) && RTConfig.hasProperty(key)) {
          String val = RTConfig.getString(key, null);
          // if ((val != null) && ((dft == null) || !val.equals(dft.toString()))) {
          out.println(rtk.toString(val));
          // }
        }
      }
    }

    /* orphaned entries */
    RTProperties cmdLineProps = RTConfig.getConfigFileProperties();
    if (cmdLineProps != null) {
      boolean orphanHeader = false;
      for (Iterator i = cmdLineProps.keyIterator(); i.hasNext(); ) {
        Object k = i.next();
        if (!k.equals(COMMAND_LINE_CONF) && !keyList.contains(k)) {
          if (!orphanHeader) {
            out.println("");
            out.println("# ===== Other entries");
            orphanHeader = true;
          }
          Object v = cmdLineProps.getProperty(k, null);
          out.println(k + "=" + ((v != null) ? v : NULL_VALUE));
        }
      }
    }

    /* final blank line */
    out.println("");
  }
Ejemplo n.º 11
0
  /**
   * Prints a throw expression to a stream.
   *
   * @param expr The expression to print.
   * @param stream The stream on which to print the expression.
   */
  public static void defaultPrint(ThrowExpression expr, OutputStream stream) {
    PrintStream p = new PrintStream(stream);

    p.print("throw ");
    expr.getExpression().print(stream);
  }