Debian Codegraph @

src/main/java/net/sf/antcontrib/walls/Walls.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.antcontrib.walls;
17
18 import java.util.*;
19
20
21 /*
22 * Created on Aug 24, 2003
23 *
24 * To change the template for this generated file go to
25 * Window>Preferences>Java>Code Generation>Code and Comments
26 */
27 /**
28 * FILL IN JAVADOC HERE
29 *
30 * @author Dean Hiller([email protected])
31 */
32 public class Walls {
33
34 private List packages = new LinkedList();
35 private Map nameToPackage = new HashMap();
36
37 public Package getPackage(String name) {
38 return (Package)nameToPackage.get(name);
39 }
40
41 public void addConfiguredPackage(Package p) {
42
43 String pack = p.getPackage();
44 if(!pack.endsWith(".*") && !pack.endsWith(".**"))
45 p.setFaultReason("The package='"+pack+"' must end with "
46 +".* or .** such as biz.xsoftware.* or "
47 +"biz.xsoftware.**");
48
49 String[] depends = p.getDepends();
50 if(depends == null) {
51 nameToPackage.put(p.getName(), p);
52 packages.add(p);
53 return;
54 }
55
56 //make sure all depends are in Map first
57 //circular references then are not a problem because they must
58 //put the stuff in order
59 for(int i = 0; i < depends.length; i++) {
60 Package dependsPackage = (Package)nameToPackage.get(depends[i]);
61
62 if(dependsPackage == null) {
63 p.setFaultReason("package name="+p.getName()+" did not have "
64 +depends[i]+" listed before it and cannot compile without it");
65 }
66 }
67
68 nameToPackage.put(p.getName(), p);
69 packages.add(p);
70 }
71
72 public Iterator getPackagesToCompile() {
73 //must return the list, as we need to process in order, so unfortunately
74 //we cannot pass back an iterator from the hashtable because that would
75 //be unordered and would break.
76 return packages.iterator();
77 }
78 }