|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ModuleContext.java | - | 83,3% | 77,8% | 81% |
|
||||||||||||||
| 1 | /* $Id: ModuleContext.java,v 1.4 2008/01/26 12:39:09 m31 Exp $ | |
| 2 | * | |
| 3 | * This file is part of the project "Hilbert II" - http://www.qedeq.org | |
| 4 | * | |
| 5 | * Copyright 2000-2007, 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.bo.module; | |
| 19 | ||
| 20 | import org.qedeq.kernel.trace.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.4 $ | |
| 34 | * @author Michael Meyling | |
| 35 | */ | |
| 36 | public class ModuleContext { | |
| 37 | ||
| 38 | /** This class. */ | |
| 39 | private static final Class CLASS = ModuleContext.class; | |
| 40 | ||
| 41 | /** Module location. */ | |
| 42 | private ModuleAddress moduleLocation; | |
| 43 | ||
| 44 | /** Location within the module. */ | |
| 45 | private String locationWithinModule; | |
| 46 | ||
| 47 | /** | |
| 48 | * Constructor. | |
| 49 | * | |
| 50 | * @param moduleLocation Module location information. | |
| 51 | * @param locationWithinModule Location within module. | |
| 52 | */ | |
| 53 | 36217 | public ModuleContext(final ModuleAddress moduleLocation, final String locationWithinModule) { |
| 54 | 36217 | this.moduleLocation = moduleLocation; |
| 55 | 36217 | this.locationWithinModule = locationWithinModule; |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Constructor. | |
| 60 | * | |
| 61 | * @param moduleLocation Module location information. | |
| 62 | */ | |
| 63 | 32802 | public ModuleContext(final ModuleAddress moduleLocation) { |
| 64 | 32802 | this(moduleLocation, ""); |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Copy constructor. | |
| 69 | * | |
| 70 | * @param original Original context. | |
| 71 | */ | |
| 72 | 3259 | public ModuleContext(final ModuleContext original) { |
| 73 | 3259 | this(original.getModuleLocation(), original.getLocationWithinModule()); |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * Constructor. | |
| 78 | * | |
| 79 | * @param main Main context. | |
| 80 | * @param moduleLocation Module location information. | |
| 81 | */ | |
| 82 | 0 | public ModuleContext(final ModuleContext main, final String moduleLocation) { |
| 83 | 0 | this(main.getModuleLocation(), moduleLocation); |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * Get location information about module. | |
| 88 | * | |
| 89 | * @return Module location information. | |
| 90 | */ | |
| 91 | 116496 | public final ModuleAddress getModuleLocation() { |
| 92 | 116496 | return moduleLocation; |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * Set location information about module. | |
| 97 | * | |
| 98 | * @param moduleLocation Module location information. | |
| 99 | */ | |
| 100 | 0 | public final void setModuleLocation(final ModuleAddress moduleLocation) { |
| 101 | 0 | this.moduleLocation = moduleLocation; |
| 102 | } | |
| 103 | ||
| 104 | /** | |
| 105 | * Get location information where are we within the module. | |
| 106 | * | |
| 107 | * @return Location within module. | |
| 108 | */ | |
| 109 | 8239413 | public final String getLocationWithinModule() { |
| 110 | 8239412 | return locationWithinModule; |
| 111 | } | |
| 112 | ||
| 113 | /** | |
| 114 | * Set location information where are we within the module. | |
| 115 | * | |
| 116 | * @param locationWithinModule Location within module. | |
| 117 | */ | |
| 118 | 6224546 | public final void setLocationWithinModule(final String locationWithinModule) { |
| 119 | 6224547 | final String method = "setLocationWithinModule(String)"; |
| 120 | 6224547 | this.locationWithinModule = locationWithinModule; |
| 121 | 6224559 | Trace.param(CLASS, this, method, "locationWithinModule", locationWithinModule); |
| 122 | } | |
| 123 | ||
| 124 | /* (non-Javadoc) | |
| 125 | * @see java.lang.Object#toString() | |
| 126 | */ | |
| 127 | 32103 | public final String toString() { |
| 128 | 32103 | return getModuleLocation() + ":" + getLocationWithinModule(); |
| 129 | } | |
| 130 | ||
| 131 | } |
|
||||||||||