• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Conditions Of Use
3 *
4 * This software was developed by employees of the National Institute of
5 * Standards and Technology (NIST), an agency of the Federal Government.
6 * Pursuant to title 15 Untied States Code Section 105, works of NIST
7 * employees are not subject to copyright protection in the United States
8 * and are considered to be in the public domain.  As a result, a formal
9 * license is not needed to use the software.
10 *
11 * This software is provided by NIST as a service and is expressly
12 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
15 * AND DATA ACCURACY.  NIST does not warrant or make any representations
16 * regarding the use of the software or the results thereof, including but
17 * not limited to the correctness, accuracy, reliability or usefulness of
18 * the software.
19 *
20 * Permission to use this software is contingent upon your acceptance
21 * of the terms of this agreement
22 *
23 * .
24 *
25 */
26 /*******************************************************************************
27 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD).        *
28 *******************************************************************************/
29 package gov.nist.javax.sip.header;
30 
31 import java.util.*;
32 import java.text.ParseException;
33 import javax.sip.header.*;
34 
35 /**
36  * List of ALLOW headers. The sip message can have multiple Allow headers
37  *
38  * @author M. Ranganathan  <br/>
39  * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:57:26 $
40  * @since 1.1
41  *
42  */
43 public class AllowList extends SIPHeaderList<Allow> {
44 
45 
46     /**
47      * Comment for <code>serialVersionUID</code>
48      */
49     private static final long serialVersionUID = -4699795429662562358L;
50 
51 
clone()52     public Object clone() {
53         AllowList retval = new AllowList();
54         retval.clonehlist(this.hlist);
55         return retval;
56     }
57 
58 
59     /** default constructor
60      */
AllowList()61     public AllowList() {
62         super(Allow.class, AllowHeader.NAME);
63     }
64 
65     /**
66      * Gets an Iterator of all the methods of the AllowHeader. Returns an empty
67      *
68      * Iterator if no methods are defined in this Allow Header.
69      *
70      *
71      *
72      * @return Iterator of String objects each identifing the methods of
73      *
74      * AllowHeader.
75      *
76      *
77      */
getMethods()78     public ListIterator<String> getMethods() {
79 
80         LinkedList<String> ll = new LinkedList<String> ();
81 
82         for ( Iterator<Allow> it = this.hlist.iterator(); it.hasNext();) {
83             Allow a = (Allow)it.next();
84             ll.add(a.getMethod());
85         }
86 
87         return ll.listIterator();
88     }
89 
90     /**
91      * Sets the methods supported defined by this AllowHeader.
92      *
93      *
94      *
95      * @param methods - the Iterator of Strings defining the methods supported
96      *
97      * in this AllowHeader
98      *
99      * @throws ParseException which signals that an error has been reached
100      *
101      * unexpectedly while parsing the Strings defining the methods supported.
102      *
103      *
104      */
setMethods(List<String> methods)105     public void setMethods(List<String> methods) throws ParseException {
106         ListIterator<String> it = methods.listIterator();
107         while (it.hasNext()) {
108             Allow allow = new Allow();
109             allow.setMethod((String) it.next());
110             this.add(allow);
111         }
112     }
113 }
114