source: release-kits/wirk3/ant-scripts/tasks/antelope/src/ise/antelope/tasks/UIDTask.java@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 1.0 KB
Line 
1package ise.antelope.tasks;
2
3import ise.antelope.tasks.typedefs.*;
4
5import java.rmi.server.ObjID;
6import java.rmi.server.UID;
7import org.apache.tools.ant.BuildException;
8
9import org.apache.tools.ant.Task;
10
11/**
12 * A task to generate a unique ID.
13 *
14 * @author Dale Anson, [email protected]
15 * @since Ant 1.6
16 * @version $Revision: 1.1 $
17 */
18public class UIDTask extends Task {
19
20
21 private String name = null;
22 private boolean asInt = false;
23
24 /**
25 * @param n a name for this UID
26 */
27 public void setName(String n) {
28 name = n;
29 }
30
31 public void setInt(boolean b) {
32 asInt = b;
33 }
34
35 /** Generate a unique id and store it in the project with the given name. */
36 public void execute() {
37 if (name == null)
38 throw new BuildException("name attribute cannot be null");
39 if (asInt)
40 getProject().setProperty(name, String.valueOf(new ObjID().hashCode()));
41 else
42 getProject().setProperty(name, new UID().toString());
43 }
44
45}
46
Note: See TracBrowser for help on using the repository browser.