Search in sources :

Example 1 with PSBoundSchemaCacheKey

use of com.helger.schematron.pure.bound.PSBoundSchemaCacheKey in project ph-schematron by phax.

the class SchematronResourcePure method createBoundSchema.

@Nonnull
protected IPSBoundSchema createBoundSchema() {
    final IReadableResource aResource = getResource();
    final IPSErrorHandler aErrorHandler = getErrorHandler();
    final PSBoundSchemaCacheKey aCacheKey = new PSBoundSchemaCacheKey(aResource, getPhase(), aErrorHandler, getVariableResolver(), getFunctionResolver(), getEntityResolver());
    if (aResource instanceof AbstractMemoryReadableResource || !isUseCache()) {
        // No need to cache anything for memory resources
        try {
            return aCacheKey.createBoundSchema();
        } catch (final SchematronException ex) {
            // Convert to runtime exception
            throw new IllegalStateException("Failed to bind Schematron", ex);
        }
    }
    // happens
    return PSBoundSchemaCache.getInstance().getFromCache(aCacheKey);
}
Also used : PSBoundSchemaCacheKey(com.helger.schematron.pure.bound.PSBoundSchemaCacheKey) AbstractMemoryReadableResource(com.helger.commons.io.resource.inmemory.AbstractMemoryReadableResource) SchematronException(com.helger.schematron.SchematronException) IPSErrorHandler(com.helger.schematron.pure.errorhandler.IPSErrorHandler) IReadableResource(com.helger.commons.io.resource.IReadableResource) Nonnull(javax.annotation.Nonnull)

Aggregations

IReadableResource (com.helger.commons.io.resource.IReadableResource)1 AbstractMemoryReadableResource (com.helger.commons.io.resource.inmemory.AbstractMemoryReadableResource)1 SchematronException (com.helger.schematron.SchematronException)1 PSBoundSchemaCacheKey (com.helger.schematron.pure.bound.PSBoundSchemaCacheKey)1 IPSErrorHandler (com.helger.schematron.pure.errorhandler.IPSErrorHandler)1 Nonnull (javax.annotation.Nonnull)1