From 76868661a009477d9cb40b5520506d0f47affd15 Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Fri, 4 Dec 2020 17:45:56 +0100 Subject: [PATCH] Made "ID" field accessible --- .../schematron/svrl/AbstractSVRLMessage.java | 35 ++++++++++++------- .../schematron/svrl/SVRLFailedAssert.java | 1 + .../schematron/svrl/SVRLSuccessfulReport.java | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/AbstractSVRLMessage.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/AbstractSVRLMessage.java index ecf992b62..9c9977649 100644 --- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/AbstractSVRLMessage.java +++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/AbstractSVRLMessage.java @@ -42,12 +42,14 @@ public abstract class AbstractSVRLMessage implements Serializable { protected ICommonsList m_aDiagnosticReferences; protected String m_sText; + protected String m_sID; protected String m_sLocation; protected String m_sTest; protected String m_sRole; protected IErrorLevel m_aFlag; public AbstractSVRLMessage (@Nullable final List aDiagnosticReferences, + @Nullable final String sID, @Nullable final String sText, @Nullable final String sLocation, @Nullable final String sTest, @@ -55,6 +57,7 @@ public AbstractSVRLMessage (@Nullable final List aDiagnost @Nullable final IErrorLevel aFlag) { m_aDiagnosticReferences = new CommonsArrayList <> (aDiagnosticReferences); + m_sID = StringHelper.trim (sID); m_sText = StringHelper.trim (sText); m_sLocation = sLocation; m_sTest = sTest; @@ -64,37 +67,43 @@ public AbstractSVRLMessage (@Nullable final List aDiagnost @Nonnull @ReturnsMutableCopy - public ICommonsList getDiagnisticReferences () + public final ICommonsList getDiagnisticReferences () { return m_aDiagnosticReferences.getClone (); } @Nullable - public String getText () + public final String getID () + { + return m_sID; + } + + @Nullable + public final String getText () { return m_sText; } @Nullable - public String getLocation () + public final String getLocation () { return m_sLocation; } @Nullable - public String getTest () + public final String getTest () { return m_sTest; } @Nullable - public String getRole () + public final String getRole () { return m_sRole; } @Nonnull - public IErrorLevel getFlag () + public final IErrorLevel getFlag () { return m_aFlag; } @@ -103,6 +112,7 @@ public IErrorLevel getFlag () public SVRLResourceError getAsResourceError (@Nullable final String sResourceName) { return new SVRLErrorBuilder (m_sTest).setErrorLevel (m_aFlag) + .setErrorID (m_sID) .setErrorFieldName (m_sLocation) .setErrorLocation (new SimpleLocation (sResourceName)) .setErrorText (m_sText) @@ -112,12 +122,13 @@ public SVRLResourceError getAsResourceError (@Nullable final String sResourceNam @Override public String toString () { - return new ToStringGenerator (this).append ("diagnosticRefs", m_aDiagnosticReferences) - .append ("text", m_sText) - .append ("location", m_sLocation) - .append ("test", m_sTest) - .appendIfNotNull ("role", m_sRole) - .append ("flag", m_aFlag) + return new ToStringGenerator (this).append ("DiagnosticRefs", m_aDiagnosticReferences) + .append ("ID", m_sID) + .append ("Text", m_sText) + .append ("Location", m_sLocation) + .append ("Test", m_sTest) + .appendIfNotNull ("Role", m_sRole) + .append ("Flag", m_aFlag) .getToString (); } } diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java index 0f06dbb72..ed17c9486 100644 --- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java +++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java @@ -48,6 +48,7 @@ public SVRLFailedAssert (@Nonnull final FailedAssert aFailedAssert, @Nonnull final Function aErrLevelProvider) { super (aFailedAssert.getDiagnosticReference (), + aFailedAssert.getId (), SVRLHelper.getAsString (aFailedAssert.getText ()), aLocationProvider.apply (aFailedAssert), aFailedAssert.getTest (), diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java index 3eb235cb4..0d27755d2 100644 --- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java +++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java @@ -48,6 +48,7 @@ public SVRLSuccessfulReport (@Nonnull final SuccessfulReport aSuccessfulReport, @Nonnull final Function aErrLevelProvider) { super (aSuccessfulReport.getDiagnosticReference (), + aSuccessfulReport.getId (), SVRLHelper.getAsString (aSuccessfulReport.getText ()), aLocationProvider.apply (aSuccessfulReport), aSuccessfulReport.getTest (),