This method fills the {@link CellBuffer} with the payload for the current cell.

@param state is the {@link ColumnState}.
@param buffer is the {@link CellBuffer}.
518598
protected void appendCellBuffer(ColumnState state, CellBuffer buffer) {

    int bufferRest = buffer.getRest();

    boolean hyphenationActive = (buffer.maxLength >= TextColumnInfo.MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN);

    boolean todo = true;
    // while ((todo) && (bufferRest > 0)) {
    while (todo) {
      TextSegment currentSegment = state.currentSegment;
      if (currentSegment.getType() == TextSegmentType.NEWLINE) {
        switch (state.getColumnInfo().getIndentationMode()) {
          case NO_INDENT_AFTER_NEWLINE:
            state.indent = false;
            break;
          case NO_INDENT_AFTER_DOUBLE_NEWLINE:
            if (state.getSubsequentNewlineCount() >= 2) {
              state.indent = false;
            } else {
              state.indent = true;
            }
            break;
          case INDENT_AFTER_NEWLINE:
            state.indent = true;
            break;
          default :
            throw new IllegalStateException("" + state.getColumnInfo().getIndentationMode());
        }
        state.proceedTextSegment();
        todo = false;
      } else {
        // currentSegment is no newline event...
        int segmentStartOffset = state.textIndex - currentSegment.startIndex;
        int segmentRest = currentSegment.getLength() - segmentStartOffset;
        int space = bufferRest - segmentRest;
        TextSegmentType nextType = null;
        if (state.nextSegment != null) {
          nextType = state.nextSegment.type;
        }
        if (hyphenationActive) {
          if (TextSegmentType.PUNCTUATION_CHARACTER == nextType) {
            space--;
          } else if (TextSegmentType.NON_BREAKING_CHARACTER == nextType) {
            // TODO
            // latest|Nmidnight
            // * la-|testNmidnight
            // latestNmid|night
            // * latest|midnight
            // latestNmid|night
            // * latestNmid-|night
            space--;
          }
        }
        if (space >= 0) {
          // entire segment fits...
          bufferRest = buffer.append(currentSegment.text, state.textIndex, currentSegment.endIndex);
          todo = state.proceedTextSegment();
        } else {
          // segment does NOT fit and has to be wrapped...
          if (hyphenationActive && (currentSegment.getType() == TextSegmentType.WORD)) {
            Hyphenation hyphenation = currentSegment.getHyphenatedWord();
            // int hyphenationBefore = bufferRest + segmentStartOffset;
            // space is actually negative here...
            int hyphenationBefore = currentSegment.getLength() + space;
            if (hyphenationBefore == currentSegment.endIndex) {
              hyphenationBefore++;
            }
            int hyphenationPoint = hyphenation.getHyphenationBefore(hyphenationBefore);
            int hyphenationOffset = hyphenationPoint - segmentStartOffset;
            // hyphenation point available that fits?
            if (hyphenationOffset <= 0) {
              // determine ratio of filled text length to space left
              int fillRatio;
              if (bufferRest > 6) {
                // accept no rest longer than 6 spaces...
                fillRatio = 0;
              } else if (bufferRest <= 2) {
                // avoid wrapping word at a single character e.g. break "is" as:
                // i-
                // s
                fillRatio = Integer.MAX_VALUE;
              } else {
                fillRatio = buffer.length() / bufferRest;
              }
              if (fillRatio <= 3) {
                hyphenationOffset = bufferRest - 1;
              } else {
                // high ratio means cell is filled okay and only little rest
                // left do NOT append any
                todo = false;
                break;
              }
            }
            int end = state.textIndex + hyphenationOffset;
            if (end + 1 == currentSegment.endIndex) {
              end--;
            }
            bufferRest = buffer.append(currentSegment.text, state.textIndex, end);
            if (end < currentSegment.endIndex) {
              bufferRest = buffer.append(state.hyphenator.getHyphen());
            } else {
              todo = state.proceedTextSegment();
            }
            state.textIndex = end;
            todo = false;
          } else {
            int end = state.textIndex + bufferRest;
            buffer.append(currentSegment.text, state.textIndex, end);
            state.textIndex = end;
            todo = false;
          }
        }
      }
    }
  }
1145319
public static void clearToFill(ByteBuffer buffer) {
        if (buffer != null) {
            buffer.position(0);
            buffer.limit(buffer.capacity());
        }
    }
1214641
public void openHeaderCell(ThTag.State state, AbstractRenderAppender appender) {
        _thRenderer.doStartTag(appender, state);
    }
1348064
private void setState(FieldState state) {
        if (DEBUG)
            LOG.debug("{}:{} --> {}", _state, _fieldState, state);
        _fieldState = state;
    }
1194287
public void writeTo(SocketChannel channel) throws IOException {
        channel.write(buffer);

        // only if buffer is empty
        if (buffer.remaining() == 0) {
            buffer.clear();
            state = BufferState.READY_TO_WRITE;
        }
    }
868064
@Override
  public void write(byte[] b, int start, int length) throws IOException {
    currentDataSegmentBuffer.write(b, start, length);
    flushIfNeeded();
  }
