View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3   
4    Copyright (c) 2005, University of Innsbruck, Austria
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  package org.deri.wsmo4j.validator;
19  
20  import org.wsmo.common.*;
21  import org.wsmo.validator.*;
22  
23  /**
24   * Validation Warning
25   *
26   * <pre>
27   * Created on 18.11.2005
28   * Committed by $Author$
29   * $Source$,
30   * </pre>
31   *
32   * @author Holger Lausen (holger.lausen@deri.org)
33   *
34   * @version $Revision$ $Date$
35   */
36  public class ValidationWarningImpl extends ValidationMessageImpl
37          implements ValidationWarning {
38      
39      private String quickFix = null;
40      
41      private String warning = null;
42      
43      public ValidationWarningImpl(Entity entity, String warning) {
44          this(entity, warning, null);
45      }
46      
47      public ValidationWarningImpl(Entity entity , String warning, String quickFix){
48          super(entity,warning);
49          this.warning = warning;
50          this.quickFix=quickFix;
51      }
52      
53      public String toString(){
54          if (quickFix != null) {
55              return super.toString() + "\n Suggestion: " + quickFix;
56          }
57          else {
58              return super.toString();
59          }
60      }
61      
62      /**
63       * <p>
64       * The <code>equals</code> method implements an equivalence relation
65       * on non-null object references. ValidationWarnings are equal if their 
66       * warning and quickFix messages are equal.
67       * </p>
68       * <p>
69       * It is generally necessary to override the <code>hashCode</code> method whenever this method
70       * is overridden.
71       * </p>
72       * @param o the reference object with which to compare.
73       * @return <code>true</code> if this object is the same as the obj
74       *          argument; <code>false</code> otherwise.
75       * @see java.lang.Object#equals(java.lang.Object)
76       * @see java.lang.Object#hashCode()
77       */
78      public boolean equals(Object obj) {
79          if (obj instanceof ValidationWarning) {
80              ValidationWarningImpl vw = (ValidationWarningImpl) obj;
81              return ((vw.getReason().equals(warning)
82                       && vw.getQuickFix().equals(quickFix)));
83          }
84          return false;
85      }
86   
87      /**
88       * <p>
89       * If two objects are equal according to the <code>equals(Object)</code> method, then calling
90       * the <code>hashCode</code> method on each of the two objects must produce the same integer
91       * result. However, it is not required that if two objects are unequal according to
92       * the <code>equals(Object)</code> method, then calling the <code>hashCode</code> method on each of the two
93       * objects must produce distinct integer results.
94       * </p>
95       * <p>
96       * This method should be overriden, when the <code>equals(Object)</code> method is overriden.
97       * </p>
98       * @return A hash code value for this Object.
99       * @see java.lang.Object#hashCode()
100      * @see java.lang.Object#equals(Object)
101      */
102     public int hashCode() {
103         return super.hashCode();
104     }
105     
106 }
107 
108 
109 /*
110  *$Log$
111  *Revision 1.6  2006/08/22 16:22:26  nathaliest
112  *ameliorated the string output of validator errors and warnings
113  *
114  *Revision 1.5  2006/01/16 13:32:46  nathaliest
115  *added ValidationMessage to wsmo-api
116  *
117  *Revision 1.4  2006/01/12 14:39:34  alex_simov
118  *a null-check performed in toString()
119  *
120  *Revision 1.3  2006/01/09 16:12:58  nathaliest
121  *added quickFix method to validationError
122  *
123  *Revision 1.2  2005/12/15 16:47:27  nathaliest
124  *check for double error and warning messages
125  *
126  *Revision 1.1  2005/11/21 13:08:47  holgerlausen
127  *added ValidationWarning
128  *
129  */