edu.uiuc.cs397rhc.sound
Class AtomicMidiCondition

java.lang.Object
  extended by edu.uiuc.cs397rhc.sound.AtomicMidiCondition
All Implemented Interfaces:
MidiCondition

public class AtomicMidiCondition
extends java.lang.Object
implements MidiCondition

AtomicMidiConditions represent atomic conditions over the fields of a ShortMessage. These atomic conditions are not created directly, but are instead produced using static factory methods.

Author:
Pedro DeRose

Nested Class Summary
static class AtomicMidiCondition.Field
          The fields of a ShortMessage, complete with a method to extract the value from a specific ShortMessage.
 
Method Summary
static MidiCondition createBetweenExclusive(AtomicMidiCondition.Field field, long value1, long value2)
          Factory method to create a MidiCondition specifying that the given field be beween the two given values, exclusive.
static MidiCondition createBetweenInclusive(AtomicMidiCondition.Field field, long value1, long value2)
          Factory method to create a MidiCondition specifying that the given field be between the two given values, inclusive.
static MidiCondition createEq(AtomicMidiCondition.Field field, long value)
          Factory method to create a MidiCondition specifying that the given field be equal to the given value.
static MidiCondition createGt(AtomicMidiCondition.Field field, long value)
          Factory method to create a MidiCondition specifying that the given field be greater than the given value.
static MidiCondition createGte(AtomicMidiCondition.Field field, long value)
          Factory method to create a MidiCondition specifying that the given field be greater than or equal to the given value.
static MidiCondition createLt(AtomicMidiCondition.Field field, long value)
          Factory method to create a MidiCondition specifying that the given field be less thanthe given value.
static MidiCondition createLte(AtomicMidiCondition.Field field, long value)
          Factory method to create a MidiCondition specifying that the given field be less than or equal to the given value.
static MidiCondition createNotEq(AtomicMidiCondition.Field field, long value)
          Factory method to create a MidiCondition specifying that the given field be not equal to the given value.
static MidiCondition createOutsideExclusive(AtomicMidiCondition.Field field, long value1, long value2)
          Factory method to create a MidiCondition specifying that the given field be outside the two given values, exclusive.
static MidiCondition createOutsideInclusive(AtomicMidiCondition.Field field, long value1, long value2)
          Factory method to create a MidiCondition specifying that the given field be outside the two given values, inclusive.
 boolean equals(java.lang.Object other)
           
 java.lang.String getPrettyString()
          Returns a pretty, printable representation of this condition.
 boolean isSatisfiedBy(javax.sound.midi.MidiMessage msg, long time)
          Whether the given MidiMessage and timestamp satisfy this AtomicMidiCondition.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isSatisfiedBy

public boolean isSatisfiedBy(javax.sound.midi.MidiMessage msg,
                             long time)
Whether the given MidiMessage and timestamp satisfy this AtomicMidiCondition.

Specified by:
isSatisfiedBy in interface MidiCondition
Parameters:
msg - the message
time - the timestamp
Returns:
true if the field checked by this AtomicMidiCondition is on the interval [low,high], false otherwise

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getPrettyString

public java.lang.String getPrettyString()
Description copied from interface: MidiCondition
Returns a pretty, printable representation of this condition. This will be used to recursively print out complex conditions.

Specified by:
getPrettyString in interface MidiCondition
Returns:
a pretty, printable representation of this condition

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createEq

public static MidiCondition createEq(AtomicMidiCondition.Field field,
                                     long value)
Factory method to create a MidiCondition specifying that the given field be equal to the given value.

Parameters:
field - the field to be tested
value - the value to be used in testing
Returns:
a MidiCondition that represents the given field being equal to the given value

createNotEq

public static MidiCondition createNotEq(AtomicMidiCondition.Field field,
                                        long value)
Factory method to create a MidiCondition specifying that the given field be not equal to the given value.

Parameters:
field - the field to be tested
value - the value to be used in testing
Returns:
a MidiCondition that represents the given field being not equal to the given value

createLte

public static MidiCondition createLte(AtomicMidiCondition.Field field,
                                      long value)
Factory method to create a MidiCondition specifying that the given field be less than or equal to the given value.

Parameters:
field - the field to be tested
value - the value to be used in testing
Returns:
a MidiCondition that represents the given field being less than or equal to the given value

createGte

public static MidiCondition createGte(AtomicMidiCondition.Field field,
                                      long value)
Factory method to create a MidiCondition specifying that the given field be greater than or equal to the given value.

Parameters:
field - the field to be tested
value - the value to be used in testing
Returns:
a MidiCondition that represents the given field being greater than or equal to the given value

createLt

public static MidiCondition createLt(AtomicMidiCondition.Field field,
                                     long value)
Factory method to create a MidiCondition specifying that the given field be less thanthe given value.

Parameters:
field - the field to be tested
value - the value to be used in testing
Returns:
a MidiCondition that represents the given field being less than the given value

createGt

public static MidiCondition createGt(AtomicMidiCondition.Field field,
                                     long value)
Factory method to create a MidiCondition specifying that the given field be greater than the given value.

Parameters:
field - the field to be tested
value - the value to be used in testing
Returns:
a MidiCondition that represents the given field being greater than the given value

createBetweenInclusive

public static MidiCondition createBetweenInclusive(AtomicMidiCondition.Field field,
                                                   long value1,
                                                   long value2)
Factory method to create a MidiCondition specifying that the given field be between the two given values, inclusive.

Parameters:
field - the field to be tested
value1 - the value to be used in testing
value2 - the value to be used in testing
Returns:
a MidiCondition that represents the given field being between the two given values, inclusive

createBetweenExclusive

public static MidiCondition createBetweenExclusive(AtomicMidiCondition.Field field,
                                                   long value1,
                                                   long value2)
Factory method to create a MidiCondition specifying that the given field be beween the two given values, exclusive.

Parameters:
field - the field to be tested
value1 - the value to be used in testing
value2 - the value to be used in testing
Returns:
a MidiCondition that represents the given field being between the two given values, exclusive

createOutsideInclusive

public static MidiCondition createOutsideInclusive(AtomicMidiCondition.Field field,
                                                   long value1,
                                                   long value2)
Factory method to create a MidiCondition specifying that the given field be outside the two given values, inclusive.

Parameters:
field - the field to be tested
value1 - the value to be used in testing
value2 - the value to be used in testing
Returns:
a MidiCondition that represents the given field being outside the two given values, inclusive

createOutsideExclusive

public static MidiCondition createOutsideExclusive(AtomicMidiCondition.Field field,
                                                   long value1,
                                                   long value2)
Factory method to create a MidiCondition specifying that the given field be outside the two given values, exclusive.

Parameters:
field - the field to be tested
value1 - the value to be used in testing
value2 - the value to be used in testing
Returns:
a MidiCondition that represents the given field being outside the two given values, exclusive