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 classDefaultBindingConfiguration.MetaschemaBindingConfiguration
-
Constructor Summary
Constructors Constructor Description DefaultBindingConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultBindingConfiguration.MetaschemaBindingConfigurationaddMetaschemaBindingConfiguration(String moduleUri, DefaultBindingConfiguration.MetaschemaBindingConfiguration config)Set the binding configuration for the Module module located at the providedmoduleUri.voidaddModelBindingConfig(String namespace, String packageName)Binds an XML namespace, which is normally associated with one or more Module, with a provided Java package name.IDefinitionBindingConfigurationgetBindingConfigurationForDefinition(IFlagContainer definition)Retrieve the binding configuration for the provideddefinition.StringgetClassName(IFlagContainer definition)Get the Java class name for the provided field or assembly definition.StringgetClassName(IModule module)Get the Java class name for the provided Module module.protected DefaultBindingConfiguration.MetaschemaBindingConfigurationgetMetaschemaBindingConfiguration(IModule module)Get the binding configuration for the provided Module.protected DefaultBindingConfiguration.MetaschemaBindingConfigurationgetMetaschemaBindingConfiguration(String moduleUri)Get the binding configuration for the Module modulke located at the providedmoduleUri.StringgetPackageNameForModule(IModule module)Generates a Java package name for the provided Module module.protected StringgetPackageNameForNamespace(String namespace)Based on the current binding configuration, generate a Java package name for the provided namespace.StringgetQualifiedBaseClassName(IFlagContainer definition)Get the Java class name of the base class to use for the class associated with the provided definition.voidload(File file)Load the binding configuration from the providedfile.voidload(URL resource)Load the binding configuration from the providedresource.voidload(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:IBindingConfigurationGenerates a Java package name for the provided Module module.- Specified by:
getPackageNameForModulein 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
nullif there is not configuration
-
getQualifiedBaseClassName
public String getQualifiedBaseClassName(IFlagContainer definition)
Description copied from interface:IBindingConfigurationGet the Java class name of the base class to use for the class associated with the provided definition.- Specified by:
getQualifiedBaseClassNamein interfaceIBindingConfiguration- Parameters:
definition- a definition that may be built as a class- Returns:
- the name of the base class or
nullif no base class is to be used
-
getClassName
public String getClassName(IFlagContainer definition)
Description copied from interface:IBindingConfigurationGet the Java class name for the provided field or assembly definition.- Specified by:
getClassNamein 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:IBindingConfigurationGet the Java class name for the provided Module module.- Specified by:
getClassNamein 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
nullif 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
nullif 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
nullif 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
-
-