Package org.jboss.fresh.io

Examples of org.jboss.fresh.io.BufferWriter


  /* (non-Javadoc)
   * @see org.jboss.fresh.shell.AbstractExecutable#process(java.lang.String, java.lang.String[])
   */
  protected void process(String exepath, String[] args) throws Exception {

    PrintWriter2 pout = new PrintWriter2(new BufferedWriter(new BufferWriter(getStdOut())));

    String[] invalids = getInvalidSwitches(args, "cpxuot", new String[]{"--ex", "--help"});

    boolean clientInfo = isSwitchActive(args, "c", null);
    boolean project = isSwitchActive(args, "p", null);
View Full Code Here


  public void process(String exepath, String[] params) throws Exception {
    log.debug("entered");

    if (helpRequested()) {
      PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
      out.print("Usage: filefilter [--help] [-ex] type=dir\n");
      out.print("    The FileInfo objects are acquired from the pipeline, filtered and the ones remaining are sent forward.\n");
      out.print("    --help : this help\n");
      out.close();
      log.debug("done");
      return;
    }

    BufferObjectReader oin = new BufferObjectReader(getStdIn());
    BufferObjectWriter oout = new BufferObjectWriter(getStdOut());

    // if no params, just let through everything
    // if type param, do some filtering.
    if (params.length == 0) {
      log.info("No parameters specified. Just piping through.");
      while (!oin.isFinished()) {
        oout.writeObject(oin.readObject());
      }
      oout.close();
      log.debug("done");
      return;
    }


    HashMap typemap = new HashMap();
    typemap.put("type", "string");

    // filterparser mora pripraviti pogoje - Filter objekte. Filter objekt zna za vrednost dolo�enega tipa pogledati ali izpolnjuje set pogojev.
    // Seveda je normalno pogoj vezan na neko polje v neki podatkovni strukturi. Treba je samo ta field vedno posredovati temu filtru.
    // Treba je torej vedeti kateri field je vezan na kateri filter.
    // smiselno je enumerirati list filtrov. Vsak filter vpra�ati na kateri field se nana�a in ta field posredovati v preverjanje.

    FilterParser p = null;
    Filter[] filters = null;

    try {
      p = new MyFilterParser(typemap, params);
      filters = p.getFilters();
    } catch (Exception e) {
      if (canThrowEx()) {
        throw e;
      } else {
        PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));
        err.println("" + e);
      }
    }

    // now we do ...
View Full Code Here

        int p = cnd.indexOf("=");
        if (p == -1) {
          if (canThrowEx()) {
            throw new Exception("Exception while parsing. No operator found in condition: " + cnd);
          } else {
            PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));
            err.println("Exception while parsing. No operator found in condition: " + cnd);
            return;
          }
        }
        String fld = cnd.substring(0, p);

        // lookup type for this field
        String fldtype = (String) typemap.get(fld);
        if (fldtype == null) {
          if (canThrowEx()) {
            throw new Exception("Exception while parsing. No such field: " + fld);
          } else {
            PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));
            err.println("Exception while parsing. No such field: " + fld);
            return;
          }
        }

        if (fldtype.equals("int")) {
          try {
            l.add(new IntFilter(fld, Filter.EQ, cnd.substring(p + 1, cnd.length())));
          } catch (Exception e) {
            if (canThrowEx()) {
              throw e;
            } else {
              PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));
              err.println("" + e);
              return;
            }
          }
        } else if (fldtype.equals("string")) {
          try {
            l.add(new StringFilter(fld, Filter.EQ, cnd.substring(p + 1, cnd.length()).intern()));
          } catch (Exception e) {
            if (canThrowEx()) {
              throw e;
            } else {
              PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));
              err.println("" + e);
              return;
            }
          }
        }
View Full Code Here

    public static final String VERSION = "$Header$";

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    protected void process(String exepath, String[] args) throws Exception {
        PrintWriter pout = new PrintWriter(new BufferedWriter(new BufferWriter(getStdOut())));
        pout.print(sdf.format(new Date()));
        pout.close();
    }
View Full Code Here

  public void process(String exepath, String[] params) throws Exception {
    log.debug("CtxDelegateExe entered.");

    if ((params.length == 0) || helpRequested()) {
      PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
      out.print("Usage: ctxdelegate [--help] [-ex] CONTEXT_NAMES\n");
      out.print("    --help : this help\n");
      out.close();
      log.debug("CtxDelegateExe done.");
      return;
    }

    Shell shell = getShell();

    PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));

    for (int i = 0; i < params.length; i++) {

      String tmp = params[i];
View Full Code Here

      log.debug("done");
      return;
    }

    if (!canThrowEx()) {
      err = new PrintWriter(new BufferWriter(getStdOut()));
    }

    boolean forceString = isSwitchActive(args, "S", "string");
    boolean forceDOM = isSwitchActive(args, "D", "DOM");
View Full Code Here

    }
    log.debug("XMLSerializerExe spent " + (System.currentTimeMillis() - benchmark) + "ms for its execution.");
  }

  private void printHelp(String execName) {
    PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
    out.println("Usage: " + execName + " [-ex] [--help] [--DOM | --string]");
    out.println();
    out.println("This executable will (de)serialize the XML. The following coversions are supported:");
    out.println("  STDIN                             STDOUT");
    out.println("  String                            org.w3c.dom.Document");
View Full Code Here

    out.println("  -u, --unix-byte-offsets   report offsets as if CRs were not there (MSDOS)");
    out.println("");
  }

  protected void process(String exepath, String[] args) throws Exception {
    PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));

    String[] invalidSwitches = getInvalidSwitches(args, "EJPfiwxzsvVhmbnoqaIcZBACUu", new String[]
    {"regexp", "file", "ignore-case", "word-regexp", "line-regexp", "null-data", "no-messages",
     "invert-match", "version", "help", "max-count", "byte-offset", "line-number",
     "line-buffered", "only-matching", "quiet", "silent", "binary-files", "text," +
View Full Code Here

  public void process(String exepath, String[] params) throws Exception {
    log.debug("entered");

    if (helpRequested()) {
      PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
      out.print("Usage: ls [--help] [dir]\n");
      out.print("    dir : the directory to be viewed - if none is specified then the current working directory is viewed.\n");
      out.print("    --help : this help");
      out.close();
      log.debug("done");
View Full Code Here

  public void process(String exename, String[] params) throws Exception {
    log.debug("entered");

    if (helpRequested()) {
      PrintWriter2 out = new PrintWriter2(new BufferWriter(getStdOut()));
      out.println("Usage: alias [--help] [-ex] <alias> <command_line>");
            out.println("    command_line parameter can be several parameters which will be concatenated");
            out.println("                 and seperated by spaces");
            out.println("    --list    : list existing aliases");
            out.println("    --listfull : list existing aliases and their values");
            out.println("    --help    : this help");
      out.close();
      log.debug("done");
      return;
    }

        String alias = null;
        if(params.length > 0) {

            alias = params[0];
            boolean full = "--listfull".equals(alias);

            if("--list".equals(alias) || full) {
                Map aliases = ((ShellImpl)shell).getRuntime().listAliases();
                PrintWriter2 out = new PrintWriter2(new BufferWriter(getStdOut()));
                Iterator it = aliases.entrySet().iterator();
                while(it.hasNext()) {
                    Map.Entry ent = (Map.Entry) it.next();
                    out.println(ent.getKey() + ( full ?  "\t\t" + ent.getValue() : ""));
                }
View Full Code Here

TOP

Related Classes of org.jboss.fresh.io.BufferWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.