KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > utility > CollectionUtil


1 package net.firstpartners.nounit.utility;
2
3 /**
4  * Title: NoUnit - Identify Classes that are not being unit Tested
5  *
6  * Copyright (C) 2001 Paul Browne , FirstPartners.net
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @author Paul Browne
24  * @version 0.7
25  */

26
27 import java.util.Collection JavaDoc;
28 import java.util.HashSet JavaDoc;
29
30 /**
31  * Performs common , but tricky tasks on Collections
32  * e.g. Stripping of spaces from Files
33  */

34 public class CollectionUtil {
35
36     /**
37      * Convert an Array to a HashSet
38      * @param arrayToConvert
39      * @return convertedHashSet with Array Information in it
40      */

41     public static Collection JavaDoc convertArrayToCollection(Object JavaDoc[] arrayToConvert) {
42         
43         //Local Variables
44
HashSet JavaDoc convertedHashSet = new HashSet JavaDoc();
45         
46         //Loop and Convert
47
for (int a=0; a< arrayToConvert.length ; a++) {
48             convertedHashSet.add(arrayToConvert[a]);
49         }
50         
51         return convertedHashSet;
52         
53     }
54
55 }
Popular Tags