Skip to content

Commit

Permalink
Renamed class again to match intent
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Mar 9, 2024
1 parent 9e2c3bc commit fa6e70d
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public interface ISchematronResource extends IHasID <String>
* In case the transformation somehow goes wrong.
*/
@Nullable
SchematronOutputType applySchematronValidationToSVRL (@Nonnull Node aXMLNode, @Nullable String sBaseURI) throws Exception;
SchematronOutputType applySchematronValidationToSVRL (@Nonnull Node aXMLNode, @Nullable String sBaseURI)
throws Exception;

/**
* Apply the Schematron validation on the passed XML source and return a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class SchematronInterruptedException extends RuntimeException
public SchematronInterruptedException ()
{
super ("Interrupted Schematron compilation");
SchematronDebug.getDebugLogger ().info ( () -> "Throwing SchematronInterruptedException()");
}

/**
Expand All @@ -43,6 +44,6 @@ public SchematronInterruptedException ()
public SchematronInterruptedException (@Nonnull final String sMsg)
{
super ("Interrupted Schematron compilation: " + sMsg);
SchematronDebug.getDebugLogger ().info ( () -> "Throwing SchematronInterruptedException: " + sMsg);
SchematronDebug.getDebugLogger ().info ( () -> "Throwing SchematronInterruptedException(" + sMsg + ")");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ public static Node getNodeOfSource (@Nonnull final Source aSource, @Nonnull fina
final URLResource aURL = new URLResource (sSystemID);
final Document aDoc = DOMReader.readXMLDOM (aURL, aDRS);
if (aDoc == null)
throw new IllegalArgumentException ("Failed to read source " + aSource + " as XML from SystemID '" + sSystemID + "'");
throw new IllegalArgumentException ("Failed to read source " +
aSource +
" as XML from SystemID '" +
sSystemID +
"'");
return aDoc;
}
catch (final MalformedURLException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import com.helger.commons.traits.IGenericImplTrait;
import com.helger.schematron.AbstractSchematronResource;
import com.helger.schematron.SchematronDebug;
import com.helger.schematron.api.xslt.validator.ISchematronOutputValidator;
import com.helger.schematron.api.xslt.validator.SchematronOutputValidatorDefault;
import com.helger.schematron.api.xslt.validator.ISchematronOutputValidityDeterminator;
import com.helger.schematron.api.xslt.validator.SchematronOutputValidityDeterminatorDefault;
import com.helger.schematron.svrl.SVRLMarshaller;
import com.helger.schematron.svrl.jaxb.SchematronOutputType;
import com.helger.xml.XMLFactory;
Expand Down Expand Up @@ -79,7 +79,7 @@ public abstract class AbstractSchematronXSLTBasedResource <IMPLTYPE extends Abst
protected ErrorListener m_aCustomErrorListener;
protected URIResolver m_aCustomURIResolver = new DefaultTransformURIResolver ();
protected final ICommonsOrderedMap <String, Object> m_aCustomParameters = new CommonsLinkedHashMap <> ();
private ISchematronOutputValidator m_aSvrlValidator = new SchematronOutputValidatorDefault ();
private ISchematronOutputValidityDeterminator m_aSOVDeterminator = new SchematronOutputValidityDeterminatorDefault ();
private boolean m_bValidateSVRL = DEFAULT_VALIDATE_SVRL;

@Nullable
Expand Down Expand Up @@ -168,16 +168,16 @@ public final IMPLTYPE setEntityResolver (@Nullable final EntityResolver aEntityR
* <code>null</code>.
*/
@Nonnull
public final ISchematronOutputValidator getOutputValidator ()
public final ISchematronOutputValidityDeterminator getOutputValidityDeterminator ()
{
return m_aSvrlValidator;
return m_aSOVDeterminator;
}

@Nonnull
public final IMPLTYPE setOutputValidator (@Nonnull final ISchematronOutputValidator aXSLTValidator)
public final IMPLTYPE setOutputValidityDeterminator (@Nonnull final ISchematronOutputValidityDeterminator aSOVDeterminator)
{
ValueEnforcer.notNull (aXSLTValidator, "XSLTValidator");
m_aSvrlValidator = aXSLTValidator;
ValueEnforcer.notNull (aSOVDeterminator, "SchematronOutputValidityDeterminator");
m_aSOVDeterminator = aSOVDeterminator;
return thisAsT ();
}

