FileDocCategorySizeDatePackage
RepeatField.javaAPI DocphoneME MR2 API (J2ME)7923Wed May 02 18:00:42 BST 2007gov.nist.javax.sdp.fields

RepeatField

public class RepeatField extends SDPField
Repeat SDP Field (part of the time field).
version
JSR141-PUBLIC-REVIEW (subject to change). This code is in the public domain.

Fields Summary
protected TypedTime
repeatInterval
Repeat interval.
protected TypedTime
activeDuration
Duration.
protected SDPObjectList
offsets
List of time offsets.
Constructors Summary
public RepeatField()
Default constructor.

 
	super(REPEAT_FIELD); 
	offsets = new SDPObjectList();
    
Methods Summary
public voidaddOffset(TypedTime offset)
Adds an starting time offset.

param
offset the new time offset to process

	offsets.addElement(offset);
    
public java.lang.Objectclone()
Copies the current instance.

return
the copy of this object

	RepeatField retval = new RepeatField();
	if (this.repeatInterval != null) 
	    retval.repeatInterval = 
		(TypedTime) this.repeatInterval.clone();
	if (this.activeDuration != null) 
	    retval.activeDuration = 
		(TypedTime)this.activeDuration.clone();
	retval.offsets = 
	    (SDPObjectList) this.offsets.clone();
	return retval;
    
public java.lang.Stringencode()
Gets an encoded string representation of the object.

return
the encoded string of object contents

	String retval =  REPEAT_FIELD + repeatInterval.encode() 
	    + Separators.SP +
	    activeDuration.encode();
	for (int i = 0; i < offsets.size(); i++) { 
	    TypedTime off = (TypedTime) offsets.elementAt(i);
	    retval += Separators.SP + off.encode();
	}
	retval += Separators.NEWLINE;
	return retval;
    
public intgetActiveDuration()
Returns the "active duration" in seconds.

throws
SdpParseException if a parinsg error occurs
return
the "active duration" in seconds.

        if (activeDuration == null)
	    return -1;
        else {
            return activeDuration.getTime();
        }
    
public int[]getOffsetArray()
Returns the list of offsets. These are relative to the start-time given in the Time object (t=field) with which this RepeatTime is associated.

throws
SdpParseException if a parsing error occurs
return
the list of offsets

	int[] result = new int[offsets.size()];
	for (int i = 0; i < offsets.size(); i++) {
            TypedTime typedTime = (TypedTime)offsets.elementAt(i);
            result[i] = typedTime.getTime();
	}
	return result;
    
public java.util.VectorgetOffsets()
Gets a vector of starting time offsets.

return
vector of time offsets

 return offsets; 
public intgetRepeatInterval()
Returns the "repeat interval" in seconds.

throws
SdpParseException if a parsing error occurs
return
the "repeat interval" in seconds.

        if (repeatInterval == null)
	    return -1;
        else {
            return repeatInterval.getTime();
        }
    
public booleangetTypedTime()
Returns whether the field will be output as a typed time or a integer value. Typed time is formatted as an integer followed by a unit character. The unit indicates an appropriate multiplier for the integer.
The following unit types are allowed.
d - days (86400 seconds)
h - hours (3600 seconds)
m - minutes (60 seconds)
s - seconds ( 1 seconds)

throws
SdpParseException if a parsing error occurs
return
true, if the field will be output as a typed time; false, if as an integer value.

        return true;
    
public voidsetActiveDuration(int activeDuration)
Sets the "active duration" in seconds.

param
activeDuration the "active duration" in seconds.
throws
SdpException if the active duration is less than 0

        if (activeDuration < 0) 
	    throw new SdpException("The active Duration is < 0");
        else {
	    if (this.activeDuration == null) 
		this.activeDuration = new TypedTime();
	    this.activeDuration.setTime(activeDuration);
        }
    
public voidsetActiveDuration(TypedTime duration)
Sets the duration.

param
duration the active duration time period

	activeDuration = duration; 
    
public voidsetOffsetArray(int[] offsets)
Sets the list of offsets. These are relative to the start-time given in the Time object (t=field) with which this RepeatTime is associated.

param
offsets array of repeat time offsets
throws
SdpException if an error occurs setting the offsets

        for (int i = 0; i < offsets.length; i++) {
            TypedTime typedTime = new TypedTime();
            typedTime.setTime(offsets[i]);
            addOffset(typedTime);
        }
        
    
public voidsetRepeatInterval(TypedTime interval)
Sets the repeat interval.

param
interval the new repeat interval

	repeatInterval = interval;
    
public voidsetRepeatInterval(int repeatInterval)
Sets the repeat interval in seconds.

param
repeatInterval the "repeat interval" in seconds.
throws
SdpException if repeatInterval is less than 0

        if (repeatInterval < 0) 
	    throw new SdpException("The repeat interval is < 0");
        else {
	    if (this.repeatInterval == null) 
		this.repeatInterval = new TypedTime();
	    this.repeatInterval.setTime(repeatInterval);
        }
    
public voidsetTypedTime(boolean typedTime)
Sets whether the field will be output as a typed time or a integer value. Typed time is formatted as an integer followed by a unit character. The unit indicates an appropriate multiplier for the integer.
The following unit types are allowed.
d - days (86400 seconds)
h - hours (3600 seconds)
m - minutes (60 seconds)
s - seconds ( 1 seconds)

param
typedTime typedTime - if set true, the start and stop times will be output in an optimal typed time format; if false, the times will be output as integers.