KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > vladium > emma > ant > XFileSet


1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
2  *
3  * This program and the accompanying materials are made available under
4  * the terms of the Common Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
6  *
7  * $Id: XFileSet.java,v 1.1.1.1 2004/05/09 16:57:28 vlad_r Exp $
8  */

9 package com.vladium.emma.ant;
10
11 import java.io.File JavaDoc;
12
13 import org.apache.tools.ant.types.FileSet;
14 import org.apache.tools.ant.types.PatternSet;
15
16 // ----------------------------------------------------------------------------
17
/**
18  * An extension of ANT's stock FileSet that adds the convenience of specifying
19  * a single 'file' attribute
20  *
21  * @author Vlad Roubtsov, (C) 2004
22  */

23 public
24 final class XFileSet extends FileSet
25 {
26     // public: ................................................................
27

28     
29     public XFileSet ()
30     {
31         super ();
32     }
33     
34     public XFileSet (final FileSet fileset)
35     {
36         super (fileset);
37     }
38     
39     
40     // 'file' attribute:
41
public void setFile (final File JavaDoc file)
42     {
43         if (IANTVersion.ANT_1_5_PLUS)
44         {
45             super.setFile (file);
46         }
47         else
48         {
49             if (isReference ()) throw tooManyAttributes ();
50         
51             final File JavaDoc parent = file.getParentFile ();
52             if (parent != null) setDir (parent);
53     
54             final PatternSet.NameEntry include = createInclude ();
55             include.setName (file.getName ());
56         }
57     }
58     
59     // protected: .............................................................
60

61     // package: ...............................................................
62

63     // private: ...............................................................
64

65 } // end of class
66
// ----------------------------------------------------------------------------
Popular Tags