KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > tests > ItemList


1 /**
2  * $Id: ItemList.java 186 2007-03-16 13:42:35Z ssmc $
3  * Copyright 2003 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.tests;
30
31 import java.util.Iterator JavaDoc;
32
33 import org.apache.tools.ant.Project;
34
35 import com.idaremedia.antx.AntX;
36 import com.idaremedia.antx.helpers.InnerString;
37 import com.idaremedia.antx.starters.ListFriendly;
38 import com.idaremedia.antx.starters.StringItemList;
39
40 /**
41  * A formal (type-safe) list of strings for testing purposes.
42  *
43  * @since JWare/AntX 0.3
44  * @author ssmc, &copy;2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
45  * @version 0.5
46  * @.safety multiple (after fully configured)
47  * @.group test,helper
48  **/

49
50 public final class ItemList extends StringItemList implements ListFriendly
51 {
52     /**
53      * Initializes a new ItemList instance.
54      **/

55     public ItemList()
56     {
57         super(AntX.nopackage);
58     }
59
60
61     /**
62      * Appends given string (with property substitution) to
63      * this string list.
64      * @param string new string
65      **/

66     public void addConfiguredString(InnerString string)
67     {
68         require_(string!=null,"addStr- nonzro itm");
69         addItem(string,getProject());
70     }
71
72
73     /**
74      * Returns a comma-delimited list of this list's contents.
75      **/

76     public String JavaDoc stringFrom(Project theProject)
77     {
78         if (isReference()) {
79             return getOtherList().stringFrom(theProject);
80         }
81         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(100);
82         int N=0;
83         Iterator JavaDoc itr= readonlyStringIterator(theProject);
84         while (itr.hasNext()) {
85             if (N>0) {
86                 sb.append(",");
87             }
88             sb.append(itr.next());
89             N++;
90         }
91         itr=null;
92         return sb.substring(0);
93     }
94
95
96     public String JavaDoc toString()
97     {
98         return stringFrom(getProject());
99     }
100
101
102     private final ItemList getOtherList()
103     {
104         return (ItemList)getOtherItemList(ItemList.class);
105     }
106 }
107
108 /* end-of-ItemList.java */
109
Popular Tags