Class 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
    • Method Detail

      • getSchemaTypeName

        @Nonnull
        public final String getSchemaTypeName()
      • 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:
        getSchema(IReadableResource)
      • 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:
        getSchema(IReadableResource...)
      • 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:
        getSchema(Collection)
      • 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>