Returns the amount of free space in the buffer. May return a negative value if there are more messages in the buffer than should fit there (because of creating new messages). @return The amount of free space (Integer.MAX_VALUE if the buffer size isn't defined)
()
| 262 | * size isn't defined) |
| 263 | */ |
| 264 | public int getFreeBufferSize() { |
| 265 | int occupancy = 0; |
| 266 | |
| 267 | if (this.getBufferSize() == Integer.MAX_VALUE) { |
| 268 | return Integer.MAX_VALUE; |
| 269 | } |
| 270 | |
| 271 | for (Message m : getMessageCollection()) { |
| 272 | occupancy += m.getSize(); |
| 273 | } |
| 274 | |
| 275 | return this.getBufferSize() - occupancy; |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Returns the host this router is in |
no test coverage detected