net.sourceforge.jsdp
Class RepeatTime

java.lang.Object
  extended by net.sourceforge.jsdp.RepeatTime
All Implemented Interfaces:
Serializable, Cloneable, Field

public class RepeatTime
extends Object
implements Field

A RepeatTime represents a r=<field value> field contained in a SDP message. A repeat time field specify repeat times for a session: his consists of a repeat interval, an active duration and a list of offsets relative to the Time.getStartTime() start time.

Since:
0.1.0
Version:
1.0
Author:
Claudio Di Vita
See Also:
Time, Serialized Form

Field Summary
protected  long activeDuration
          The active duraction
protected  boolean isTyped
          Indicates if the field will be output as a typed time or a number
protected  Vector offsets
          The list of offset relative to the t field start time
protected  long repeatInterval
          The repeat interval
 
Fields inherited from interface net.sourceforge.jsdp.Field
ATTRIBUTE_FIELD, BANDWITH_FIELD, CONNECTION_FIELD, EMAIL_FIELD, END_OF_FIELD, INFORMATION_FIELD, KEY_FIELD, MEDIA_FIELD, ORIGIN_FIELD, PHONE_FIELD, REPEAT_TIME_FIELD, SESSION_NAME_FIELD, TIME_FIELD, TIMEZONE_FIELD, URI_FIELD, VERSION_FIELD
 
Constructor Summary
protected RepeatTime()
          Creates a new RepeatTime.
  RepeatTime(long repeatInterval, long activeDuration, long offset)
          Creates a new RepeatTime.
  RepeatTime(long repeatInterval, long activeDuration, long[] offsets)
          Creates a new RepeatTime.
 
Method Summary
 void addOffset(long offset)
          Adds an offset to the field.
 Object clone()
          Returns a clone of this field.
 long getActiveDuration()
          Returns the active duration in seconds
 long[] getOffsets()
          Returns the list of offsets.
 long getRepeatInterval()
          Returns the repeat interval.
 char getType()
          Returns the type character for the field.
 boolean isTypedTime()
          Returns whether the field will be output as a typed time or a number.
static RepeatTime parse(String field)
          Parse an input string and constructs the equivalent repeat time field.
 void setActiveDuration(long activeDuration)
          Sets the active duration.
 void setOffset(long[] offsets)
          Set the list of offsets.
 void setRepeatInterval(long repeatInterval)
          Sets the repeat interval.
 void setTypedTime(boolean typedTime)
          Sets whether the field will be output as a typed time or a number.
 String toString()
          Returns a string representation of the field.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

repeatInterval

protected long repeatInterval
The repeat interval


activeDuration

protected long activeDuration
The active duraction


offsets

protected Vector offsets
The list of offset relative to the t field start time


isTyped

protected boolean isTyped
Indicates if the field will be output as a typed time or a number

Constructor Detail

RepeatTime

protected RepeatTime()
Creates a new RepeatTime.


RepeatTime

public RepeatTime(long repeatInterval,
                  long activeDuration,
                  long offset)
           throws SDPException
Creates a new RepeatTime.

Parameters:
repeatInterval - the repeat interval
activeDuration - the active duration
offset - the offset
Throws:
SDPException - if the parameters are not valid

RepeatTime

public RepeatTime(long repeatInterval,
                  long activeDuration,
                  long[] offsets)
           throws SDPException
Creates a new RepeatTime.

Parameters:
repeatInterval - the repeat interval
activeDuration - the active duration
offsets - the offsets
Throws:
SDPException - if the parameters are not valid
Method Detail

parse

public static RepeatTime parse(String field)
                        throws SDPParseException
Parse an input string and constructs the equivalent repeat time field.

Parameters:
field - the string to parse
Returns:
a new RepeatTime instance
Throws:
SDPParseException - if an error occurs while parsing

addOffset

public void addOffset(long offset)
               throws SDPException
Adds an offset to the field.

Parameters:
offset - the offset value
Throws:
SDPException - if the offset value is negative

clone

public Object clone()
Returns a clone of this field.

Specified by:
clone in interface Field
Overrides:
clone in class Object
Returns:
a clone of this field

getActiveDuration

public long getActiveDuration()
Returns the active duration in seconds

Returns:
the active duration

getOffsets

public long[] getOffsets()
Returns the list of offsets. These are relative to the start time given in the Time field with which this RepeatTime is associated.

Returns:
an array of repeat time offsets

getRepeatInterval

public long getRepeatInterval()
Returns the repeat interval.

Returns:
the repeat interval in seconds

getType

public char getType()
Returns the type character for the field.

Specified by:
getType in interface Field
Returns:
the field type character: r

isTypedTime

public boolean isTypedTime()
Returns whether the field will be output as a typed time or a number.

Typed time is formatted as an number followed by a unit character: the unit indicates an appropriate multiplier for the number. The following unit types are allowed:

Returns:
true if the field will be output as a typed time, false if as a number

setActiveDuration

public void setActiveDuration(long activeDuration)
                       throws SDPException
Sets the active duration.

Parameters:
activeDuration - the active duration in seconds
Throws:
SDPException - if the active duration is negative

setOffset

public void setOffset(long[] offsets)
               throws SDPException
Set the list of offsets. These are relative to the start time given in the Time field with which this RepeatTime is associated.

Parameters:
offsets - an array of repeat time offsets
Throws:
SDPException - if one or more offset is negative

setRepeatInterval

public void setRepeatInterval(long repeatInterval)
                       throws SDPException
Sets the repeat interval.

Parameters:
repeatInterval - the repeat interval in seconds
Throws:
SDPException - if repeatInterval is negative

setTypedTime

public void setTypedTime(boolean typedTime)
Sets whether the field will be output as a typed time or a number. Typed time is formatted as an number followed by a unit character: the unit indicates an appropriate multiplier for the number. The following unit types are allowed:


toString

public String toString()
Returns a string representation of the field. The representation has the form: r=<value>

Specified by:
toString in interface Field
Overrides:
toString in class Object
Returns:
the string representation of the field


Copyright © 2004-2008. All Rights Reserved.