1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.tools.ant.taskdefs.optional.sourceforge;
29
30 import java.io.File;
31 import java.io.Serializable;
32
33 import java.util.Date;
34
35 import org.apache.tools.ant.BuildException;
36
37 import sfutils.frs.FileSpecification;
38
39 /***
40 * A simple adapter class that allows <a href="http://ant.apache.org/">Ant</a>
41 * to create and set the attributes of a {@link FileSpecification}.
42 *
43 * @author <a href="mailto:ljnelson94@alumni.amherst.edu">Laird Nelson</a>
44 * @version $Revision: 1.2 $ $Date: 2003/07/10 19:48:13 $
45 * @since July 2, 2003
46 */
47 public final class FileSpec implements Serializable {
48
49 /***
50 * The {@link FileSpecification} being adapted. This field is never
51 * <code>null</code>.
52 */
53 private final FileSpecification spec;
54
55 /***
56 * Creates a new {@link FileSpec}.
57 */
58 public FileSpec() {
59 super();
60 this.spec = new FileSpecification();
61 }
62
63 /***
64 * Sets the {@link File} for the underlying {@link FileSpecification}.
65 *
66 * @param file
67 * the {@link File} to install; must not be <code>null</code>
68 * @exception BuildException
69 * if an error occurs
70 */
71 public final void setFile(final File file)
72 throws BuildException {
73 try {
74 this.spec.setFile(file);
75 } catch (final Exception anything) {
76 throw new BuildException(anything);
77 }
78 }
79
80 /***
81 * Sets the {@linkplain FileSpecification#setReleaseDate(Date) release date}
82 * for the underlying {@link FileSpecification}.
83 *
84 * @param date
85 * the release {@link Date}; must not be <code>null</code>
86 * @exception BuildException
87 * if an error occurs
88 */
89 public final void setReleaseDate(final Date date)
90 throws BuildException {
91 try {
92 this.spec.setReleaseDate(date);
93 } catch (final Exception anything) {
94 throw new BuildException(anything);
95 }
96 }
97
98 /***
99 * Sets the {@linkplain FileSpecification#setProcessorType(int) processor
100 * type} on the underlying {@link FileSpecification}.
101 *
102 * @param type
103 * the processor type; must not be <code>null</code>
104 * @exception BuildException
105 * if an error occurs
106 */
107 public final void setProcessorType(final String type)
108 throws BuildException {
109 try {
110 this.spec.setProcessorTypeString(type);
111 } catch (final Exception anything) {
112 throw new BuildException(anything);
113 }
114 }
115
116 /***
117 * Sets the {@linkplain FileSpecification#setFileType(int) file type} on the
118 * underlying {@link FileSpecification}.
119 *
120 * @param type
121 * the file type; must not be <code>null</code>
122 * @exception BuildException
123 * if an error occurs
124 */
125 public final void setFileType(final String type)
126 throws BuildException {
127 try {
128 this.spec.setFileTypeString(type);
129 } catch (final Exception anything) {
130 throw new BuildException(anything);
131 }
132 }
133
134 /***
135 * Returns the underlying {@link FileSpecification}. This method never
136 * returns <code>null</code>.
137 *
138 * @return the underlying {@link FileSpecification}; never
139 * <code>null</code>
140 */
141 public final FileSpecification getFileSpecification() {
142 return this.spec;
143 }
144
145 }