|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ModuleContext.java | - | 83,3% | 77,8% | 81% |
|
||||||||||||||
| 1 | /* $Id: ModuleContext.java,v 1.3 2007/12/21 23:33:46 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 java.net.URL; | |
| 21 | ||
| 22 | import org.qedeq.kernel.trace.Trace; | |
| 23 | ||
| 24 | ||
| 25 | /** | |
| 26 | * Define context for an instance of {@link org.qedeq.kernel.base.module.Qedeq}. | |
| 27 | * It consists of a location information: where is this module located. | |
| 28 | * Also the location within the {@link org.qedeq.kernel.base.module.Qedeq} object | |
| 29 | * should be described in an XPath like manner. | |
| 30 | * <p> | |
| 31 | * The idea behind this context is a caller perspective. The caller sets the | |
| 32 | * context (at least the module location information) and if the called method | |
| 33 | * throws an exception a try/catch block can retrieve the context information. | |
| 34 | * | |
| 35 | * @version $Revision: 1.3 $ | |
| 36 | * @author Michael Meyling | |
| 37 | */ | |
| 38 | public class ModuleContext { | |
| 39 | ||
| 40 | /** Module location. */ | |
| 41 | private URL moduleLocation; | |
| 42 | ||
| 43 | /** Location within the module. */ | |
| 44 | private String locationWithinModule; | |
| 45 | ||
| 46 | /** | |
| 47 | * Constructor. | |
| 48 | * | |
| 49 | * @param moduleLocation Module location information. | |
| 50 | * @param locationWithinModule Location within module. | |
| 51 | */ | |
| 52 | 38710 | public ModuleContext(final URL moduleLocation, final String locationWithinModule) { |
| 53 | 38710 | this.moduleLocation = moduleLocation; |
| 54 | 38710 | this.locationWithinModule = locationWithinModule; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Constructor. | |
| 59 | * | |
| 60 | * @param moduleLocation Module location information. | |
| 61 | */ | |
| 62 | 36337 | public ModuleContext(final URL moduleLocation) { |
| 63 | 36337 | this(moduleLocation, ""); |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Copy constructor. | |
| 68 | * | |
| 69 | * @param original Original context. | |
| 70 | */ | |
| 71 | 2217 | public ModuleContext(final ModuleContext original) { |
| 72 | 2217 | this(original.getModuleLocation(), original.getLocationWithinModule()); |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Constructor. | |
| 77 | * | |
| 78 | * @param main Main context. | |
| 79 | * @param moduleLocation Module location information. | |
| 80 | */ | |
| 81 | 0 | public ModuleContext(final ModuleContext main, final String moduleLocation) { |
| 82 | 0 | this(main.getModuleLocation(), moduleLocation); |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * Get location information about module. | |
| 87 | * | |
| 88 | * @return Module location information. | |
| 89 | */ | |
| 90 | 89657 | public final URL getModuleLocation() { |
| 91 | 89657 | return moduleLocation; |
| 92 | } | |
| 93 | ||
| 94 | /** | |
| 95 | * Set location information about module. | |
| 96 | * | |
| 97 | * @param moduleLocation Module location information. | |
| 98 | */ | |
| 99 | 0 | public final void setModuleLocation(final URL moduleLocation) { |
| 100 | 0 | this.moduleLocation = moduleLocation; |
| 101 | } | |
| 102 | ||
| 103 | /** | |
| 104 | * Get location information where are we within the module. | |
| 105 | * | |
| 106 | * @return Location within module. | |
| 107 | */ | |
| 108 | 7980730 | public final String getLocationWithinModule() { |
| 109 | 7980731 | return locationWithinModule; |
| 110 | } | |
| 111 | ||
| 112 | /** | |
| 113 | * Set location information where are we within the module. | |
| 114 | * | |
| 115 | * @param locationWithinModule Location within module. | |
| 116 | */ | |
| 117 | 5851589 | public final void setLocationWithinModule(final String locationWithinModule) { |
| 118 | 5851589 | final String method = "setLocationWithinModule(String)"; |
| 119 | 5851590 | this.locationWithinModule = locationWithinModule; |
| 120 | 5851593 | Trace.param(this, method, "locationWithinModule", locationWithinModule); |
| 121 | } | |
| 122 | ||
| 123 | /* (non-Javadoc) | |
| 124 | * @see java.lang.Object#toString() | |
| 125 | */ | |
| 126 | 1200 | public final String toString() { |
| 127 | 1200 | return getModuleLocation() + ":" + getLocationWithinModule(); |
| 128 | } | |
| 129 | ||
| 130 | } |
|
||||||||||