1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.testsuite;
14
15 import org.apache.xmlbeans.XmlError;
16
17 import com.eviware.soapui.support.editor.xml.support.ValidationError;
18
19 /***
20 * Holder for an assertion error
21 *
22 * @author Ole.Matzura
23 */
24
25 public class AssertionError implements ValidationError
26 {
27 private String message;
28 private XmlError xmlError;
29
30 public AssertionError( String message )
31 {
32 this.message = message;
33 }
34
35 public AssertionError( XmlError xmlError )
36 {
37 this.xmlError = xmlError;
38 this.message = xmlError.getMessage();
39 }
40
41 public String getMessage()
42 {
43 return message;
44 }
45
46 public int getLineNumber()
47 {
48 return xmlError == null ? -1 : xmlError.getLine();
49 }
50
51 public XmlError getXmlError()
52 {
53 return xmlError;
54 }
55
56 public String toString()
57 {
58 if( xmlError == null )
59 return message;
60
61 return "line " + getLineNumber() + ": " + message;
62 }
63
64 public int hashCode()
65 {
66 final int PRIME = 31;
67 int result = 1;
68 String msg = toString();
69 result = PRIME * result + ((msg == null) ? 0 : msg.hashCode());
70 return result;
71 }
72
73 public boolean equals(Object obj)
74 {
75 if (this == obj)
76 return true;
77 if (obj == null)
78 return false;
79 if (getClass() != obj.getClass())
80 return false;
81 final AssertionError other = (AssertionError) obj;
82
83 return other.toString().equals( toString() );
84 }
85 }