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 javax.sdp.*;
Repeat SDP Field (part of the time field).

Author(s):
Olivier Deruelle <deruelle@antd.nist.gov>
M. Ranganathan
Version:
JSR141-PUBLIC-REVIEW (subject to change).
 
 public class RepeatField extends SDPField implements javax.sdp.RepeatTime {
 
     private static final long serialVersionUID = -6415338212212641819L;
     protected TypedTime repeatInterval;
     protected TypedTime activeDuration;
     protected SDPObjectList offsets;
 
     public RepeatField() {
         super();
          = new SDPObjectList();
     }
 
     public void setRepeatInterval(TypedTime interval) {
          = interval;
     }
 
     public void setActiveDuration(TypedTime duration) {
          = duration;
     }
 
     public void addOffset(TypedTime offset) {
         .add(offset);
     }
 
     public LinkedList getOffsets() {
         return ;
     }

    
Returns the "repeat interval" in seconds.

Returns:
the "repeat interval" in seconds.
Throws:
javax.sdp.SdpParseException
 
     public int getRepeatInterval() throws SdpParseException {
         if ( == null)
             return -1;
         else {
             return .getTime();
         }
     }

    
Set the "repeat interval" in seconds.

Parameters:
repeatInterval the "repeat interval" in seconds.
Throws:
javax.sdp.SdpException if repeatInterval is <0
 
     public void setRepeatInterval(int repeatIntervalthrows SdpException {
         if (repeatInterval < 0)
             throw new SdpException("The repeat interval is <0");
         else {
             if (this. == null)
                 this. = new TypedTime();
             this..setTime(repeatInterval);
         }
     }

    
Returns the "active duration" in seconds.

Returns:
the "active duration" in seconds.
Throws:
javax.sdp.SdpParseException
    public int getActiveDuration() throws SdpParseException {
        if ( == null)
            return -1;
        else {
            return .getTime();
        }
    }

    
Sets the "active duration" in seconds.

Parameters:
activeDuration the "active duration" in seconds.
Throws:
javax.sdp.SdpException if the active duration is <0
    public void setActiveDuration(int activeDurationthrows SdpException {
        if (activeDuration < 0)
            throw new SdpException("The active Duration is <0");
        else {
            if (this. == null)
                this. = new TypedTime();
            this..setTime(activeDuration);
        }
    }

    
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.

Returns:
the list of offsets
Throws:
javax.sdp.SdpParseException
    public int[] getOffsetArray() throws SdpParseException {
        LinkedList linkedList = getOffsets();
        int[] result = new int[linkedList.size()];
        for (int i = 0; i < linkedList.size(); i++) {
            TypedTime typedTime = (TypedTimelinkedList.get(i);
            result[i] = typedTime.getTime();
        }
        return result;
    }

    
Set the list of offsets. These are relative to the start-time given in the Time object (t= field) with which this RepeatTime is associated.

Parameters:
offsets array of repeat time offsets
Throws:
javax.sdp.SdpException
    public void setOffsetArray(int[] offsetsthrows SdpException {
        for (int i = 0; i < offsets.lengthi++) {
            TypedTime typedTime = new TypedTime();
            typedTime.setTime(offsets[i]);
            addOffset(typedTime);
        }
    }

    
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.
Throws:
javax.sdp.SdpParseException
    public boolean getTypedTime() throws SdpParseException {
        return true;
    }

    
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) {
    }
    public String encode() {
        StringBuilder retval = new StringBuilder();
    retval.append()
            .append(.)
          .append(.encode());
        ListIterator li = .listIterator();
        while (li.hasNext()) {
            TypedTime off = (TypedTimeli.next();
            retval.append (.).append (off.encode());
        }
        retval.append (.);
        return retval.toString ();
    }
    public Object clone() {
        RepeatField retval = (RepeatFieldsuper.clone();
        if (this. != null)
            retval.repeatInterval = (TypedTimethis..clone();
        if (this. != null)
            retval.activeDuration = (TypedTimethis..clone();
        if (this. != null)
            retval.offsets = (SDPObjectListthis..clone();
        return retval;
    }
New to GrepCode? Check out our FAQ X