FileDocCategorySizeDatePackage
IntervalTimeInstance.javaAPI DocphoneME MR2 API (J2ME)6440Wed May 02 18:00:36 BST 2007com.sun.perseus.model

IntervalTimeInstance

public final class IntervalTimeInstance extends TimeInstance
This specialized TimeInstance is created by SyncBaseCondition time conditions.

IntervalTimeInstance instances can be notified of updates by the TimeCondition which created it. This update can result on a Time update on the instance depending on context.

see
SMIL 2 Timing: Propagating changes to time
version
$Id: IntervalTimeInstance.java,v 1.3 2006/06/29 10:47:32 ln156897 Exp $

Fields Summary
long
offset
Offset from the interval sync base.
TimeInterval
timeInterval
Associated interval.
boolean
isBeginSync
Controls whether the instance synchronizes on begin or end
TimedElementSupport
syncBase
Associated syncBase
Constructors Summary
IntervalTimeInstance(TimedElementSupport timedElement, TimedElementSupport syncBase, long offset, boolean clearOnReset, boolean isBegin, boolean isBeginSync)
Builds an instance time for the input TimedElementSupport and time. The constructor will insert the instance automatically into the TimeInterval's corresponding dependent list

param
timedElement the associated TimedElementSupport. Should not be null.
param
syncBase the TimedElementSupport this time instance synchronizes with.
param
offset this instance offset from the synch base.
param
clearOnReset defines whether or not this instance should be cleared from instance times lists on reset.
param
isBegin true if this object is part of the timedElement's begin instance list.
param
isBeginSync true if this instance is synchronized on the interval's begin time. False if this instance is synchronized on the interval's end time.

        super(timedElement, 
              getTime(syncBase.currentInterval, 
                      isBeginSync, 
                      offset, 
                      timedElement, 
                      syncBase),
              clearOnReset, 
              isBegin);

        this.offset = offset;
        this.syncBase = syncBase;
        this.timeInterval = syncBase.currentInterval;
        this.isBeginSync = isBeginSync;

        timeInterval.addDependent(this);
    
Methods Summary
voiddispose()
Invoke when this instance is no longer in a begin or end instance list, i.e., when it is removed from one of these lists.

        timeInterval.removeDependent(this);
    
private static TimegetTime(TimeInterval interval, boolean isBeginSync, long offset, TimedElementSupport timedElement, TimedElementSupport syncBase)
Implementation helpers.

param
interval the interval to get
param
isBeginSync the time to get
param
offset offset from the sync base value.
param
timedElement the TimedElementSupport to which the interval belongs
param
syncBase the TimedElementSupport with which the timedElement is synchronized.
return
the input interval's begin or end time. This method accounts for the offset from the syncBase and for the time convertion between the syncBase and the instance's timedElement.

        if (isBeginSync && !interval.begin.isResolved()) {
            // 'unresolved' and 'indefinite' times are not
            // legal begin time for intervals. This is an illegal
            // state, so we throw an exception.
            throw new IllegalStateException();
        }

        Time t = interval.begin;
        if (!isBeginSync) {
            t = interval.end;
        }

        if (!t.isResolved()) {
            return t;
        } else {
            // Convert the time value from the syncBase's time space
            // to the timedElement time space.
            Time time = new Time(t.value + offset);
            return timedElement.toContainerSimpleTime
                (syncBase.toRootContainerSimpleTime(time));
        }
    
voidonIntervalUpdate()
Must be called by the TimeInterval's begin or end time this instance depends on changes.

This method update this time instance with a new time, accounting for the offset from the sync base.

        setTime(getTime(timeInterval, isBeginSync, offset, timedElement, 
                        syncBase));
    
voidsyncTime()
Used to synchronize this instance's time with its syncBase time. This is used when resetting timed elements.

        setTime(getTime(timeInterval, isBeginSync, offset, timedElement, 
                        syncBase));