Expand Down Expand Up @@ -211,7 +211,7 @@ public final EValidity getSchematronValidity (@Nonnull final Node aXMLNode, @Nul
return EValidity.INVALID;

// And now filter all elements that make the passed source invalid
return m_aSvrlValidator.getSchematronOutputValidity (aSO);
return m_aSOVDeterminator.getSchematronOutputValidity (aSO);
}

@Nullable
Expand Down Expand Up @@ -310,7 +310,7 @@ public String toString ()
.append ("CustomErrorListener", m_aCustomErrorListener)
.append ("CustomURIResolver", m_aCustomURIResolver)
.append ("CustomParameters", m_aCustomParameters)
.append ("XSLTValidator", m_aSvrlValidator)
.append ("XSLTValidator", m_aSOVDeterminator)
.append ("ValidateSVRL", m_bValidateSVRL)
.getToString ();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.helger.commons.annotation.ReturnsMutableObject;
import com.helger.commons.collection.impl.ICommonsOrderedMap;
import com.helger.schematron.ISchematronResource;
import com.helger.schematron.api.xslt.validator.ISchematronOutputValidator;
import com.helger.schematron.api.xslt.validator.ISchematronOutputValidityDeterminator;

/**
* Special Schematron resource for XSLT based implementations.
Expand Down Expand Up @@ -110,18 +110,18 @@ default void setAllowForeignElements (final boolean bAllow)
* <code>null</code>.
*/
@Nonnull
ISchematronOutputValidator getOutputValidator ();
ISchematronOutputValidityDeterminator getOutputValidityDeterminator ();

/**
* Set the Schematron output validator to be used.<br>
* Note: The method was renamed in v8 from <code>setXSLTValidator</code>.
*
* @param aOutputValidator
* Validator instance to use. May not be <code>null</code>.
* @param aValidityDeterminator
* Validity determinator instance to use. May not be <code>null</code>.
* @return this for chaining
*/
@Nonnull
ISchematronXSLTBasedResource setOutputValidator (@Nonnull ISchematronOutputValidator aOutputValidator);
ISchematronXSLTBasedResource setOutputValidityDeterminator (@Nonnull ISchematronOutputValidityDeterminator aValidityDeterminator);

