public static ShortBuffer createShortBuffer(ShortBuffer buf, int size) {
        if (buf != null && buf.limit() == size) {
            buf.rewind();
            return buf;
        }

        buf = createShortBuffer(size);
        return buf;
    }
Create a new ShortBuffer of an appropriate size to hold the specified
number of shorts only if the given buffer if not already the right size.

@param buf
           the buffer to first check and rewind
@param size
           number of shorts that need to be held by the newly created
           buffer
@return the requested new ShortBuffer
jme3-core/src/main/java/com/jme3/util/BufferUtils.java