Class DefaultBindingConfiguration
- java.lang.Object
-
- gov.nist.secauto.metaschema.databind.codegen.config.DefaultBindingConfiguration
-
- All Implemented Interfaces:
IBindingConfiguration
public class DefaultBindingConfiguration extends Object implements IBindingConfiguration
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultBindingConfiguration.MetaschemaBindingConfiguration
-
Constructor Summary
Constructors Constructor Description DefaultBindingConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultBindingConfiguration.MetaschemaBindingConfiguration
addMetaschemaBindingConfiguration(String moduleUri, DefaultBindingConfiguration.MetaschemaBindingConfiguration config)
Set the binding configuration for the Module module located at the providedmoduleUri
.void
addModelBindingConfig(String namespace, String packageName)
Binds an XML namespace, which is normally associated with one or more Module, with a provided Java package name.IDefinitionBindingConfiguration
getBindingConfigurationForDefinition(IFlagContainer definition)
Retrieve the binding configuration for the provideddefinition
.String
getClassName(IFlagContainer definition)
Get the Java class name for the provided field or assembly definition.String
getClassName(IModule module)
Get the Java class name for the provided Module module.protected DefaultBindingConfiguration.MetaschemaBindingConfiguration
getMetaschemaBindingConfiguration(IModule module)
Get the binding configuration for the provided Module.protected DefaultBindingConfiguration.MetaschemaBindingConfiguration
getMetaschemaBindingConfiguration(String moduleUri)
Get the binding configuration for the Module modulke located at the providedmoduleUri
.String
getPackageNameForModule(IModule module)
Generates a Java package name for the provided Module module.protected String
getPackageNameForNamespace(String namespace)
Based on the current binding configuration, generate a Java package name for the provided namespace.String
getQualifiedBaseClassName(IFlagContainer definition)
Get the Java class name of the base class to use for the class associated with the provided definition.void
load(File file)
Load the binding configuration from the providedfile
.void
load(URL resource)
Load the binding configuration from the providedresource
.void
load(Path file)
Load the binding configuration from the providedfile
.
-
-
-
Constructor Detail
-
DefaultBindingConfiguration
public DefaultBindingConfiguration()
-
-
Method Detail
-
getPackageNameForModule
public String getPackageNameForModule(IModule module)
Description copied from interface:IBindingConfiguration
Generates a Java package name for the provided Module module.- Specified by:
getPackageNameForModule
in interfaceIBindingConfiguration
- Parameters:
module
- the Module module to generate a package name for- Returns:
- a Java package name
-
getBindingConfigurationForDefinition
@Nullable public IDefinitionBindingConfiguration getBindingConfigurationForDefinition(@NonNull IFlagContainer definition)
Retrieve the binding configuration for the provideddefinition
.- Parameters:
definition
- the definition to get the config for- Returns:
- the binding configuration or
null
if there is not configuration
-
getQualifiedBaseClassName
public String getQualifiedBaseClassName(IFlagContainer definition)
Description copied from interface:IBindingConfiguration
Get the Java class name of the base class to use for the class associated with the provided definition.- Specified by:
getQualifiedBaseClassName
in interfaceIBindingConfiguration
- Parameters:
definition
- a definition that may be built as a class- Returns:
- the name of the base class or
null
if no base class is to be used
-
getClassName
public String getClassName(IFlagContainer definition)
Description copied from interface:IBindingConfiguration
Get the Java class name for the provided field or assembly definition.- Specified by:
getClassName
in interfaceIBindingConfiguration
- Parameters:
definition
- the definition to generate the Java class name for- Returns:
- a Java class name
-
getClassName
@NonNull public String getClassName(@NonNull IModule module)
Description copied from interface:IBindingConfiguration
Get the Java class name for the provided Module module.- Specified by:
getClassName
in interfaceIBindingConfiguration
- Parameters:
module
- the Module module to generate the Java class name for- Returns:
- a Java class name
-
addModelBindingConfig
public void addModelBindingConfig(String namespace, String packageName)
Binds an XML namespace, which is normally associated with one or more Module, with a provided Java package name.- Parameters:
namespace
- an XML namespace URIpackageName
- the package name to associate with the namespace- Throws:
IllegalStateException
- if the binding configuration is changing a previously changed namespace to package binding
-
getPackageNameForNamespace
@NonNull protected String getPackageNameForNamespace(@NonNull String namespace)
Based on the current binding configuration, generate a Java package name for the provided namespace. If the namespace is already mapped, such as through the use ofaddModelBindingConfig(String, String)
, then the provided package name will be used. If the namespace is not mapped, then the namespace URI will be translated into a Java package name.- Parameters:
namespace
- the namespace to generate a Java package name for- Returns:
- a Java package name
-
getMetaschemaBindingConfiguration
protected DefaultBindingConfiguration.MetaschemaBindingConfiguration getMetaschemaBindingConfiguration(@NonNull IModule module)
Get the binding configuration for the provided Module.- Parameters:
module
- the Module module- Returns:
- the configuration for the Module or
null
if there is no configuration
-
getMetaschemaBindingConfiguration
@Nullable protected DefaultBindingConfiguration.MetaschemaBindingConfiguration getMetaschemaBindingConfiguration(@NonNull String moduleUri)
Get the binding configuration for the Module modulke located at the providedmoduleUri
.- Parameters:
moduleUri
- the location of the Module module- Returns:
- the configuration for the Module module or
null
if there is no configuration
-
addMetaschemaBindingConfiguration
public DefaultBindingConfiguration.MetaschemaBindingConfiguration addMetaschemaBindingConfiguration(@NonNull String moduleUri, @NonNull DefaultBindingConfiguration.MetaschemaBindingConfiguration config)
Set the binding configuration for the Module module located at the providedmoduleUri
.- Parameters:
moduleUri
- the location of the Module moduleconfig
- the Module binding configuration- Returns:
- the old configuration for the Module module or
null
if there was no previous configuration
-
load
public void load(Path file) throws IOException
Load the binding configuration from the providedfile
.- Parameters:
file
- the configuration resource- Throws:
IOException
- if an error occurred while reading thefile
-
load
public void load(File file) throws IOException
Load the binding configuration from the providedfile
.- Parameters:
file
- the configuration resource- Throws:
IOException
- if an error occurred while reading thefile
-
load
public void load(URL resource) throws IOException
Load the binding configuration from the providedresource
.- Parameters:
resource
- the configuration resource- Throws:
IOException
- if an error occurred while reading theresource
-
-