Skip to content

Package: DepFile

DepFile

nameinstructionbranchcomplexitylinemethod
DepFile()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addDepEntry(DepEntry)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addToArchive(ArchiveGenerator, Module)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
addToArchive2(ArchiveGenerator, DepEntry, List)
M: 39 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 10 C: 23
70%
M: 4 C: 4
50%
M: 4 C: 1
20%
M: 3 C: 7
70%
M: 0 C: 1
100%
getDepEntries()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getEntryByModule(Module)
M: 0 C: 24
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package kernelmodules;
2:
3: import java.io.FileNotFoundException;
4: import java.util.ArrayList;
5: import java.util.Iterator;
6: import java.util.List;
7:
8: import basic.ModelConstants;
9: import generator.ArchiveGenerator;
10: import pruefskript.parser.exceptions.CheckScriptException;
11: import pruefskript.parser.nodes.AddToOptFacade;
12:
13: /**
14: * @author Markus. class for dependencies.
15: */
16:
17: public class DepFile {
18:         /**
19:          * represents a List of dependency entries.
20:          */
21:         private final List<DepEntry> depEntries;
22:
23:         /**
24:          * @param depEntries
25:          */
26:         protected DepFile() {
27:                 super();
28:                 this.depEntries = new ArrayList<DepEntry>();
29:         }
30:
31:         /**
32:          * getter for dependency entries.
33:          *
34:          * @return List<DepEntry>
35:          */
36:         public List<DepEntry> getDepEntries() {
37:
38:                 return this.depEntries;
39:         }
40:
41:         /**
42:          * add a dependency entries.
43:          *
44:          * @param depEntry
45:          * the depEntry
46:          */
47:         public void addDepEntry(final DepEntry depEntry) {
48:
49:                 this.depEntries.add(depEntry);
50:         }
51:
52:         /**
53:          * Add a module to archive.
54:          *
55:          * @param gen
56:          * the {@link ArchiveGenerator} to use
57:          * @param module
58:          * the module to add.
59:          * @throws EntryNotFoundException
60:          * if module or dependent module is not found.
61:          * @throws CheckScriptException
62:          * if it fails.
63:          * @throws FileNotFoundException
64:          * i ffile not found.
65:          */
66:         public void addToArchive(final ArchiveGenerator gen, final Module module)
67:                         throws EntryNotFoundException, FileNotFoundException, CheckScriptException {
68:                 addToArchive2(gen, this.getEntryByModule(module), new ArrayList<Module>());
69:         }
70:
71:         /**
72:          * Add entry.getModule and dependencies to archive.
73:          *
74:          * @param gen
75:          * the {@link ArchiveGenerator} to use
76:          * @param entry
77:          * the modulentry.
78:          * @param liste
79:          * the list for rekursion.
80:          * @throws EntryNotFoundException
81:          * if a module is not found.
82:          * @throws CheckScriptException
83:          * if it fails
84:          * @throws FileNotFoundException
85:          * if file not found
86:          */
87:         private void addToArchive2(final ArchiveGenerator gen, final DepEntry entry,
88:                         final List<Module> liste)
89:                         throws EntryNotFoundException, FileNotFoundException, CheckScriptException {
90:•                if (!liste.contains(entry.getModule())) {
91:                         liste.add(entry.getModule());
92:                         final Iterator<Module> iDeps = entry.getDeps().iterator();
93:•                        while (iDeps.hasNext()) {
94:                                 final Module module = iDeps.next();
95:                                 this.addToArchive2(gen, this.getEntryByModule(module), liste);
96:                         }
97:                 }
98:
99:                 gen.addToOpt(new AddToOptFacade(entry.getModule().toString(), ""));
100:                 // TODO:Alle Elemente aus der Liste dem Archive hinzuf�gen.
101:
102:         }
103:
104:         /**
105:          * get the Module to the Entry.
106:          *
107:          * @param module
108:          * module.
109:          * @return the entry to the @param module
110:          * @throws EntryNotFoundException
111:          * if no Entry is found
112:          */
113:         public DepEntry getEntryByModule(final Module module) throws EntryNotFoundException {
114:
115:                 final Iterator<DepEntry> iEntries = this.getDepEntries().iterator();
116:•                while (iEntries.hasNext()) {
117:                         final DepEntry depEntry = iEntries.next();
118:•                        if (depEntry.getModule().equals(module)) {
119:                                 return depEntry;
120:                         }
121:                 }
122:                 throw new EntryNotFoundException(ModelConstants.DEPENTRYNOTFOUND);
123:
124:         }
125:
126:         @Override
127:         public int hashCode() {
128:                 return this.getClass().toString().hashCode() + this.depEntries.hashCode();
129:         }
130:
131:         @Override
132:         public boolean equals(final Object other) {
133:                 boolean result = false;
134:•                if (other == null) {
135:                         result = false;
136:•                } else if (other == this) {
137:                         result = true;
138:•                } else if (!(other instanceof DepFile)) { // NOPMD ! is okay here!
139:                         result = false;
140:                 } else {
141:                         final DepFile oDF = (DepFile) other;
142:•                        result = oDF.hashCode() == other.hashCode();
143:                 }
144:                 return result;
145:         }
146: }