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

SyncBaseCondition

public final class SyncBaseCondition extends TimeCondition implements TimeDependent, IDRef
An SyncBaseCondition generates a TimeInstance everytime the SyncBase TimedElementSupport generates a new interval (i.e., each time its newInterval method is called by the TypedElement. A SyncBaseCondition is a time dependent of it's sync base TimedElementSupport
version
$Id: SyncBaseCondition.java,v 1.3 2006/04/21 06:39:09 st125089 Exp $

Fields Summary
String
syncBaseId
The SyncBase identifier
TimedElementSupport
syncBase
SyncBase TimedElementSupport
boolean
isBeginSync
True if this condition is on the syncBase's begin.
long
offset
Offset from the synch base
Constructors Summary
public SyncBaseCondition(TimedElementNode timedElementNode, boolean isBegin, String syncBaseId, boolean isBeginSync, long offset)

param
timedElementNode the associated TimedElementNode. Should not be null.
param
isBegin defines whether this condition is for a begin list.
param
syncBaseId identifier of the TimedElementSupport this condition is synchronized on. Should not be null.
param
isBeginSync true if this condition is on the syncBase's begin condition. False if this condition is on the syncBase's end condition.
param
offset offset from the sync base. This means that time instances synchronized on the syncBase begin or end time are offset by this amount.

        super(timedElementNode.timedElementSupport, isBegin);

        if (syncBaseId == null) {
            throw new NullPointerException();
        }

        this.syncBaseId = syncBaseId;
        this.isBeginSync = isBeginSync;
        this.offset = offset;

        timedElementNode.ownerDocument.resolveIDRef(this, syncBaseId);
    
Methods Summary
public voidonNewInterval(TimedElementSupport syncBase)
Called by the associated sync base when it creates a new current TimeInterval. Whenever this happens, a new IntervalTimeInstance is added for the sync base's begin or end interval time (depending on isBeginSync), to the timedElement's begin or end instance list (depending on isBegin).

param
syncBase the element which just generated a new interval.

        // IntervalTimeInstances are _not_ cleared on reset
        new IntervalTimeInstance(timedElement, syncBase, 
                                 offset, false, isBegin, isBeginSync);
    
public voidresolveTo(ElementNode ref)
IDRef implementation.

param
ref the resolved reference (mapped from the syncBase id passed to the constructor.

        if (!(ref instanceof TimedElementNode)) {
            // The condition is synchronized on an element which does 
            // not have timing. Do nothing, this is _not_ an error.
            return;
        }

        syncBase = ((TimedElementNode) ref).timedElementSupport;

        if (isBeginSync) {
            if (syncBase.beginDependents == null) {
                syncBase.beginDependents = new Vector(1);
            }
            syncBase.beginDependents.addElement(this);
        } else {
            if (syncBase.endDependents == null) {
                syncBase.endDependents = new Vector(1);
            }
            syncBase.endDependents.addElement(this);
        }
    
protected java.lang.StringtoStringTrait()
Converts this SyncBaseCondition to a String trait.

return
a string describing this TimeCondition

        StringBuffer sb = new StringBuffer();
        sb.append(syncBaseId);
        sb.append('.");
        if (isBeginSync) {
            sb.append("begin");
        } else {
            sb.append("end");
        }

        if (offset != 0) {
            if (offset > 0) {
                sb.append('+");
            }
            sb.append(offset / 1000f);
            sb.append('s");
        }

        return sb.toString();