Package com.caucho.vfs

Examples of com.caucho.vfs.TempCharBuffer


   * @param url the source url to parse from
   */
  private void parseImpl()
    throws IOException, SAXException
  {
    TempCharBuffer inputBuffer = TempCharBuffer.allocate();
    TempCharBuffer valueBuffer = TempCharBuffer.allocate();
    try {
      _valueBuf = valueBuffer.getBuffer();
      _inputBuf = inputBuffer.getBuffer();
      _inputLength = 0;
      _inputOffset = 0;
      _line = 1;

View Full Code Here


   * Writes the inode value to a stream.
   */
  public void writeToWriter(Writer writer)
    throws IOException
  {
    TempCharBuffer tempBuffer = TempCharBuffer.allocate();

    char []buffer = tempBuffer.getBuffer();
    int writeLength = buffer.length;
    long offset = 0;

    while (true) {
      int sublen = writeLength;
View Full Code Here

   * Writes the inode value to a stream.
   */
  public void writeToWriter(Writer out)
    throws IOException
  {
    TempCharBuffer charBuffer = TempCharBuffer.allocate();
    char []buffer = charBuffer.getBuffer();

    long offset = 0;

    long length = _length;

View Full Code Here

    }
    else if (_charLength == SIZE) {
      _tail.setLength(_charLength);
      _bufferSize += _charLength;

      TempCharBuffer tempBuf = TempCharBuffer.allocate();
      _tail.setNext(tempBuf);
      _tail = tempBuf;

      _charBuffer = _tail.getBuffer();
      _charLength = 0;
View Full Code Here

  {
    _tail.setLength(_charLength);
    _bufferSize += _charLength;
    _charLength = 0;

    TempCharBuffer ptr = _head;
    do {
      _head = ptr;
     
      TempCharBuffer next = ptr.getNext();
      ptr.setNext(null);

      writeNext(ptr.getBuffer(), 0, ptr.getLength());

      if (next != null)
View Full Code Here

  @Override
  public void clearBuffer()
  {
    _charLength = 0;

    TempCharBuffer ptr = _head;
    do {
      _head = ptr;
     
      TempCharBuffer next = ptr.getNext();
      ptr.setNext(null);

      if (next != null)
        TempCharBuffer.free(ptr);
View Full Code Here

  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

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.