Skip to content

Package: AliasReader

AliasReader

nameinstructionbranchcomplexitylinemethod
AliasReader()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
createAlias(String, String)
M: 29 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
read(String)
M: 42 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
splitFileInLines(String)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
splitLineInParts(String)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: *
3: */
4: package kernelmodules;
5:
6: import reader.ReaderException;
7: import scanner.ScannerConstants;
8:
9: /**
10: * @author Hendrik
11: *
12: */
13: public class AliasReader {
14:
15:         /**
16:          *
17:          */
18:         public AliasReader() {
19:                 super();
20:         }
21:
22:         /**
23:          * reads the file.
24:          *
25:          * @param pathToRead
26:          * path to file.
27:          * @throws ReaderException
28:          * if it fails
29:          */
30:         public void read(final String pathToRead) throws ReaderException {
31:                 final String file = reader.FileReader.read(pathToRead);
32:
33:                 final String[] lines = splitFileInLines(file);
34:•                for (int i = 0; i < lines.length; i++) {
35:                         final String[] line = splitLineInParts(lines[i]);
36:                         int j = 0;
37:•                        while (j < line.length) {
38:                                 createAlias(line[j + 1], line[j + 2]);
39:                                 j++;
40:
41:                         }
42:                 }
43:
44:         }
45:
46:         /**
47:          * create Alias.
48:          *
49:          * @param alias
50:          * Alias
51:          * @param name
52:          * Module
53:          * @throws ModulNotFoundException
54:          * if the Module not exists.
55:          */
56:         private void createAlias(final String alias, final String name) throws ModulNotFoundException {
57:•                if (ModMgr.getTheInstance().getModules().containsKey(name)) {
58:                         // TODO Es wird hier ein Alias-Objekt erstellt mit zwei Parametern. Und daaaaaaan?
59:                         // Es wird die Verbindung zwischen dem Module und dem Alias erstellt. Siehe
60:                         // Klassendiagramm.
61:                         new Alias(ModMgr.getTheInstance().getModules().get(name), alias);
62:                 } else {
63:                         throw new ModulNotFoundException(name + "not found");
64:                 }
65:
66:         }
67:
68:         /**
69:          * split the file in lines.
70:          *
71:          * @param file
72:          * Datei.
73:          * @return List of Lines
74:          */
75:         public String[] splitFileInLines(final String file) {
76:                 return file.split(ScannerConstants.NEWLINE.toString());
77:         }
78:
79:         /**
80:          * split the line in parts.
81:          *
82:          * @param line
83:          * Zeile.
84:          * @return List of Parts
85:          */
86:         public String[] splitLineInParts(final String line) {
87:                 return line.split(ScannerConstants.SPACE.toString());
88:         }
89:
90: }