Appends the data to the buffer. If the data is incorrectly formatted, ie, the data should always start with the header, false will be returned and the data will be discarded. @param b - bytes to be appended @param len - the number of bytes to append. @return true if the data was appended correct
(ByteBuffer b, int len)
| 198 | * something, or the length of data is 0 |
| 199 | */ |
| 200 | public boolean append(ByteBuffer b, int len) { |
| 201 | int newcount = bufSize + len; |
| 202 | if (newcount > buf.length) { |
| 203 | expand(newcount); |
| 204 | } |
| 205 | b.get(buf, bufSize, len); |
| 206 | |
| 207 | bufSize = newcount; |
| 208 | |
| 209 | if (discard) { |
| 210 | if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) { |
| 211 | bufSize = 0; |
| 212 | log.error(sm.getString("xByteBuffer.discarded.invalidHeader")); |
| 213 | return false; |
| 214 | } |
| 215 | } |
| 216 | return true; |
| 217 | |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Appends a single byte to the buffer. |