/**
* @return <code>true</code> if the created SVRL should be validated or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Philip Helger
*/
public interface ISchematronOutputValidator
public interface ISchematronOutputValidityDeterminator
{
/**
* Determine the overall validity of a Schematron validation result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import com.helger.schematron.svrl.jaxb.SuccessfulReport;

/**
* The default implementation of {@link ISchematronOutputValidator} that
* interprets both failed asserts and successful reports as errors.
* The default implementation of {@link ISchematronOutputValidityDeterminator}
* that interprets both failed asserts and successful reports as errors.
*
* @author Philip Helger
*/
public class SchematronOutputValidatorDefault implements ISchematronOutputValidator
public class SchematronOutputValidityDeterminatorDefault implements ISchematronOutputValidityDeterminator
{
@Nonnull
public EValidity getSchematronOutputValidity (@Nonnull final SchematronOutputType aSO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import com.helger.schematron.svrl.jaxb.SchematronOutputType;

/**
* A special implementation of {@link ISchematronOutputValidator} that only
* handles failed asserts as failures, but not successful reports.
* A special implementation of {@link ISchematronOutputValidityDeterminator}
* that only handles failed asserts as failures, but not successful reports.
*
* @author Philip Helger
*/
public class SchematronOutputValidatorFailedAssertOnly implements ISchematronOutputValidator
public class SchematronOutputValidityDeterminatorFailedAssertOnly implements ISchematronOutputValidityDeterminator
{
@Nonnull
public EValidity getSchematronOutputValidity (@Nonnull final SchematronOutputType aSO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import com.helger.schematron.svrl.jaxb.SuccessfulReport;

/**
* A special implementation of {@link ISchematronOutputValidator} that only
* handles successful reports as failures, but not failed asserts.
* A special implementation of {@link ISchematronOutputValidityDeterminator}
* that only handles successful reports as failures, but not failed asserts.
*
* @author Philip Helger
* @since 6.0.0
*/
public class SchematronOutputValidatorSuccessfulReportOnly implements ISchematronOutputValidator
public class SchematronOutputValidityDeterminatorSuccessfulReportOnly implements ISchematronOutputValidityDeterminator
{
@Nonnull
public EValidity getSchematronOutputValidity (@Nonnull final SchematronOutputType aSO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public static TransformerFactory createTransformerFactorySaxonFirst (@Nullable f
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Calling createTransformerFactorySaxonFirst");

final ClassLoader aEffectiveClassLoader = aClassLoader != null ? aClassLoader : ClassLoaderHelper.getContextClassLoader ();
final ClassLoader aEffectiveClassLoader = aClassLoader != null ? aClassLoader : ClassLoaderHelper
.getContextClassLoader ();

TransformerFactory aFactory;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public SVRLMarshaller ()

public SVRLMarshaller (final boolean bValidationEnabled)
{
super (SchematronOutputType.class, bValidationEnabled ? CSVRL.SVRL_XSDS : null, new ObjectFactory ()::createSchematronOutput);
super (SchematronOutputType.class,
bValidationEnabled ? CSVRL.SVRL_XSDS : null,
new ObjectFactory ()::createSchematronOutput);
setFormattedOutput (GlobalDebug.isDebugMode ());

// Use the default namespace context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public abstract class AbstractCollectingPSErrorHandler extends AbstractPSErrorHa
{
private final ErrorList m_aErrorList;

public AbstractCollectingPSErrorHandler (@Nonnull final ErrorList aErrorList, @Nullable final IPSErrorHandler aNestedErrorHandler)
public AbstractCollectingPSErrorHandler (@Nonnull final ErrorList aErrorList,
@Nullable final IPSErrorHandler aNestedErrorHandler)
{
super (aNestedErrorHandler);
m_aErrorList = ValueEnforcer.notNull (aErrorList, "ErrorList");
Expand Down Expand Up @@ -95,6 +96,6 @@ public boolean isEmpty ()
@Override
public String toString ()
{
return ToStringGenerator.getDerived (super.toString ()).appendIfNotNull ("ErrorList", m_aErrorList).getToString ();
return ToStringGenerator.getDerived (super.toString ()).append ("ErrorList", m_aErrorList).getToString ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.helger.commons.error.IError;
import com.helger.commons.error.IErrorTextProvider;
import com.helger.commons.log.LogHelper;
import com.helger.commons.string.ToStringGenerator;

/**
* An implementation if {@link IPSErrorHandler} that logs to an SLF4J logger.
Expand All @@ -38,13 +39,17 @@
*/
public class LoggingPSErrorHandler extends AbstractPSErrorHandler
{
// Same as ErrorTextProvider::DEFAULT but without the date and time
public static final IErrorTextProvider DEFAULT_PS = new ErrorTextProvider ().addItem (EField.ERROR_LEVEL, "[$]")
.addItem (EField.ERROR_ID, "[$]")
.addItem (EField.ERROR_FIELD_NAME, "[$]")
.addItem (EField.ERROR_FIELD_NAME,
"in [$]")
.addItem (EField.ERROR_LOCATION, "@ $")
.addItem (EField.ERROR_TEXT, "$")
.addItem (EField.ERROR_LINKED_EXCEPTION_CLASS, "($:")
.addItem (EField.ERROR_LINKED_EXCEPTION_MESSAGE, "$)")
.addItem (EField.ERROR_LINKED_EXCEPTION_CLASS,
"($:")
.addItem (EField.ERROR_LINKED_EXCEPTION_MESSAGE,
"$)")
.setFieldSeparator (" ");

private static final Logger LOGGER = LoggerFactory.getLogger (LoggingPSErrorHandler.class);
Expand Down Expand Up @@ -78,6 +83,15 @@ public final LoggingPSErrorHandler setErrorTextProvider (@Nonnull final IErrorTe
@Override
protected void handleInternally (@Nonnull final IError aError)
{
LogHelper.log (LOGGER, aError.getErrorLevel (), m_aETP.getErrorText (aError, Locale.US), aError.getLinkedException ());
LogHelper.log (LOGGER,
aError.getErrorLevel (),
m_aETP.getErrorText (aError, Locale.US),
aError.getLinkedException ());
}

@Override
public String toString ()
{
return ToStringGenerator.getDerived (super.toString ()).append ("ErrorTextProvider", m_aETP).getToString ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -45,15 +44,11 @@
import com.helger.xml.microdom.serialize.MicroWriter;
import com.helger.xml.serialize.read.SAXReaderSettings;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Utility class for reading all Schematron elements from a resource.
*
* @author Philip Helger
*/
@Immutable
@SuppressFBWarnings ("JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS")
public class PSReader
{
private static final Logger LOGGER = LoggerFactory.getLogger (PSReader.class);
Expand Down

0 comments on commit fa6e70d

Please sign in to comment.