Class SchemaCache

java.lang.Object
com.helger.commons.cache.MappedCache<com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,Schema>
com.helger.commons.cache.Cache<com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,Schema>
com.helger.xml.schema.SchemaCache
All Implemented Interfaces:
com.helger.commons.cache.ICache<com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,Schema>, com.helger.commons.cache.IMutableCache<com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,Schema>, com.helger.commons.lang.IHasSize, com.helger.commons.name.IHasName
Direct Known Subclasses:
XMLSchemaCache

@ThreadSafe public class SchemaCache extends com.helger.commons.cache.Cache<com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,Schema>
Base class for caching abstract Schema objects. A Schema is immutable and can therefore safely be used in multi-threaded environments.
Author:
Philip Helger
  • Field Summary

    Fields inherited from class com.helger.commons.cache.Cache

    DEFAULT_ALLOW_NULL_VALUES

    Fields inherited from class com.helger.commons.cache.MappedCache

    m_aRWLock, NO_MAX_SIZE, STATISTICS_PREFIX
  • Constructor Summary

    Constructors
    Constructor
    Description
    SchemaCache(String sSchemaTypeName, SchemaFactory aSchemaFactory, ErrorHandler aErrorHandler, LSResourceResolver aResourceResolver)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Schema
    createSchema(SchemaFactory aSchemaFactory, String sSchemaTypeName, com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource> aResources)
     
     
     
    final Schema
    getSchema(com.helger.commons.io.resource.IReadableResource aResource)
    Get a cached Schema from a single resource.
    final Schema
    getSchema(com.helger.commons.io.resource.IReadableResource... aResources)
    Get a cached Schema that consists of multiple resources.
    final Schema
    getSchema(Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)
    Get a cached Schema that consists of multiple resources.
     
    final String
     
    final Validator
    getValidator(com.helger.commons.io.resource.IReadableResource aResource)
    Get a new validator based on the Schema that consists of a single resource.
    final Validator
    getValidator(com.helger.commons.io.resource.IReadableResource... aResources)
    Get a new validator based on the Schema that consists of multiple resources.
    final Validator
    getValidator(Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)
    Get a new validator based on the Schema that consists of multiple resources.
    final Validator
    Utility method to get the validator for a given schema using the error handler provided in the constructor.
    com.helger.commons.state.EChange
    removeFromCache(com.helger.commons.io.resource.IReadableResource aKey)
    Utility method to remove a single resource from the schema cache.
     

    Methods inherited from class com.helger.commons.cache.MappedCache

    clearCache, createCache, getCacheKeyProvider, getFromCache, getFromCacheNoStats, getFromCacheNoStatsNotLocked, getMaxSize, getName, getValueProvider, hasMaxSize, isAllowNullValues, isEmpty, isInCache, isNotEmpty, putInCache, putInCacheNotLocked, removeFromCache, size

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • getSchemaTypeName

      @Nonnull public final String getSchemaTypeName()
    • getSchemaFactory

      @Nonnull public final SchemaFactory getSchemaFactory()
    • getErrorHandler

      @Nullable public ErrorHandler getErrorHandler()
    • getResourceResolver

      @Nullable public LSResourceResolver getResourceResolver()
    • createSchema

      @Nonnull public static Schema createSchema(@Nonnull SchemaFactory aSchemaFactory, @Nonnull String sSchemaTypeName, @Nonnull @Nonempty com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource> aResources)
    • getSchema

      @Nonnull public final Schema getSchema(@Nonnull com.helger.commons.io.resource.IReadableResource aResource)
      Get a cached Schema from a single resource.
      Parameters:
      aResource - The resource to parse into a Schema. May not be null.
      Returns:
      Either the Schema from the cache or the newly compiled one.
    • getSchema

      @Nonnull public final Schema getSchema(@Nonnull @Nonempty com.helger.commons.io.resource.IReadableResource... aResources)
      Get a cached Schema that consists of multiple resources.
      Parameters:
      aResources - The resources to parse into a single Schema. May neither null nor empty nor may it contain null elements.
      Returns:
      Either the Schema from the cache or the newly compiled one.
    • getSchema

      @Nonnull public final Schema getSchema(@Nonnull @Nonempty Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)
      Get a cached Schema that consists of multiple resources.
      Parameters:
      aResources - The resources to parse into a single Schema. May neither null nor empty nor may it contain null elements.
      Returns:
      Either the Schema from the cache or the newly compiled one.
    • getValidatorFromSchema

      @Nonnull public final Validator getValidatorFromSchema(@Nonnull Schema aSchema)
      Utility method to get the validator for a given schema using the error handler provided in the constructor.
      Parameters:
      aSchema - The schema for which the validator is to be retrieved. May not be null.
      Returns:
      The validator and never null.
    • getValidator

      @Nonnull public final Validator getValidator(@Nonnull com.helger.commons.io.resource.IReadableResource aResource)
      Get a new validator based on the Schema that consists of a single resource.
      Parameters:
      aResource - The resource to parse into a single Schema. May not be null.
      Returns:
      A new Validator object. Never null.
      See Also:
    • getValidator

      @Nonnull public final Validator getValidator(@Nonnull @Nonempty com.helger.commons.io.resource.IReadableResource... aResources)
      Get a new validator based on the Schema that consists of multiple resources.
      Parameters:
      aResources - The resources to parse into a single Schema. May neither null nor empty nor may it contain null elements.
      Returns:
      A new Validator object. Never null.
      See Also:
    • getValidator

      @Nonnull public final Validator getValidator(@Nonnull @Nonempty Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)
      Get a new validator based on the Schema that consists of multiple resources.
      Parameters:
      aResources - The resources to parse into a single Schema. May neither null nor empty nor may it contain null elements.
      Returns:
      A new Validator object. Never null.
      See Also:
    • removeFromCache

      @Nonnull public com.helger.commons.state.EChange removeFromCache(@Nonnull com.helger.commons.io.resource.IReadableResource aKey)
      Utility method to remove a single resource from the schema cache.
      Parameters:
      aKey - The resource to remove. May not be null.
      Returns:
      EChange.
    • toString

      public String toString()
      Overrides:
      toString in class com.helger.commons.cache.MappedCache<com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource>,Schema>