01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.core.resolve;
19:
20: import java.util.ArrayList;
21: import java.util.HashMap;
22: import java.util.List;
23: import java.util.Map;
24:
25: /**
26: * This class is used to store data related to one node of the dependency graph visit. It stores
27: * both an {@link IvyNode} and related {@link VisitNode} objects. Indeed, during the visit of the
28: * graph, the algorithm can visit the same node from several parents, thus requiring several
29: * VisitNode.
30: */
31: public class VisitData {
32: /**
33: * A node in the graph of module dependencies resolution
34: */
35: private IvyNode node;
36:
37: /**
38: * The associated visit nodes, per rootModuleConf Note that the value is a List, because a node
39: * can be visited from several parents during the resolution process
40: */
41: private Map visitNodes = new HashMap(); // Map (String rootModuleConf -> List(VisitNode))
42:
43: public VisitData(IvyNode node) {
44: this .node = node;
45: }
46:
47: public void addVisitNode(VisitNode node) {
48: String rootModuleConf = node.getRootModuleConf();
49: getVisitNodes(rootModuleConf).add(node);
50: }
51:
52: public List getVisitNodes(String rootModuleConf) {
53: List visits = (List) visitNodes.get(rootModuleConf);
54: if (visits == null) {
55: visits = new ArrayList();
56: visitNodes.put(rootModuleConf, visits);
57: }
58: return visits;
59: }
60:
61: public IvyNode getNode() {
62: return node;
63: }
64:
65: public void setNode(IvyNode node) {
66: this .node = node;
67: }
68:
69: public void addVisitNodes(String rootModuleConf, List visitNodes) {
70: getVisitNodes(rootModuleConf).addAll(visitNodes);
71: }
72: }
|