Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * Conditions Of Use
  *
  * This software was developed by employees of the National Institute of
  * Standards and Technology (NIST), an agency of the Federal Government.
  * Pursuant to title 15 Untied States Code Section 105, works of NIST
  * employees are not subject to copyright protection in the United States
  * and are considered to be in the public domain.  As a result, a formal
  * license is not needed to use the software.
 *
 * This software is provided by NIST as a service and is expressly
 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
 * AND DATA ACCURACY.  NIST does not warrant or make any representations
 * regarding the use of the software or the results thereof, including but
 * not limited to the correctness, accuracy, reliability or usefulness of
 * the software.
 *
 * Permission to use this software is contingent upon your acceptance
 * of the terms of this agreement
 *
 * .
 *
 */
Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * /
 
 package gov.nist.javax.sdp.fields;
 import java.util.*;
 import javax.sdp.*;

Z= SDP field.

Author(s):
Olivier Deruelle <deruelle@antd.nist.gov>
M. Ranganathan
Version:
JSR141-PUBLIC-REVIEW (subject to change).
 
 
 public class ZoneField
     extends SDPField
     implements javax.sdp.TimeZoneAdjustment {
 
     protected SDPObjectList zoneAdjustments;

    
Constructor.
 
     public ZoneField() {
         super();
          = new SDPObjectList();
     }

    
Add an element to the zone adjustment list.

Parameters:
za zone adjustment to add.
 
     public void addZoneAdjustment(ZoneAdjustment za) {
         .add(za);
     }

    
Get the zone adjustment list.

Returns:
the list of zone adjustments.
 
 
     public SDPObjectList getZoneAdjustments() {
         return ;
     }

    
Encode this structure into a canonical form.
 
     public String encode() {
         StringBuilder retval = new StringBuilder();
         ListIterator li = .listIterator();
         int num = 0;
         while (li.hasNext()) {
             ZoneAdjustment za = (ZoneAdjustmentli.next();
             if (num > 0)
                 retval.append(.);
             retval.append(za.encode());
             num++;
         }
         retval.append(.);
         return retval.toString();
     }

    
Returns a Hashtable of adjustment times, where: key = Date. This is the equivalent of the decimal NTP time value. value = Int Adjustment. This is a relative time value in seconds.

Parameters:
create to set
Returns:
create - when true, an empty Hashtable is created, if it is null.
Throws:
javax.sdp.SdpParseException
    public Hashtable getZoneAdjustments(boolean create)
        throws SdpParseException {
        Hashtable result = new Hashtable();
        SDPObjectList zoneAdjustments = getZoneAdjustments();
        ZoneAdjustment zone;
        if (zoneAdjustments == null)
            if (create)
                return new Hashtable();
            else
                return null;
        else {
            while ((zone = (ZoneAdjustmentzoneAdjustments.next()) != null) {
                Long l = Long.valueOf(zone.getTime());
                Integer time = Integer.valueOf(l.toString());
                Date date = new Date(zone.getTime());
                result.put(datetime);
            }
            return result;
        }
    }

    
Sets the Hashtable of adjustment times, where: key = Date. This is the equivalent of the decimal NTP time value. value = Int Adjustment. This is a relative time value in seconds.

Parameters:
map Hashtable to set
Throws:
javax.sdp.SdpException if the parameter is null
    public void setZoneAdjustments(Hashtable mapthrows SdpException {
        if (map == null)
            throw new SdpException("The map is null");
        else {
            for (Enumeration e = map.keys(); e.hasMoreElements();) {
                Object o = e.nextElement();
                if (o instanceof Date) {
                    Date date = (Dateo;
                    ZoneAdjustment zone = new ZoneAdjustment();
                    zone.setTime(date.getTime());
                    addZoneAdjustment(zone);
                } else
                    throw new SdpException("The map is not well-formated ");
            }
        }
    }

    
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)

Parameters:
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.
    public void setTypedTime(boolean typedTime) {
        // Dummy -- feature not implemented.
    }

    
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)

Returns:
true, if the field will be output as a typed time; false, if as an integer value.
    public boolean getTypedTime() {
        return false;
    }
    public Object clone() {
        ZoneField retval = (ZoneFieldsuper.clone();
        if (this. != null)
            retval.zoneAdjustments = (SDPObjectListthis..clone();
        return retval;
    }
New to GrepCode? Check out our FAQ X