Package com.caucho.vfs

Examples of com.caucho.vfs.ReadStream$StreamReader


  public void flushResponse()
    throws IOException
  {
    _out.flush();
   
    ReadStream rs = _tempStream.openRead();
    PrintWriter out = _response.getWriter();
   
    int ch;

    while ((ch = rs.readChar()) >= 0)
      out.write((char) ch);

    rs.close();
  }
View Full Code Here


    _out = null;

    if (out != null)
      out.flush();
   
    ReadStream rs = _tempStream.openRead();
    StringBuilder sb = new StringBuilder();
   
    int ch;

    while ((ch = rs.readChar()) >= 0)
      sb.append((char) ch);

    rs.close();

    return sb.toString();
  }
View Full Code Here

            || className.equals("com/caucho/vfs/JniFileStream.class")
            || className.equals("com/caucho/vfs/JniServerSocketImpl.class"))) {
      byte []buffer = new byte[length];

      try {
        ReadStream is = null;
        try {
          is = path.openRead();

          is.readAll(buffer, 0, buffer.length);

          Class<?> cl = defineClass(name, buffer, 0, buffer.length,
                                 (CodeSource) null);

          return cl;
        } finally {
          is.close();
        }
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

      os.println("<propfind xmlns=\"DAV:\"><prop>");
      os.println("<resourcetype/>");
      os.println("</prop></propfind>");
      os.flush();

      ReadStream is = new ReadStream(stream);
   
      ListHandler handler = new ListHandler(getPath());
      XmlParser parser = new XmlParser();
      parser.setContentHandler(handler);

      parser.parse(is);

      is.close();
      os.close();
      stream.close();

      ArrayList<String> names = handler.getNames();
      String []list = new String[names.size()];
View Full Code Here

   * the implementation must initialize any variables for each connection.
   */
  public boolean handleRequest()
    throws IOException
  {
    ReadStream in = _connection.getReadStream();
   
    SnmpParser parser = new SnmpParser(in);
    SnmpMessageValue req = parser.readMessage();
   
    checkVersion(req);
View Full Code Here

      _socket = new Socket(host, port);
      _socket.setSoTimeout(10000);
      SocketStream s = new SocketStream(_socket);
   
      _os = new WriteStream(s);
      _is = new ReadStream(s, _os);

      String line = _is.readLine();
     
      log.fine("smtp connection to " + host + ":" + port + " succeeded");
      log.fine("smtp: " + line);
View Full Code Here

      Constructor<?> ctor = cl.getConstructor(new Class[] { int.class, boolean.class, boolean.class });
     
      stream = (StreamImpl) ctor.newInstance(stdoutFd, true, false);
     
      _is = new ReadStream(stream);
    } catch (Exception e) {
      throw ConfigException.create(e);
    }
  }
View Full Code Here

    @Override
    public int read(byte []buf, int offset, int length)
      throws IOException
    {
      int sublen = _pendingData;
      ReadStream is = _is;

      if (sublen <= 0)
        return -1;

      if (length < sublen)
        sublen = length;

      _os.flush();
      int readLen = is.read(buf, offset, sublen);
      _pendingData -= readLen;

      if (log.isLoggable(Level.FINEST))
        log.finest(new String(buf, offset, readLen));

      while (_pendingData == 0) {
        _os.flush();

        int code = is.read();

        switch (code) {
        case HMUX_DATA: {
          int len = (is.read() << 8) + is.read();

          if (log.isLoggable(Level.FINE))
            log.fine(_request.dbgId() + "D-r:post-data " + len);

          _pendingData = len;

          if (len > 0)
            return readLen;

          break;
        }

        case HMUX_QUIT: {
          if (log.isLoggable(Level.FINE))
            log.fine(_request.dbgId() + "Q-r:quit");

          return readLen;
        }

        case HMUX_EXIT: {
          if (log.isLoggable(Level.FINE))
            log.fine(_request.dbgId() + "X-r:exit");

          _request.killKeepalive("hmux request exit");
          return readLen;
        }

        case HMUX_YIELD: {
          _request.flushResponseBuffer();

          _os.write(HMUX_ACK);
          _os.write(0);
          _os.write(0);
          _os.flush();

          if (log.isLoggable(Level.FINE)) {
            log.fine(_request.dbgId() + "Y-r:yield");
            log.fine(_request.dbgId() + "A-w:ack");
          }
          break;
        }

        case HMUX_CHANNEL: {
          int channel = (is.read() << 8) + is.read();

          if (log.isLoggable(Level.FINE))
            log.fine(_request.dbgId() + "channel-r " + channel);
          break;
        }

        case ' ': case '\n':
          break;

        default:
          if (code < 0) {
            _request.killKeepalive("hmux request end-of-file");

            return readLen;
          }
          else {
            _request.killKeepalive("hmux unknown request: " + (char) code);

            int len = (is.read() << 8) + is.read();

            if (log.isLoggable(Level.FINE))
              log.fine(_request.dbgId() + "unknown-r '" + (char) code + "' " + len);

            is.skip(len);
          }
        }
      }

      return readLen;
View Full Code Here

  private SelectResultSetImpl()
  {
    _ws = new WriteStream();
    _ws.setReuseBuffer(true);
    _ts = new TempStream();
    _rs = new ReadStream();
    _rs.setReuseBuffer(true);
    _buf = TempBuffer.allocate();
    _buffer = _buf.getBuffer();
    _cb = new CharBuffer();
View Full Code Here

 
  public boolean next()
    throws SQLException
  {
    try {
      ReadStream rs = _rs;

      _lastColumn = 0;
     
      int hasData = rs.read();
      if (hasData <= 0)
        return false;

      int length = 0;
      int fields = _exprs.length;

      byte []buffer = _buffer;
      for (int i = 0; i < fields; i++) {
        int type = rs.read();

        int sublen = 0;

        if (type < 0)
          return false;

        ColumnType cType = ColumnType.values()[type];

        switch (cType) {
        case NONE:
          sublen = -1;
          break;

        case VARCHAR:
          int l0 = rs.read();
          int l1 = rs.read();
          int l2 = rs.read();
          int l3 = rs.read();

          sublen = ((l0 << 24) +
                    (l1 << 16) +
                    (l2 << 8) +
                    (l3));
          break;

        case INT:
          sublen = 4;
          break;
        case LONG:
        case DOUBLE:
        case DATE:
          sublen = 8;
          break;

        case BLOB:
          sublen = 128;
          break;

        default:
          throw new SQLException("Unknown column: " + type);
        }

        _types[i] = cType;
        _offsets[i] = length;
        _lengths[i] = sublen;

        if (sublen > 0) {
          rs.read(buffer, length, sublen);

          length += sublen;
        }
      }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.ReadStream$StreamReader

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.