KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > StringListImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /**
30  * StringListImpl is a wrapper class for lists of strings.
31  *
32  *
33  * Inherits from:
34  *
35  * - ListBaseImpl: The base class for all lists.
36  *
37  * - StringList: OMG IDL for lists of strings.
38  *
39  *
40  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
41  *
42  * @version 0.1
43  */

44
45 public class StringListImpl
46        extends ListBaseImpl
47        implements org.objectweb.openccm.ast.api.StringList
48 {
49     // ==================================================================
50
//
51
// Internal state.
52
//
53
// ==================================================================
54

55     // ==================================================================
56
//
57
// Constructor.
58
//
59
// ==================================================================
60

61     /**
62      * The default constructor.
63      */

64     public
65     StringListImpl()
66     {
67         // Call the ListBaseImpl constructor.
68
super();
69     }
70
71     // ==================================================================
72
//
73
// Internal methods.
74
//
75
// ==================================================================
76

77     /*
78      * Check if an same element of the list is present several times
79      *
80      * @return : -1 if all elements are distinct
81      * the index of element present several times.
82      */

83     public int
84     checkSameItem()
85     {
86         for(int i=0; i<getSize(); i++)
87         {
88             String JavaDoc s1 = (String JavaDoc)get(i);
89
90             for(int j=i+1; j<getSize(); j++)
91             {
92                 String JavaDoc s2 = (String JavaDoc)get(j);
93
94                 if( s1.compareTo(s2) == 0 )
95                     return i;
96             }
97         }
98         return -1;
99     }
100
101     // ==================================================================
102
//
103
// Public methods.
104
//
105
// ==================================================================
106

107     // ==================================================================
108
//
109
// Methods for OMG IDL org.objectweb.openccm.ast.api.List
110
//
111
// ==================================================================
112

113     // ==================================================================
114
//
115
// Methods for OMG IDL org.objectweb.openccm.ast.api.StringList
116
//
117
// ==================================================================
118

119     /**
120      * Add a string to this list.
121      *
122      * @param s The string to add to the list.
123      */

124     public void
125     add(String JavaDoc s)
126     {
127         super.addObject(s);
128     }
129
130     /**
131      * Obtain all the strings added to this list.
132      *
133      * @return All the strings added to this list.
134      */

135     public String JavaDoc[]
136     getStrings()
137     {
138        return (String JavaDoc[])super.toArray(new String JavaDoc[0]);
139     }
140 }
141
Popular Tags