Package org.jboss.fresh.io

Examples of org.jboss.fresh.io.BufferObjectReader


        if (image == null) {
          throwException("No image retrieved from the pipeline!");
          return;
        }
      } else { //OBJ_TYPE
        BufferObjectReader oin = new BufferObjectReader(getStdIn());

        if (oin.hasNext()) {
          image = (BufferedImage) oin.next();
        }
        oin.close();

        if (image == null) {
          throwException("No image object retrieved from the pipeline!");
          return;
        }
View Full Code Here


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

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

    // handle parameters
    int x = 0, y = 0, w = 0, h = 0, x2 = -1, y2 = -1;
    String inType = IMG_TYPE;
    String outType = null;

    for (int i = 0; i < params.length; i++) {
      String str = params[i];

      if (str.equals("-x1")) {
        x = Integer.parseInt(params[++i]);
      } else if (str.equals("-y1")) {
        y = Integer.parseInt(params[++i]);
      } else if (str.equals("-x2")) {
        x2 = Integer.parseInt(params[++i]);
      } else if (str.equals("-y2")) {
        y2 = Integer.parseInt(params[++i]);
      } else if (str.equals("-in")) {
        inType = params[++i];
        if (!inType.equals(IMG_TYPE) && !inType.equals(OBJ_TYPE)) {
          throwException("Invalid in type");
          return;
        }
      } else if (str.equals("-out")) {
        outType = params[++i];
        if (!outType.equals(IMG_TYPE) && !outType.equals(OBJ_TYPE)) {
          throwException("Invalid out type");
          return;
        }
      } else {
        throwException("There is an unknown parameter.");
        return;
      }
    }

    if (outType == null) {
      outType = inType;
    }

    // read image
    BufferedImage image = null;

    if (inType.equals(IMG_TYPE)) {
      BufferInputStream bis = new BufferInputStream(getStdIn());
      image = ImageIO.read(bis);
      bis.close();
    } else { // OBJ_TYPE
      Object obj = null;

      if (oin.hasNext()) {
        obj = oin.next();
      }
      oin.close();

      try {
        image = (BufferedImage) obj;
      } catch (Exception e) {
        throwException("" + e);
View Full Code Here

    switch (action) {

      case BIND:
        {
          BufferObjectReader objin = new BufferObjectReader(getStdIn());
          // read from input names.length() objects
          // bind each one as you go
          Iterator it = names.iterator();
          while (it.hasNext()) {
            String name = String.valueOf(it.next());
            Object obj = null;
            if (!objin.isFinished()) obj = objin.readObject();

            if (obj == null) {
              if (canThrowEx()) {
                throw new Exception("Could not read object from std-in for name: " + name);
              } else {
View Full Code Here

*/
public class Bzip2Exe extends AbstractExecutable {
  public static final String VERSION = "$Header$";

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectReader in = new BufferObjectReader(getStdIn());
    BufferOutputStream out = getStdOutStream();
    CBZip2OutputStream bout = new CBZip2OutputStream(out);
    ObjectOutputStream oout = new ObjectOutputStream(bout);
    Object obj;
    try {
      while( !in.isFinished() ) {
        obj = in.readObject();
        oout.writeObject(obj);
        oout.flush();
        bout.flush();
        out.flush();
      }
      in.close();
    } catch (Exception e) {
      if(canThrowEx()) {
        throw e;
      } else {
        org.jboss.fresh.io.BufferWriter bw = new BufferWriter(getStdOut());
View Full Code Here

TOP

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

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.