@return true if there is space in inputBuffer.
(EncoderJNI.Operation op)
| 163 | * @return true if there is space in inputBuffer. |
| 164 | */ |
| 165 | boolean encode(EncoderJNI.Operation op) throws IOException { |
| 166 | boolean force = (op != EncoderJNI.Operation.PROCESS); |
| 167 | if (force) { |
| 168 | ((Buffer) inputBuffer).limit(inputBuffer.position()); |
| 169 | } else if (inputBuffer.hasRemaining()) { |
| 170 | return true; |
| 171 | } |
| 172 | boolean hasInput = true; |
| 173 | while (true) { |
| 174 | if (!encoder.isSuccess()) { |
| 175 | fail("encoding failed"); |
| 176 | } else if (!pushOutput(force)) { |
| 177 | return false; |
| 178 | } else if (encoder.hasMoreOutput()) { |
| 179 | buffer = encoder.pull(); |
| 180 | } else if (encoder.hasRemainingInput()) { |
| 181 | encoder.push(op, 0); |
| 182 | } else if (hasInput) { |
| 183 | encoder.push(op, inputBuffer.limit()); |
| 184 | hasInput = false; |
| 185 | } else { |
| 186 | ((Buffer) inputBuffer).clear(); |
| 187 | return true; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | void flush() throws IOException { |
| 193 | encode(EncoderJNI.Operation.FLUSH); |
no test coverage detected