Package com.caucho.vfs

Examples of com.caucho.vfs.TempStream


    void setChaining()
    {
      if (_os != null)
        throw new IllegalStateException(L.l("setContentType for XSLT chaining must be before any data."));
     
      _tempStream = new TempStream();
      _tempStream.openWrite();

      _os = new WriteStream(_tempStream);
    }
View Full Code Here


  public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());

    TempStream ts = new TempStream();
    ts.openWrite();
    WriteStream ws = new WriteStream(ts);
    ByteCodeWriter o2 = new ByteCodeWriter(ws, out.getJavaClass());
   
    o2.writeShort(_maxStack);
    o2.writeShort(_maxLocals);
    o2.writeInt(_code.length);
    o2.write(_code, 0, _code.length);

    o2.writeShort(_exceptions.size());
    for (int i = 0; i < _exceptions.size(); i++) {
      ExceptionItem exn = _exceptions.get(i);

      o2.writeShort(exn.getStart());
      o2.writeShort(exn.getEnd());
      o2.writeShort(exn.getHandler());
      o2.writeShort(exn.getType());
    }

    o2.writeShort(_attributes.size());
    for (int i = 0; i < _attributes.size(); i++) {
      Attribute attr = _attributes.get(i);

      attr.write(o2);
    }
   
    ws.close();
   
    out.writeInt(ts.getLength());
    TempBuffer ptr = ts.getHead();

    for (; ptr != null; ptr = ptr.getNext())
      out.write(ptr.getBuffer(), 0, ptr.getLength());

    ts.destroy();
  }
View Full Code Here

    }
    else if (ch == 0xff) {
      if (_is.read() != 0xd8)
  return false;

      TempStream ts = new TempStream();

      WriteStream ws = new WriteStream(ts);
      ws.write(0xff);
      ws.write(0xd8);
      _is.writeToStream(ws);
      ws.close();

      // XXX: issues with _jpegHead vs ts.openReadAndSaveBuffer()
      _jpegHead = ts.getHead();
      _is.close();

      _is = new ReadStream();
      ts.openRead(_is);

      parseJPEG();

      return true;
    }
View Full Code Here

  public boolean begin_document(@Optional String fileName,
                                @Optional String optList)
    throws IOException
  {
    _tempStream = new TempStream();
    _tempStream.openWrite();
    _os = new WriteStream(_tempStream);

    _out = new PDFWriter(_os);
    _out.beginDocument();
View Full Code Here

  /**
   * Returns the result as a string.
   */
  public Value get_buffer(Env env)
  {
    TempStream ts = _tempStream;
    _tempStream = null;

    if (ts == null)
      return BooleanValue.FALSE;

    StringValue result = env.createBinaryBuilder();
    for (TempBuffer ptr = ts.getHead();
         ptr != null;
         ptr = ptr.getNext()) {
      result.append(ptr.getBuffer(), 0, ptr.getLength());
    }

    ts.destroy();

    return result;
  }
View Full Code Here

  PDFStream(int id)
  {
    _id = id;

    _tempStream = new TempStream();
    _tempStream.openWrite();
    _out.init(_tempStream);

    _procSet = new PDFProcSet();
    _procSet.add("/PDF");
View Full Code Here

  public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());

    TempStream ts = new TempStream();
    ts.openWrite();
    WriteStream ws = new WriteStream(ts);
    ByteCodeWriter o2 = new ByteCodeWriter(ws, out.getJavaClass());

    o2.writeShort(_exceptions.size());
    for (int i = 0; i < _exceptions.size(); i++) {
      String exn = _exceptions.get(i);

      o2.writeClass(exn);
    }
   
    ws.close();
   
    out.writeInt(ts.getLength());
   
    TempBuffer ptr = ts.getHead();

    for (; ptr != null; ptr = ptr.getNext())
      out.write(ptr.getBuffer(), 0, ptr.getLength());

    ts.destroy();
  }
View Full Code Here

        if (_os != null)
          _os.write(buffer, offset, length);
      }
      else {
        if (_tempStream == null) {
          _tempStream = new TempStream();
          _tempStreamSize = 0;
        }

        _tempStreamSize += length;
        _tempStream.write(buffer, offset, length, false);
View Full Code Here

  /**
   * Called from inside _logLock
   */
  private void flushTempStream()
  {
    TempStream ts = _tempStream;
    _tempStream = null;
    _tempStreamSize = 0;

    try {
      if (ts != null) {
        if (_os == null)
          openLog();

        try {
          ReadStream is = ts.openRead();

          try {
            is.writeToStream(_os);
          } finally {
            is.close();
View Full Code Here

   
    try {
      deflater = new Deflater(level, true);

      boolean isFinished = false;
      TempStream out = new TempStream();

      int len;
      while (! isFinished) {
        if (! isFinished && deflater.needsInput()) {
          len = data.read(buffer, 0, buffer.length);

          if (len > 0)
            deflater.setInput(buffer, 0, len);
          else {
            isFinished = true;
            deflater.finish();
          }
        }

        while ((len = deflater.deflate(buffer, 0, buffer.length)) > 0) {
          out.write(buffer, 0, len, false);
        }
      }
      deflater.end();

      return env.createBinaryString(out.getHead());

    } catch (Exception e) {
      throw QuercusModuleException.create(e);
    } finally {
      TempBuffer.free(tempBuf);
View Full Code Here

TOP

Related Classes of com.caucho.vfs.TempStream

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.