Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
19   137   15   2.38
14   51   0.79   8
8     1.88  
1    
 
  ModuleDataException       Line # 29 19 15 97.6% 0.9756098
 
  (98)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.se.common;
17   
18    import org.qedeq.base.utility.EqualsUtility;
19   
20    /**
21    * Data validation error for a QEDEQ module. An error has always a reference to its
22    * location. Maybe an additional reference for another location is provided.
23    * <br/>
24    * An error code, message and location should fix a certain data validation error, so only these
25    * informations are used for {@link #hashCode()} and {@link #equals(Object)}.
26    *
27    * @author Michael Meyling
28    */
 
29    public abstract class ModuleDataException extends QedeqException {
30   
31    /** Error location. */
32    private final ModuleContext context;
33   
34    /** Reference location to explain the error. */
35    private final ModuleContext referenceContext;
36   
37    /**
38    * Constructor.
39    *
40    * @param errorCode Error code of this message.
41    * @param message Error message.
42    * @param context Error location.
43    * @param referenceContext Reference location.
44    * @param cause Detailed exception information.
45    */
 
46  29 toggle public ModuleDataException(final int errorCode, final String message,
47    final ModuleContext context, final ModuleContext referenceContext,
48    final Exception cause) {
49  29 super(errorCode, message, cause);
50    // use copy constructor
51  29 this.context = (context == null ? null : new ModuleContext(context));
52  29 this.referenceContext = (referenceContext == null ? null
53    : new ModuleContext(referenceContext));
54    }
55   
56    /**
57    * Constructor.
58    *
59    * @param errorCode Error code of this message.
60    * @param message Error message.
61    * @param context Error location.
62    * @param referenceContext Reference location.
63    */
 
64  23 toggle public ModuleDataException(final int errorCode, final String message,
65    final ModuleContext context, final ModuleContext referenceContext) {
66  23 super(errorCode, message);
67    // use copy constructor
68  23 this.context = (context == null ? null : new ModuleContext(context));
69  23 this.referenceContext = (referenceContext == null ? null
70    : new ModuleContext(referenceContext));
71    }
72   
73    /**
74    * Constructor.
75    *
76    * @param errorCode Error code of this message.
77    * @param message Error message.
78    * @param context Error location.
79    * @param cause Detailed exception information.
80    */
 
81  68 toggle public ModuleDataException(final int errorCode, final String message,
82    final ModuleContext context, final Exception cause) {
83  68 super(errorCode, message, cause);
84    // use copy constructor
85  68 this.context = (context == null ? null : new ModuleContext(context));
86  68 this.referenceContext = null;
87    }
88   
89    /**
90    * Constructor. Copies module context, so original can be changed.
91    *
92    * @param errorCode Error code of this message.
93    * @param message Error message.
94    * @param context Error location.
95    */
 
96  67225 toggle public ModuleDataException(final int errorCode, final String message,
97    final ModuleContext context) {
98  67225 super(errorCode, message);
99    // use copy constructor
100  67225 this.context = (context == null ? null : new ModuleContext(context));
101  67225 this.referenceContext = null;
102    }
103   
104    /**
105    * Get context information about error location.
106    *
107    * @return Error location context.
108    */
 
109  331 toggle public final ModuleContext getContext() {
110  331 return context;
111    }
112   
113    /**
114    * Get additional context information about another associated location.
115    *
116    * @return Additional error location context.
117    */
 
118  344 toggle public final ModuleContext getReferenceContext() {
119  344 return referenceContext;
120    }
121   
 
122  52 toggle public final int hashCode() {
123  52 return getErrorCode() ^ context.hashCode() ^ getMessage().hashCode();
124    }
125   
 
126  41 toggle public final boolean equals(final Object obj) {
127  41 if (!(obj instanceof ModuleDataException)) {
128  14 return false;
129    }
130  27 final ModuleDataException other = (ModuleDataException) obj;
131  27 return (getErrorCode() == other.getErrorCode())
132    && EqualsUtility.equals(getMessage(), other.getMessage())
133    && EqualsUtility.equals(context, other.context);
134    }
135   
136   
137    }