Package com.caucho.vfs

Examples of com.caucho.vfs.TempCharBuffer


  public CharBuffer getCharBuffer()
  {
    CharBuffer cb = new CharBuffer();
     
    TempCharBuffer head = _tempStream.getHead();

    for (; head != null; head = head.getNext()) {
      char []cbuf = head.getBuffer();

      cb.append(cbuf, 0, head.getLength());
    }
     
    return cb;
  }
View Full Code Here


  /**
   * Returns a string representing the body content.
   */
  public String getString()
  {
    TempCharBuffer head = _tempStream.getHead();

    if (head == null || head.getBuffer().length == 0)
      return "";

    int bomLength = 0;

    if (head.getBuffer()[0] == 0xfeff)
      bomLength = 1;

    if (head.getNext() == null)
      return new String(head.getBuffer(), bomLength, head.getLength() - bomLength);

    int length = 0;
    for (; head != null; head = head.getNext())
      length += head.getLength();

    char []buf = new char[length];

    int offset = 0;
    for (head = _tempStream.getHead(); head != null; head = head.getNext()) {
      char []cbuf = head.getBuffer();
      int sublen = head.getLength();

      System.arraycopy(cbuf, 0, buf, offset, sublen);

      offset += sublen;
    }
View Full Code Here

  /**
   * Returns a string representing the body content.
   */
  public String getTrimString()
  {
    TempCharBuffer head = _tempStream.getHead();

    boolean hasData = false;

    char []buf = null;
    int totalLength = 0;
    for (; head != null; head = head.getNext()) {
      char []cbuf = head.getBuffer();
      int end = head.getLength();
      int offset = 0;

      if (! hasData) {
  for (offset = 0; offset < end; offset++) {
    if (! Character.isWhitespace(cbuf[offset])) {
      hasData = true;
      break;
    }
  }
      }

      if (head.getNext() == null) {
  for (; offset < end; end--) {
    if (! Character.isWhitespace(cbuf[end - 1]))
      break;
  }

View Full Code Here

   * Writes the body contents out to the named writer.
   */
  public void writeOut(Writer out) throws IOException
  {
    try {
      TempCharBuffer head = _tempStream.getHead();
      boolean isFirst = true;

      for (; head != null; head = head.getNext()) {
  int offset = 0;
  int length = head.getLength();
  char []cbuf = head.getBuffer();

  if (isFirst && length > 0 && cbuf[0] == 0xfeff) {
    // skip byte-order-mark
    offset = 1;
    length--;
View Full Code Here

      res.setHeader("Cache-Control", "private");
    }

    // res.setContentLength(_contentLength);

    TempCharBuffer buf = TempCharBuffer.allocate();
    char []cBuf = buf.getBuffer();
    int len;

    PrintWriter out = response.getWriter();
   
    ReadStream rs = _cacheEntry.openRead();
View Full Code Here

  public static Value socket_read(Env env,
                                  @NotNull SocketInputOutput socket,
                                  int length, @Optional int type)
  {
    TempBuffer tempBuffer = null;
    TempCharBuffer tempCharBuffer = null;

    try {
      if (type == PHP_NORMAL_READ) {
        return socket.readLine(length);
      } else {
View Full Code Here

  public static Value socket_read(Env env,
                                  @NotNull SocketInputOutput socket,
                                  int length, @Optional int type)
  {
    TempBuffer tempBuffer = null;
    TempCharBuffer tempCharBuffer = null;

    try {
      if (type == PHP_NORMAL_READ) {
        return socket.readLine(length);
      } else {
View Full Code Here

  @Override
  protected StringBuilder decodeImpl(Env env, StringValue str)
  {
    ByteBuffer in = ByteBuffer.wrap(str.toBytes());
   
    TempCharBuffer tempBuf = TempCharBuffer.allocate();
   
    try  {
      CharBuffer out = CharBuffer.wrap(tempBuf.getBuffer());
     
      StringBuilder sb = new StringBuilder();
     
      while (in.hasRemaining()) {
        CoderResult coder = _decoder.decode(in, out, false);
View Full Code Here

TOP

Related Classes of com.caucho.vfs.TempCharBuffer

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.