01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.proof.init;
12:
13: import java.util.HashMap;
14: import java.util.LinkedList;
15: import java.util.List;
16:
17: import de.uka.ilkd.key.proof.RuleSource;
18:
19: /**
20: * Encapsulates 2 lists (one for LDT-include, one for "normal" includes)
21: * containing the filenames parsed in the include-section of a <code>KeYFile</code>.
22: * <code>name2Source</code> maps the entries of both lists to the corresponding
23: * RuleSources.
24: */
25: public class Includes {
26:
27: /** a list containing the "normal" includes, represented as Strings */
28: private final List includes;
29: /** a list containing the LDT includes, represented as Strings */
30: private final List ldtIncludes;
31: /** contains mappings from filenames to RuleSources */
32: private final HashMap name2Source;
33:
34: public Includes() {
35: includes = new LinkedList();
36: ldtIncludes = new LinkedList();
37: name2Source = new HashMap();
38: }
39:
40: private void put(String name, RuleSource source, List list) {
41: if (!list.contains(name)) {
42: list.add(name);
43: name2Source.put(name, source);
44: }
45: }
46:
47: /** adds a "normal" include.*/
48: public void put(String name, RuleSource source) {
49: put(name, source, includes);
50: }
51:
52: /** adds a LDT include.*/
53: public void putLDT(String name, RuleSource source) {
54: put(name, source, ldtIncludes);
55: }
56:
57: /** returns the corresponding RuleSource to the filename
58: * <code>name</name>
59: */
60: public RuleSource get(String name) {
61: return (RuleSource) name2Source.get(name);
62: }
63:
64: /** removes the filename <code>name</code> and its mapping. */
65: public void remove(String name) {
66: includes.remove(name);
67: ldtIncludes.remove(name);
68: name2Source.remove(name);
69: }
70:
71: /** return the list of non-LDT includes*/
72: public List getIncludes() {
73: return includes;
74: }
75:
76: /** return the list of LDT includes*/
77: public List getLDTIncludes() {
78: return ldtIncludes;
79: }
80:
81: public boolean isEmpty() {
82: return name2Source.isEmpty();
83: }
84:
85: public void putAll(Includes in) {
86: includes.addAll(in.includes);
87: ldtIncludes.addAll(in.ldtIncludes);
88: name2Source.putAll(in.name2Source);
89: }
90: }
|