1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.helger.schematron.svrl;
18
19 import java.util.Locale;
20
21 import javax.annotation.Nonnull;
22
23 import com.helger.commons.ValueEnforcer;
24 import com.helger.commons.error.IErrorLevel;
25 import com.helger.commons.error.IResourceLocation;
26 import com.helger.commons.error.ResourceError;
27 import com.helger.commons.hashcode.HashCodeGenerator;
28 import com.helger.commons.string.StringHelper;
29 import com.helger.commons.string.ToStringGenerator;
30
31
32
33
34
35
36
37 public class SVRLResourceError extends ResourceError
38 {
39 private final String m_sTest;
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 public SVRLResourceError (@Nonnull final IResourceLocation aLocation,
55 @Nonnull final IErrorLevel aErrorLevel,
56 @Nonnull final String sErrorText,
57 @Nonnull final String sTest)
58 {
59 super (aLocation, aErrorLevel, sErrorText, null);
60 ValueEnforcer.notNull (sTest, "Test");
61 m_sTest = sTest;
62 }
63
64
65
66
67 @Nonnull
68 public String getTest ()
69 {
70 return m_sTest;
71 }
72
73 @Override
74 public String getAsString (@Nonnull final Locale aContentLocale)
75 {
76 String ret = "[" + getErrorLevel ().getID () + "]";
77 final String sLocation = getLocation ().getAsString ();
78 if (StringHelper.hasText (sLocation))
79 ret += ' ' + sLocation;
80 ret += "; Test=" + m_sTest;
81 ret += "; Message=" + getDisplayText (aContentLocale);
82 return ret;
83 }
84
85 @Override
86 public boolean equals (final Object o)
87 {
88 if (o == this)
89 return true;
90 if (!super.equals (o))
91 return false;
92 final SVRLResourceError rhs = (SVRLResourceError) o;
93 return m_sTest.equals (rhs.m_sTest);
94 }
95
96 @Override
97 public int hashCode ()
98 {
99 return HashCodeGenerator.getDerived (super.hashCode ()).append (m_sTest).getHashCode ();
100 }
101
102 @Override
103 public String toString ()
104 {
105 return ToStringGenerator.getDerived (super.toString ()).append ("test", m_sTest).toString ();
106 }
107 }