01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.teststeps.assertions;
14:
15: import org.apache.xmlbeans.XmlError;
16:
17: import com.eviware.soapui.impl.wsdl.panels.request.components.editor.support.ValidationError;
18:
19: /**
20: * Holder for an assertion error
21: *
22: * @author Ole.Matzura
23: */
24:
25: public class AssertionError implements ValidationError {
26: private String message;
27: private XmlError xmlError;
28:
29: public AssertionError(String message) {
30: this .message = message;
31: }
32:
33: public AssertionError(XmlError xmlError) {
34: this .xmlError = xmlError;
35: this .message = xmlError.getMessage();
36: }
37:
38: public String getMessage() {
39: return message;
40: }
41:
42: public int getLineNumber() {
43: return xmlError == null ? -1 : xmlError.getLine();
44: }
45:
46: public XmlError getXmlError() {
47: return xmlError;
48: }
49:
50: public String toString() {
51: if (xmlError == null)
52: return message;
53:
54: return "line " + getLineNumber() + ": " + message;
55: }
56:
57: public int hashCode() {
58: final int PRIME = 31;
59: int result = 1;
60: String msg = toString();
61: result = PRIME * result + ((msg == null) ? 0 : msg.hashCode());
62: return result;
63: }
64:
65: public boolean equals(Object obj) {
66: if (this == obj)
67: return true;
68: if (obj == null)
69: return false;
70: if (getClass() != obj.getClass())
71: return false;
72: final AssertionError other = (AssertionError) obj;
73:
74: return other.toString().equals(toString());
75: }
76: }
|