Clover coverage report - Maven Clover report
Coverage timestamp: Tue Sep 16 2008 01:16:37 EEST
file stats: LOC: 206   Methods: 6
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ValidationErrorImpl.java 0% 0% 0% 0%
coverage
 1    /*
 2    wsmo4j - a WSMO API and Reference Implementation
 3    Copyright (c) 2005, University of Innsbruck, Austria
 4    This library is free software; you can redistribute it and/or modify it under
 5    the terms of the GNU Lesser General Public License as published by the Free
 6    Software Foundation; either version 2.1 of the License, or (at your option)
 7    any later version.
 8    This library is distributed in the hope that it will be useful, but WITHOUT
 9    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 10    FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 11    details.
 12    You should have received a copy of the GNU Lesser General Public License along
 13    with this library; if not, write to the Free Software Foundation, Inc.,
 14    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 15    */
 16   
 17    package org.deri.wsmo4j.validator;
 18   
 19   
 20    import org.wsmo.common.*;
 21    import org.wsmo.validator.ValidationError;
 22   
 23   
 24    /**
 25    * Gives Structure to a validation error.
 26    *
 27    * <pre>
 28    * Created on Jul 28, 2005
 29    * Committed by $Author: nathaliest $
 30    * $Source$,
 31    * </pre>
 32    *
 33    * @author Holger Lausen
 34    * @author nathalie.steinmetz@deri.org
 35    * @see org.wsmo.validator.ValidationError
 36    * @version $Revision: 1813 $ $Date: 2006-08-22 19:22:26 +0300 (Tue, 22 Aug 2006) $
 37    */
 38    public class ValidationErrorImpl extends ValidationMessageImpl implements ValidationError{
 39   
 40    private String variant = null;
 41   
 42    private String reason = null;
 43   
 44    private String quickFix = null;
 45   
 46  0 public ValidationErrorImpl(Entity entity, String reason, String variant) {
 47  0 this(entity, reason, variant, null);
 48    }
 49   
 50  0 public ValidationErrorImpl(Entity entity, String reason, String variant, String quickFix) {
 51  0 super(entity,reason);
 52  0 this.reason = reason;
 53  0 if (!variant.equals(WSML.WSML_CORE)
 54    && !variant.equals(WSML.WSML_DL)
 55    && !variant.equals(WSML.WSML_FULL)
 56    && !variant.equals(WSML.WSML_FLIGHT)
 57    && !variant.equals(WSML.WSML_RULE)) {
 58  0 throw new IllegalArgumentException(
 59    "Invalid WSML Variant specified:" + variant);
 60    }
 61  0 this.variant = variant;
 62  0 this.quickFix = quickFix;
 63    }
 64   
 65    /**
 66    * @see org.wsmo.validator.ValidationError#getViolatesVariant()
 67    * @return String representation of URI representing the variant that the
 68    * error violates
 69    */
 70  0 public String getViolatesVariant() {
 71  0 return variant;
 72    }
 73   
 74    /**
 75    * Formats the String representation of the ValidationError.
 76    *
 77    * @see java.lang.Object#toString()
 78    */
 79  0 public String toString() {
 80    //short for variant if possible
 81  0 String shortVariant = variant;
 82  0 if (variant.lastIndexOf('/') != -1) {
 83  0 shortVariant = variant.substring(variant.lastIndexOf('/') + 1);
 84    }
 85  0 if (quickFix != null) {
 86  0 return super.toString() + "\n(Violated variant: " +
 87    shortVariant + ")" + "\n Suggestion: " + quickFix;
 88    }
 89    else {
 90  0 return super.toString() + "\n(Violated variant: " +
 91    shortVariant + ")";
 92    }
 93    }
 94   
 95    /**
 96    * <p>
 97    * The <code>equals</code> method implements an equivalence relation
 98    * on non-null object references. ValidationWarnings are equal if their
 99    * warning and quickFix messages are equal.
 100    * </p>
 101    * <p>
 102    * It is generally necessary to override the <code>hashCode</code> method whenever this method
 103    * is overridden.
 104    * </p>
 105    * @param o the reference object with which to compare.
 106    * @return <code>true</code> if this object is the same as the obj
 107    * argument; <code>false</code> otherwise.
 108    * @see java.lang.Object#equals(java.lang.Object)
 109    * @see java.lang.Object#hashCode()
 110    */
 111  0 public boolean equals(Object obj) {
 112  0 if (obj instanceof ValidationError) {
 113  0 if (quickFix == null) {
 114  0 quickFix = "";
 115    }
 116  0 ValidationErrorImpl vw = (ValidationErrorImpl) obj;
 117  0 return (vw.getReason().equals(reason)
 118    && vw.getQuickFix().equals(quickFix));
 119    }
 120  0 return false;
 121    }
 122   
 123    /**
 124    * <p>
 125    * If two objects are equal according to the <code>equals(Object)</code> method, then calling
 126    * the <code>hashCode</code> method on each of the two objects must produce the same integer
 127    * result. However, it is not required that if two objects are unequal according to
 128    * the <code>equals(Object)</code> method, then calling the <code>hashCode</code> method on each of the two
 129    * objects must produce distinct integer results.
 130    * </p>
 131    * <p>
 132    * This method should be overriden, when the <code>equals(Object)</code> method is overriden.
 133    * </p>
 134    * @return A hash code value for this Object.
 135    * @see java.lang.Object#hashCode()
 136    * @see java.lang.Object#equals(Object)
 137    */
 138  0 public int hashCode() {
 139  0 return super.hashCode();
 140    }
 141   
 142    }
 143    /*
 144    * $Log$
 145    * Revision 1.7 2006/08/22 16:22:26 nathaliest
 146    * ameliorated the string output of validator errors and warnings
 147    *
 148    * Revision 1.6 2006/08/21 10:44:47 nathaliest
 149    * fixed problem causing duplicate error messages
 150    *
 151    * Revision 1.5 2006/01/16 13:32:46 nathaliest
 152    * added ValidationMessage to wsmo-api
 153    *
 154    * Revision 1.4 2006/01/09 16:12:58 nathaliest
 155    * added quickFix method to validationError
 156    *
 157    * Revision 1.3 2005/12/15 16:47:27 nathaliest
 158    * check for double error and warning messages
 159    *
 160    * Revision 1.2 2005/11/21 13:08:47 holgerlausen
 161    * added ValidationWarning
 162    *
 163    * Revision 1.1 2005/11/15 16:54:37 nathaliest
 164    * created validation error implementations
 165    *
 166    * Revision 1.13 2005/11/08 17:46:10 nathaliest
 167    * changed error messages
 168    *
 169    * Revision 1.12 2005/10/24 10:47:55 holgerlausen
 170    * added metamodelling error for core / dl
 171    * fixed checkDatatype
 172    * fixed ofType bug
 173    * fixed bug in relation parameter checks
 174    * fixed null pointer when calling validator without errorlist
 175    *
 176    * Revision 1.11 2005/09/23 12:06:32 holgerlausen
 177    * moved wsml varinat constructs to common.wsml
 178    *
 179    * Revision 1.10 2005/09/21 08:15:39 holgerlausen
 180    * fixing java doc, removing asString()
 181    *
 182    * Revision 1.9 2005/09/12 16:02:00 nathaliest
 183    * added error codes
 184    *
 185    * Revision 1.8 2005/09/11 22:11:19 nathaliest
 186    * added error codes
 187    *
 188    * Revision 1.7 2005/09/09 15:51:42 marin_dimitrov
 189    * formatting
 190    *
 191    * Revision 1.6 2005/09/09 15:46:48 marin_dimitrov
 192    * validators moved from org.wsmo.common to org.wsmo.validator
 193    *
 194    * Revision 1.5 2005/09/09 15:23:04 nathaliest
 195    * changed WsmlValidator imports
 196    *
 197    * Revision 1.4 2005/09/09 14:39:05 nathaliest
 198    * changed wsmlvalidator import, new error code and changed toString method
 199    *
 200    * Revision 1.3 2005/09/08 17:09:23 nathaliest
 201    * changed error codes
 202    *
 203    * Revision 1.2 2005/09/07 06:57:14 holgerlausen
 204    * better readable output of toString
 205    *
 206    */