protected int replaceNaN(ShortBuffer shortBuffer, short value) { int length = shortBuffer.remaining(); int numValues = 0; if (this.tmpBuffer == null || this.tmpBuffer.length < shortBuffer.remaining()) { this.tmpBuffer = new short[length]; } shortBuffer.get(this.tmpBuffer, 0, length); shortBuffer.flip(); for (int i = 0; i < length; i++) { if (isNoValueShort(this.tmpBuffer[i])) { this.tmpBuffer[i] = value; } else { numValues++; } } shortBuffer.put(this.tmpBuffer, 0, length); shortBuffer.flip(); return(numValues); }