Class SchemaBuilder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.xml.SchemaBuilder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSchemaBuilder.SchemaLanguageLanguage of the schema files.
-
Field Summary
Fields Modifier and Type Field Description private booleanalreadyBuiltOne time-init flag.private ErrorHandlererrorHandlerCustom error handler.private Map<String,Boolean>featuresFeatures to set on factory.private org.slf4j.LoggerlogClass logger.private Map<String,Object>propertiesProperties to set on factory.private LSResourceResolverresourceResolverMechanism for resolving nested resources like included/imported schemas.private SchemaBuilder.SchemaLanguageschemaLangLanguage of schemas.private List<Source>sourcesSources of schema material compatible with JAXP.
-
Constructor Summary
Constructors Constructor Description SchemaBuilder()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaBuilderaddSchema(InputStream schemaSource)Add schemas from the given schema input streams.SchemaBuilderaddSchema(Source schemaSource)Add schemas from the given schema sources.SchemaBuilderaddSchema(Resource resource)Add schemas from the given schema resource.SchemabuildSchema()Build a schema from the given schema sources.SchemaBuilderresetSchemas()Clear the schemas to be included.SchemaBuildersetErrorHandler(ErrorHandler handler)Set a custom error handler to use.voidsetFeature(String name, boolean value)Set a feature for theSchemaFactoryto be built.voidsetProperty(String name, Object object)Set the value of a property for theSchemaFactoryto be built.SchemaBuildersetResourceResolver(LSResourceResolver resolver)Set the resource resolver to use for included/imported schemas.SchemaBuildersetSchemaLanguage(SchemaBuilder.SchemaLanguage lang)Set the schema language.voidsetSchemaResources(Collection<Resource> schemaResources)Set the schemas to load from the given schema resources (replaces any previously added).voidsetSchemas(Collection<Source> schemaSources)Set the schemas to load from the given schema sources (replaces any previously added).
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
schemaLang
@Nonnull private SchemaBuilder.SchemaLanguage schemaLang
Language of schemas.
-
sources
@Nonnull @NonnullElements private List<Source> sources
Sources of schema material compatible with JAXP.
-
resourceResolver
@Nullable private LSResourceResolver resourceResolver
Mechanism for resolving nested resources like included/imported schemas.
-
errorHandler
@Nullable private ErrorHandler errorHandler
Custom error handler.
-
alreadyBuilt
private boolean alreadyBuilt
One time-init flag.
-
-
Method Detail
-
setSchemaLanguage
@Nonnull public SchemaBuilder setSchemaLanguage(@Nonnull SchemaBuilder.SchemaLanguage lang)
Set the schema language.- Parameters:
lang- the schema language- Returns:
- this builder
-
setResourceResolver
@Nonnull public SchemaBuilder setResourceResolver(@Nullable LSResourceResolver resolver)
Set the resource resolver to use for included/imported schemas.If not set, the default resolver will prevent lookup of any schemas not explicitly added.
- Parameters:
resolver- resource resolver- Returns:
- this builder
-
setErrorHandler
@Nonnull public SchemaBuilder setErrorHandler(@Nullable ErrorHandler handler)
Set a custom error handler to use.If not set, a default handler will be used that logs errors before throwing exceptions.
- Parameters:
handler- error handler- Returns:
- this builder
-
setFeature
public void setFeature(@Nonnull @NotEmpty String name, boolean value)
Set a feature for theSchemaFactoryto be built.- Parameters:
name- The feature name, which is a non-null fully-qualified URI.value- The requested value of the feature (true or false).- See Also:
SchemaFactory.setFeature(String, boolean)
-
setProperty
public void setProperty(@Nonnull @NotEmpty String name, @Nullable Object object)
Set the value of a property for theSchemaFactoryto be built.- Parameters:
name- The property name, which is a non-null fully-qualified URI.object- The requested value for the property.- See Also:
SchemaFactory.setProperty(String, Object)
-
resetSchemas
@Nonnull public SchemaBuilder resetSchemas()
Clear the schemas to be included.- Returns:
- this builder
-
setSchemas
public void setSchemas(@Nonnull @NullableElements Collection<Source> schemaSources)
Set the schemas to load from the given schema sources (replaces any previously added).If the caller wishes to ensure the schemas are loaded in a particular order, the
Collectionimplementation provided must be one that preserves order. The method will add the sources in the order returned by the collection.- Parameters:
schemaSources- schema sources
-
setSchemaResources
public void setSchemaResources(@Nonnull @NullableElements Collection<Resource> schemaResources)
Set the schemas to load from the given schema resources (replaces any previously added).If the caller wishes to ensure the schemas are loaded in a particular order, the
Collectionimplementation provided must be one that preserves order. The method will add the sources in the order returned by the collection.- Parameters:
schemaResources- schema resources
-
addSchema
@Nonnull public SchemaBuilder addSchema(@Nonnull InputStream schemaSource)
Add schemas from the given schema input streams.- Parameters:
schemaSource- schema input stream- Returns:
- this builder
-
addSchema
@Nonnull public SchemaBuilder addSchema(@Nonnull Source schemaSource)
Add schemas from the given schema sources.- Parameters:
schemaSource- schema source- Returns:
- this builder
-
addSchema
@Nonnull public SchemaBuilder addSchema(@Nonnull Resource resource)
Add schemas from the given schema resource.- Parameters:
resource- schema input resource- Returns:
- this builder
-
buildSchema
@Nonnull public Schema buildSchema() throws SAXException
Build a schema from the given schema sources.This method is thread-safe, although the various mutating methods to establish the state of the object are not.
- Returns:
- the constructed schema
- Throws:
SAXException- thrown if there is a problem converting the schema sources into a schema
-
-