Package com.helger.xml.schema
Class SchemaCache
- java.lang.Object
-
- com.helger.commons.cache.MappedCache<KEYTYPE,KEYTYPE,VALUETYPE>
-
- 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 abstractSchemaobjects. ASchemais immutable and can therefore safely be used in multi-threaded environments.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description SchemaCache(String sSchemaTypeName, SchemaFactory aSchemaFactory, ErrorHandler aErrorHandler, LSResourceResolver aResourceResolver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SchemacreateSchema(SchemaFactory aSchemaFactory, String sSchemaTypeName, com.helger.commons.collection.impl.ICommonsList<? extends com.helger.commons.io.resource.IReadableResource> aResources)ErrorHandlergetErrorHandler()LSResourceResolvergetResourceResolver()SchemagetSchema(com.helger.commons.io.resource.IReadableResource aResource)Get a cachedSchemafrom a single resource.SchemagetSchema(com.helger.commons.io.resource.IReadableResource... aResources)Get a cachedSchemathat consists of multiple resources.SchemagetSchema(Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)Get a cachedSchemathat consists of multiple resources.SchemaFactorygetSchemaFactory()StringgetSchemaTypeName()ValidatorgetValidator(com.helger.commons.io.resource.IReadableResource aResource)Get a new validator based on theSchemathat consists of a single resource.ValidatorgetValidator(com.helger.commons.io.resource.IReadableResource... aResources)Get a new validator based on theSchemathat consists of multiple resources.ValidatorgetValidator(Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)Get a new validator based on theSchemathat consists of multiple resources.ValidatorgetValidatorFromSchema(Schema aSchema)Utility method to get the validator for a given schema using the error handler provided in the constructor.com.helger.commons.state.EChangeremoveFromCache(com.helger.commons.io.resource.IReadableResource aKey)Utility method to remove a single resource from the schema cache.StringtoString()-
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
-
-
-
-
Constructor Detail
-
SchemaCache
public SchemaCache(@Nonnull String sSchemaTypeName, @Nonnull SchemaFactory aSchemaFactory, @Nullable ErrorHandler aErrorHandler, @Nullable LSResourceResolver aResourceResolver)
-
-
Method Detail
-
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 cachedSchemafrom a single resource.
-
getSchema
@Nonnull public final Schema getSchema(@Nonnull @Nonempty com.helger.commons.io.resource.IReadableResource... aResources)
Get a cachedSchemathat consists of multiple resources.
-
getSchema
@Nonnull public final Schema getSchema(@Nonnull @Nonempty Collection<? extends com.helger.commons.io.resource.IReadableResource> aResources)
Get a cachedSchemathat consists of multiple resources.
-
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 benull.- 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 theSchemathat consists of a single resource.- Parameters:
aResource- The resource to parse into a singleSchema. May not benull.- Returns:
- A new
Validatorobject. Nevernull. - 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 theSchemathat consists of multiple resources.- Parameters:
aResources- The resources to parse into a singleSchema. May neithernullnor empty nor may it containnullelements.- Returns:
- A new
Validatorobject. Nevernull. - 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 theSchemathat consists of multiple resources.- Parameters:
aResources- The resources to parse into a singleSchema. May neithernullnor empty nor may it containnullelements.- Returns:
- A new
Validatorobject. Nevernull. - 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 benull.- Returns:
EChange.
-
toString
public String toString()
- Overrides:
toStringin classcom.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>
-
-