KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > savant > ArtifactGroup


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;
8
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.Date JavaDoc;
12 import java.util.List JavaDoc;
13
14
15 /**
16  * <p>
17  * This class is an ant data type to stores a list of
18  * artifacts that compose a logic group.
19  * </p>
20  *
21  * @author Brian Pontarelli
22  */

23 public class ArtifactGroup {
24
25     /**
26      * The name of the default fileset all artifacts are added to ({@value})
27      * unless they belong to a group that specifies another fileset.
28      */

29     public static final String JavaDoc DEFAULT_FS = "fileset.deps";
30
31     /**
32      * The name of the default path all artifacts are added to ({@value}) unless
33      * they belong to a group that specifies another path.
34      */

35     public static final String JavaDoc DEFAULT_PATH = "fileset.path";
36
37     private List JavaDoc artifacts = new ArrayList JavaDoc();
38     private List JavaDoc groups = new ArrayList JavaDoc();
39     private int expireMinutes;
40     private Date JavaDoc expireTime;
41     private String JavaDoc classPathId;
42     private String JavaDoc fileSetId;
43
44
45     /**
46      * Constructs a new <code>ArtifactGroupType</code>.
47      */

48     public ArtifactGroup() {
49     }
50
51
52     /**
53      * Returns the live list of artifacts in this group.
54      */

55     public List JavaDoc getArtifacts() {
56         return artifacts;
57     }
58
59     /**
60      * Adds a new artifact to this group.
61      *
62      * @param artifact The artifact
63      */

64     public void addArtifact(Artifact artifact) {
65         if (artifact.getExpireminutes() == 0) {
66             artifact.setExpireminutes(expireMinutes);
67         }
68
69         if (artifact.getExpiretime() == null) {
70             artifact.setExpiretime(expireTime);
71         }
72
73         artifacts.add(artifact);
74     }
75
76     /**
77      * Returns all the ArtifactGroups inside this artifact group.
78      *
79      * @return The list of groups and never null
80      */

81     public List JavaDoc getArtifactGroups() {
82         return groups;
83     }
84
85     /**
86      * Adds a new nested artifact group or a reference.
87      *
88      * @param group The group to add
89      */

90     public void addArtifactGroup(ArtifactGroup group) {
91         if (group.getClasspathid() == null) {
92             group.setClasspathid(classPathId);
93         }
94
95         if (group.getFilesetid() == null) {
96             group.setFilesetid(fileSetId);
97         }
98
99         groups.add(group);
100     }
101
102     public String JavaDoc getClasspathid() {
103         return classPathId;
104     }
105
106     public void setClasspathid(String JavaDoc classPathId) {
107         this.classPathId = classPathId;
108     }
109
110     public String JavaDoc getFilesetid() {
111         return fileSetId;
112     }
113
114     public void setFilesetid(String JavaDoc fileSetId) {
115         this.fileSetId = fileSetId;
116     }
117
118     public int getExpireminutes() {
119         return expireMinutes;
120     }
121
122     public void setExpireminutes(int expireMinutes) {
123         this.expireMinutes = expireMinutes;
124     }
125
126     public Date JavaDoc getExpiretime() {
127         return expireTime;
128     }
129
130     public void setExpiretime(Date JavaDoc expireTime) {
131         this.expireTime = expireTime;
132     }
133
134     /**
135      * Validates the group.
136      *
137      * @throws SavantException If the group contains no artifacts
138      */

139     public void validate() throws SavantException {
140         if (artifacts.size() == 0) {
141             throw new SavantException("All artifact groups must have artifacts");
142         }
143     }
144 }
Popular Tags