code: private static final <T extends Appendable> void encodeRun(T buffer, byte value, int length,
              byte[] state) {
          if (length < 4) {
              for (int j=0; j<length; ++j) {
                  if (value == ESCAPE_BYTE) appendEncodedByte(buffer, ESCAPE_BYTE, state);
                  appendEncodedByte(buffer, value, state);
              }
          }
          else {
              if ((byte)length == ESCAPE_BYTE) {
                  if (value == ESCAPE_BYTE) appendEncodedByte(buffer, ESCAPE_BYTE, state);
                  appendEncodedByte(buffer, value, state);
                  --length;
              }
              appendEncodedByte(buffer, ESCAPE_BYTE, state);
              appendEncodedByte(buffer, (byte)length, state);
              appendEncodedByte(buffer, value, state); // Don't need to escape this value
          }
      }
docs: Encode a run, possibly a degenerate run (of < 4 values).
  @param length The length of the run; must be > 0 && <= 0xFF.