KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > savant > ant > types > ArtifactGroupType


1 /*
2  * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.savant.ant.types;
8
9 import java.util.Date JavaDoc;
10 import java.util.List JavaDoc;
11
12 import org.apache.tools.ant.types.DataType;
13 import org.apache.tools.ant.types.Reference;
14
15 import com.inversoft.savant.Artifact;
16 import com.inversoft.savant.ArtifactGroup;
17
18
19 /**
20  * <p>
21  * This class is an ant data type to stores a list of
22  * artifacts that compose a logic group.
23  * </p>
24  *
25  * @author Brian Pontarelli
26  */

27 public class ArtifactGroupType extends DataType {
28
29     private ArtifactGroup proxy = new ArtifactGroup();
30
31
32     /**
33      * Constructs a new <code>ArtifactGroupType</code>.
34      */

35     public ArtifactGroupType() {
36     }
37
38
39     /**
40      * Returns the ArtifactGroup that this class is a proxy to.
41      */

42     public ArtifactGroup getProxy() {
43         return proxy;
44     }
45
46     /**
47      * Copy everything from the reference into this object rather than delegate.
48      */

49     public void setRefid(Reference reference) {
50         super.setRefid(reference);
51
52         ArtifactGroupType group = (ArtifactGroupType) reference.getReferencedObject(getProject());
53         List JavaDoc artifacts = group.getArtifacts();
54         for (int i = 0; i < artifacts.size(); i++) {
55             proxy.addArtifact((Artifact) artifacts.get(i));
56         }
57
58         proxy.setClasspathid(group.getClasspathid());
59         proxy.setFilesetid(group.getFilesetid());
60         proxy.setExpireminutes(group.getExpireminutes());
61         proxy.setExpiretime(group.getExpiretime());
62     }
63
64     /**
65      * Returns the live list of artifacts in this group.
66      */

67     public List JavaDoc getArtifacts() {
68         return proxy.getArtifacts();
69     }
70
71     /**
72      * Adds a new artifact to this group.
73      *
74      * @param artifact The artifact
75      */

76     public void addConfiguredArtifact(ArtifactType artifact) {
77         if (isReference()) {
78             throw noChildrenAllowed();
79         }
80
81         if (artifact.getExpireminutes() == 0) {
82             artifact.setExpireminutes(proxy.getExpireminutes());
83         }
84
85         if (artifact.getExpiretime() == null) {
86             artifact.setExpiretime(proxy.getExpiretime());
87         }
88
89         proxy.addArtifact(artifact.getProxy());
90     }
91
92     /**
93      * Adds a new nested artifact group or a reference. This group is completely
94      * configured and therefore we just dump the artifacts from that group into
95      * this group.
96      *
97      * @param group The group to add
98      */

99     public void addConfiguredArtifactgroup(ArtifactGroupType group) {
100         if (isReference()) {
101             throw noChildrenAllowed();
102         }
103
104         List JavaDoc artifacts = group.getArtifacts();
105         for (int i = 0; i < artifacts.size(); i++) {
106             proxy.addArtifact((Artifact) artifacts.get(i));
107         }
108     }
109
110     public String JavaDoc getClasspathid() {
111         return proxy.getClasspathid();
112     }
113
114     public void setClasspathid(String JavaDoc classPathId) {
115         if (isReference()) {
116             throw tooManyAttributes();
117         }
118
119         proxy.setClasspathid(classPathId);
120     }
121
122     public String JavaDoc getFilesetid() {
123         return proxy.getFilesetid();
124     }
125
126     public void setFilesetid(String JavaDoc fileSetId) {
127         if (isReference()) {
128             throw tooManyAttributes();
129         }
130
131         proxy.setFilesetid(fileSetId);
132     }
133
134     public int getExpireminutes() {
135         return proxy.getExpireminutes();
136     }
137
138     public void setExpireminutes(int expireMinutes) {
139         proxy.setExpireminutes(expireMinutes);
140     }
141
142     public Date JavaDoc getExpiretime() {
143         return proxy.getExpiretime();
144     }
145
146     public void setExpiretime(Date JavaDoc expireTime) {
147         proxy.setExpiretime(expireTime);
148     }
149 }
Popular Tags