412
413 /**
414 * Obtains the second data byte in the message.
415 *
416 * @return the value of the {@code data2} field
417 * @see #setMessage(int, int, int)
418 */
419 public int getData2() {
420 if (length > 2) {
421 return (data[2] & 0xFF);
422 }
423 return 0;
424 }
425
426 /**
427 * Creates a new object of the same class and with the same contents as this
428 * object.
429 *
430 * @return a clone of this instance
431 */
432 public Object clone() {
433 byte[] newData = new byte[length];
434 System.arraycopy(data, 0, newData, 0, newData.length);
435
436 ShortMessage msg = new ShortMessage(newData);
437 return msg;
438 }
439
440 /**
441 * Retrieves the number of data bytes associated with a particular status
442 * byte value.
443 *
444 * @param status status byte value, which must represent a short MIDI
445 * message
446 * @return data length in bytes (0, 1, or 2)
447 * @throws InvalidMidiDataException if the {@code status} argument does not
448 * represent the status byte for any short message
449 */
450 protected final int getDataLength(int status) throws InvalidMidiDataException {
451 // system common and system real-time messages
|
412
413 /**
414 * Obtains the second data byte in the message.
415 *
416 * @return the value of the {@code data2} field
417 * @see #setMessage(int, int, int)
418 */
419 public int getData2() {
420 if (length > 2) {
421 return (data[2] & 0xFF);
422 }
423 return 0;
424 }
425
426 /**
427 * Creates a new object of the same class and with the same contents as this
428 * object.
429 *
430 * @return a clone of this instance
431 */
432 @Override
433 public Object clone() {
434 byte[] newData = new byte[length];
435 System.arraycopy(data, 0, newData, 0, newData.length);
436
437 ShortMessage msg = new ShortMessage(newData);
438 return msg;
439 }
440
441 /**
442 * Retrieves the number of data bytes associated with a particular status
443 * byte value.
444 *
445 * @param status status byte value, which must represent a short MIDI
446 * message
447 * @return data length in bytes (0, 1, or 2)
448 * @throws InvalidMidiDataException if the {@code status} argument does not
449 * represent the status byte for any short message
450 */
451 protected final int getDataLength(int status) throws InvalidMidiDataException {
452 // system common and system real-time messages
|