939391
@Override
    public void restoreState(final FacesContext context, final Object state) {
        if (state == null) {
            return;
        }

        final Object values[] = (Object[]) state;
        super.restoreState(context, values[0]);
        final Object restoredSubmittedValues = values[1];
        final Object restoredLocalValues = values[2];
        final Object restoredInvalidUpdates = values[3];
        final Object restoredColMappings = values[4];
        final Object restoredSortedList = values[5];
        final Object restoredRowMap = values[6];
        final Object restoredRowNumbers = values[7];

        if (restoredSubmittedValues == null) {
            submittedValues.clear();
        }
        else {
            submittedValues = (Map<SheetRowColIndex, String>) restoredSubmittedValues;
        }

        if (restoredLocalValues == null) {
            localValues.clear();
        }
        else {
            localValues = (Map<SheetRowColIndex, Object>) restoredLocalValues;
        }

        if (restoredInvalidUpdates == null) {
            getInvalidUpdates().clear();
        }
        else {
            invalidUpdates = (List<SheetInvalidUpdate>) restoredInvalidUpdates;
        }

        if (restoredColMappings == null) {
            columnMapping = null;
        }
        else {
            columnMapping = (Map<Integer, Integer>) restoredColMappings;
        }

        if (restoredSortedList == null) {
            getFilteredValue().clear();
        }
        else {
            setFilteredValue((List<Object>) restoredSortedList);
        }

        if (restoredRowMap == null) {
            rowMap = null;
        }
        else {
            rowMap = (Map<String, Object>) restoredRowMap;
        }

        if (restoredRowNumbers == null) {
            rowNumbers = null;
        }
        else {
            rowNumbers = (Map<String, Integer>) restoredRowNumbers;
        }
    }
500630
public void write(ByteArrayBuffer buf) {
        data.copy(buf.data, 0, pointer, buf.length());
        pointer += buf.length();
    }
749748
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  if (!isBuf) {
    chunk = decodeChunk(state, chunk, encoding);
    if (Buffer.isBuffer(chunk)) encoding = 'buffer';
  }
  var len = state.objectMode ? 1 : chunk.length;

  state.length += len;

  var ret = state.length < state.highWaterMark;
  // we must ensure that previous needDrain will not be reset to false.
  if (!ret) state.needDrain = true;

  if (state.writing || state.corked) {
    var last = state.lastBufferedRequest;
    state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
    if (last) {
      last.next = state.lastBufferedRequest;
    } else {
      state.bufferedRequest = state.lastBufferedRequest;
    }
    state.bufferedRequestCount += 1;
  } else {
    doWrite(stream, state, false, len, chunk, encoding, cb);
  }

  return ret;
}
446947
public void setBuffer(final String buffer) {
        initRandomBuffer();
        byteBufferAry = Arrays.copyOf(buffer.getBytes(), MAX_PACKETBUFFER_LENGTH);
    }
1295038
public void saveState() {
    s0=h0;
    s1=h1;
    s2=h2;
    s3=h3;
    s4=h4;
    
    saveLength = length;
    
    int position = finalBuffer.position();
    
    finalBuffer.position(0);
    finalBuffer.limit(position);
    
    saveBuffer.clear();
    saveBuffer.put(finalBuffer);
    saveBuffer.flip();
    
    finalBuffer.limit(64);
    finalBuffer.position( position );
  }
1302237
protected void put(ByteBuffer bb) {
       if(_buffer.remaining() < bb.remaining()) {
           int newCapacity = Math.max(_buffer.capacity() << 1, _buffer.position() + bb.remaining());
           ByteBuffer b = ByteBuffer.allocate(newCapacity);
           _buffer.flip();
           b.put(_buffer);
           _buffer = b;
       }
       
       _buffer.put(bb);
    }
933726
protected void bufferize(byte b) {
        if (index == buffer.length) {
            byte[] newBuffer = new byte[buffer.length * 2];
            System.arraycopy(buffer, 0, newBuffer, 0, index);
            buffer = newBuffer;
        }
        buffer[index++] = b;
    }
158068
function (buffer) {
            this._checkState(true);
            this._addContentToLastElement();
            this._appendToReadBuffer(_gpfStringEscapeForXml(buffer.toString()));
            return Promise.resolve();
        }
340701
@Override
  public synchronized void write(final int b) {
    BufferPool.Buffer buff = getBuffer(count, false);

    if (buff == null) {
      buff = newBuffer();
    }

    if (!buff.putByte(b)) {
      buff = newBuffer();
      if (!buff.putByte(b)) {
        throw new RuntimeException("Logic error in write(b)");
      }
    }

    count++;
  }
205989
public void fill(final double[][] data, final int startRow, final int startCol) {
		final int rows = data.length;
		final int cols = data[0].length;

		verifyTrue(startRow < rows && startRow < getRowCount(), "illegal startRow: %s", startRow);
		verifyTrue(startCol < cols && startCol < getColumnCount(), "illegal startCol: %s", startCol);
		verifyTrue(rows <= getRowCount(), "too many rows in input: %s: max allowed = %s", rows,
				getRowCount());
		verifyTrue(cols <= getColumnCount(), "too many columns in input: %s: max allowed = %s",
				cols, getColumnCount());

		for (int i = startRow; i < rows; i++) {
			for (int j = startCol; j < cols; j++) {
				setDouble(data[i][j], i, j);
			}
		}
	}
79222
public void acceptCell(C cell) {
        cell.reset();
        if(cell.isReusable()) {
            pool.add(cell);
        } else {
            cell.dispose();
        }
    }