net.sourceforge.jsdp
Class TimeZone

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

public class TimeZone
extends Object
implements Field

A TimeZone represents a z=<field value> field contained in a SDP message. The timezone field allows the sender to specify a list of adjustment times and offsets from the base time.

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

Field Summary
protected  Hashtable adjustments
          The map of timezone adjustments
protected  boolean isTyped
          Indicates if the field will be output as a typed time or a number
 
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 TimeZone()
          Creates a new TimeZone.
  TimeZone(Date time, long offset)
          Creates a new TimeZone.
  TimeZone(ZoneAdjustment adjustment)
          Creates a new TimeZone.
 
Method Summary
 void addZoneAdjustment(Date time, long offset)
          Add a zone adjustment to the field.
 void addZoneAdjustment(ZoneAdjustment adjustment)
          Add a zone adjustment to the field.
 Object clone()
          Returns a clone of this field.
 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 TimeZone parse(String field)
          Parse an input string and constructs the equivalent timezone field.
 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

isTyped

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


adjustments

protected Hashtable adjustments
The map of timezone adjustments

Constructor Detail

TimeZone

protected TimeZone()
Creates a new TimeZone.


TimeZone

public TimeZone(Date time,
                long offset)
         throws SDPException
Creates a new TimeZone.

Parameters:
time - the adjustment time
offset - the offset
Throws:
SDPException - if the NTP representation of the adjustment time is negative

TimeZone

public TimeZone(ZoneAdjustment adjustment)
Creates a new TimeZone.

Parameters:
adjustment - the time zone adjustment
Method Detail

parse

public static TimeZone parse(String field)
                      throws SDPParseException
Parse an input string and constructs the equivalent timezone field.

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

addZoneAdjustment

public void addZoneAdjustment(Date time,
                              long offset)
                       throws SDPException
Add a zone adjustment to the field.

Parameters:
time - the adjustment time
offset - the offset
Throws:
SDPException - if the NTP representation of the adjustment time is negative

addZoneAdjustment

public void addZoneAdjustment(ZoneAdjustment adjustment)
Add a zone adjustment to the field.

Parameters:
adjustment - the time zone adjustment

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

getType

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

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

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:

  • d - days (86400 seconds)
  • h - hours (3600 seconds)
  • m - minutes (60 seconds)
  • s - seconds (1 second)

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

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:

  • d - days (86400 seconds)
  • h - hours (3600 seconds)
  • m - minutes (60 seconds)
  • s - seconds (1 second)


toString

public String toString()
Returns a string representation of the field. The representation has the form: z=<time> <offset>+

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


Copyright © 2004-2008. All Rights Reserved.