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 */
9package com.vladium.emma.ant;
10
11import java.io.File;
12
13import org.apache.tools.ant.types.FileSet;
14import 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 */
23public
24final 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 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 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// ----------------------------------------------------------------------------