KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > mktemp > DirectoryListing


1 /**
2  * $Id: DirectoryListing.java 186 2007-03-16 13:42:35Z ssmc $
3  * Copyright 2004 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 (LGPL) as published
8  * by the Free Software Foundation; either version 2.1 of the License, or (at your option)
9  * any 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 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 GNU 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.mktemp;
30
31 import java.io.File JavaDoc;
32 import java.util.Iterator JavaDoc;
33
34 import org.apache.tools.ant.DirectoryScanner;
35 import org.apache.tools.ant.Project;
36
37 import com.idaremedia.antx.AntX;
38 import com.idaremedia.antx.AntXFixture;
39 import com.idaremedia.antx.ownhelpers.LocalTk;
40 import com.idaremedia.antx.starters.ListFriendly;
41 import com.idaremedia.antx.starters.StringItemList;
42
43 /**
44  * Directory listing data type. Created by the {@linkplain ListDirTask} but functional
45  * like any other {@linkplain ListFriendly} item list.
46  *
47  * @since JWare/AntX 0.5
48  * @author ssmc, &copy;2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
49  * @version 0.5
50  * @.safety single
51  * @.group impl,helper
52  **/

53
54 public final class DirectoryListing extends StringItemList implements ListFriendly
55 {
56     /**
57      * Initializes a new directory list item list.
58      * @param basenameOnly <i>true</i> if this is a list of base names.
59      **/

60     DirectoryListing(boolean basenameOnly)
61     {
62         super(AntX.mktemp+"DirectoryList:");
63         m_basenameOnly = basenameOnly;
64     }
65
66
67
68     /**
69      * Adds a set of included files or directory to this listing.
70      * @param list the included list (non-null)
71      * @param ds active directory scanner (non-null)
72      **/

73     void addIncludes(String JavaDoc[] list, DirectoryScanner ds)
74     {
75         LocalTk.resolveAllFilesOrDirs(list,ds,m_basenameOnly);
76         for (int i=0;i<list.length;i++) {
77             addItemFinal(list[i]);
78         }
79     }
80
81
82
83     /**
84      * Returns a path-separator delimited list of this list's contents.
85      **/

86     public String JavaDoc stringFrom(Project theProject)
87     {
88         final String JavaDoc theDelimiter = File.pathSeparator;
89         StringBuffer JavaDoc sb = AntXFixture.newStringBuffer();
90
91         int N=0;
92         Iterator JavaDoc itr= readonlyStringIterator(theProject);
93         while (itr.hasNext()) {
94             if (N>0) {
95                 sb.append(theDelimiter);
96             }
97             sb.append(itr.next());
98             N++;
99         }
100         itr=null;
101         return sb.substring(0);
102     }
103     
104
105     private boolean m_basenameOnly;
106 }
107
108 /* end-of-DirectoryListing.java */
Popular Tags