|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ModuleContext.java | - | 83,3% | 77,8% | 81% |
|
1 | /* $Id: ModuleContext.java,v 1.1 2006/10/20 20:23:05 m31 Exp $ | |
2 | * | |
3 | * This file is part of the project "Hilbert II" - http://www.qedeq.org | |
4 | * | |
5 | * Copyright 2000-2006, Michael Meyling <mime@qedeq.org>. | |
6 | * | |
7 | * "Hilbert II" is free software; you can redistribute | |
8 | * it and/or modify it under the terms of the GNU General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | */ | |
17 | ||
18 | package org.qedeq.kernel.context; | |
19 | ||
20 | import org.qedeq.kernel.log.Trace; | |
21 | ||
22 | ||
23 | /** | |
24 | * Define context for an instance of {@link org.qedeq.kernel.base.module.Qedeq}. | |
25 | * It consists of a location information: where is this module located. | |
26 | * Also the location within the {@link org.qedeq.kernel.base.module.Qedeq} object | |
27 | * should be described in an XPath like manner. | |
28 | * <p> | |
29 | * The idea behind this context is a caller perspective. The caller sets the | |
30 | * context (at least the module location information) and if the called method | |
31 | * throws an exception a try/catch block can retrieve the context information. | |
32 | * | |
33 | * @version $Revision: 1.1 $ | |
34 | * @author Michael Meyling | |
35 | */ | |
36 | public final class ModuleContext { | |
37 | ||
38 | /** Module location. */ | |
39 | private String moduleLocation; | |
40 | ||
41 | /** Location within the module. */ | |
42 | private String locationWithinModule; | |
43 | ||
44 | /** | |
45 | * Constructor. | |
46 | * | |
47 | * @param moduleLocation Module location information. | |
48 | * @param locationWithinModule Location within module. | |
49 | */ | |
50 | 910 | public ModuleContext(final String moduleLocation, final String locationWithinModule) { |
51 | 910 | this.moduleLocation = moduleLocation; |
52 | 910 | this.locationWithinModule = locationWithinModule; |
53 | } | |
54 | ||
55 | /** | |
56 | * Constructor. | |
57 | * | |
58 | * @param moduleLocation Module location information. | |
59 | */ | |
60 | 26 | public ModuleContext(final String moduleLocation) { |
61 | 26 | this(moduleLocation, ""); |
62 | } | |
63 | ||
64 | /** | |
65 | * Copy constructor. | |
66 | * | |
67 | * @param original Original context. | |
68 | */ | |
69 | 725 | public ModuleContext(final ModuleContext original) { |
70 | 725 | this(original.getModuleLocation(), original.getLocationWithinModule()); |
71 | } | |
72 | ||
73 | /** | |
74 | * Constructor. | |
75 | * | |
76 | * @param main Main context. | |
77 | * @param moduleLocation Module location information. | |
78 | */ | |
79 | 0 | public ModuleContext(final ModuleContext main, final String moduleLocation) { |
80 | 0 | this(main.getModuleLocation(), moduleLocation); |
81 | } | |
82 | ||
83 | /** | |
84 | * Get location information about module. | |
85 | * | |
86 | * @return Module location information. | |
87 | */ | |
88 | 3880 | public final String getModuleLocation() { |
89 | 3880 | return moduleLocation; |
90 | } | |
91 | ||
92 | /** | |
93 | * Set location information about module. | |
94 | * | |
95 | * @param moduleLocation Module location information. | |
96 | */ | |
97 | 0 | public final void setModuleLocation(final String moduleLocation) { |
98 | 0 | this.moduleLocation = moduleLocation; |
99 | } | |
100 | ||
101 | /** | |
102 | * Get location information where are we within the module. | |
103 | * | |
104 | * @return Location within module. | |
105 | */ | |
106 | 67074 | public final String getLocationWithinModule() { |
107 | 67074 | return locationWithinModule; |
108 | } | |
109 | ||
110 | /** | |
111 | * Set location information where are we within the module. | |
112 | * | |
113 | * @param locationWithinModule Location within module. | |
114 | */ | |
115 | 141648 | public final void setLocationWithinModule(final String locationWithinModule) { |
116 | 141648 | final String method = "setLocationWithinModule(String)"; |
117 | 141648 | this.locationWithinModule = locationWithinModule; |
118 | 141648 | Trace.param(this, method, "locationWithinModule", locationWithinModule); |
119 | } | |
120 | ||
121 | /* (non-Javadoc) | |
122 | * @see java.lang.Object#toString() | |
123 | */ | |
124 | 2 | public final String toString() { |
125 | 2 | return getModuleLocation() + ":" + getLocationWithinModule(); |
126 | } | |
127 | ||
128 | } |
|