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 ******************************************************************************/
29package gov.nist.javax.sip.header;
30import java.util.ListIterator;
31import java.util.LinkedList;
32import java.util.Iterator;
33import java.lang.reflect.*;
34import gov.nist.core.*;
35
36/**
37 * Root class for all the collection objects in this list:
38 * a wrapper class on the GenericObjectList class for lists of objects
39 * that can appear in SIPObjects.
40 * IMPORTANT NOTE: SIPObjectList cannot derive from SIPObject.
41 *
42 * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:57:38 $
43 *
44 * @author M. Ranganathan   <br/>
45 *
46 *
47 */
48public class SIPObjectList extends GenericObjectList {
49
50
51    private static final long serialVersionUID = -3015154738977508905L;
52
53    /**
54     * Construct a SIPObject List given a list name.
55     * @param lname String to set
56     */
57    public SIPObjectList(String lname) {
58        super(lname);
59    }
60
61
62
63
64    /**
65     * Construct an empty SIPObjectList.
66     */
67    public SIPObjectList() {
68        super();
69    }
70
71
72
73
74    /**
75     * Do a merge of the GenericObjects contained in this list with the
76     * GenericObjects in the mergeList. Note that this does an inplace
77     * modification of the given list. This does an object by object
78     * merge of the given objects.
79     *
80     *@param mergeList is the list of Generic objects that we want to do
81     * an object by object merge with. Note that no new objects are
82     * added to this list.
83     *
84     */
85
86    public void mergeObjects(GenericObjectList mergeList) {
87        Iterator<GenericObject> it1 = this.listIterator();
88        Iterator<GenericObject> it2 = mergeList.listIterator();
89        while (it1.hasNext()) {
90            GenericObject outerObj = (GenericObject) it1.next();
91            while (it2.hasNext()) {
92                Object innerObj = it2.next();
93                outerObj.merge(innerObj);
94            }
95        }
96    }
97
98    /**
99     * Append a given list to the end of this list.
100     * @param otherList SIPObjectList to set
101     */
102    public void concatenate(SIPObjectList otherList) {
103        super.concatenate(otherList);
104    }
105
106    /**
107     * Append or prepend a given list to this list.
108     * @param otherList SIPObjectList to set
109     * @param topFlag boolean to set
110     */
111    public void concatenate(SIPObjectList otherList, boolean topFlag) {
112        super.concatenate(otherList, topFlag);
113    }
114
115    /**
116     * Get the first object of this list.
117     * @return GenericObject
118     */
119    public GenericObject first() {
120        return (SIPObject) super.first();
121    }
122
123
124    /**
125     * Get the next object of this list (assumes that first() has been
126     * called prior to calling this method.)
127     * @return GenericObject
128     */
129    public GenericObject next() {
130        return (SIPObject) super.next();
131    }
132
133
134
135
136
137    /**
138     * Convert to a string given an indentation(for pretty printing).
139     * This is useful for debugging the system in lieu of a debugger.
140     *
141     * @param indent int to set
142     * @return an indentation
143     */
144    public String debugDump(int indent) {
145        return super.debugDump(indent);
146    }
147
148
149
150
151
152}
153