Package org.incenp.obofoundry.sssom
Class ExtensionSlotManager
java.lang.Object
org.incenp.obofoundry.sssom.ExtensionSlotManager
A helper class to deal with non-standard metadata slots and their
definitions.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance without a prefix manager.ExtensionSlotManager(ExtraMetadataPolicy policy, PrefixManager prefixManager) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDefinition(String slotName, String property, String typeHint) Defines a new extension slot.voidGets definitions for all extensions used in the specified mapping set.getDefinitionForProperty(String property) Looks up for an existing definition for the specified property.getDefinitionForSlot(String slotName) Looks up for an existing definition for the specified slot name.getDefinitions(boolean sorted, boolean mappingLevelOnly) Gets the definitions known to this manager.Gets all the prefix names used in extensions and extension definitions.booleanisEmpty()Indicates whether this object contains any extension definition.static booleanChecks whether the specified name is usable as an extension slot name.
-
Field Details
-
UNDEFINED_EXTENSION_NAMESPACE
The default namespace for auto-generated properties for undefined extensions.- See Also:
-
DEFAULT_TYPE_HINT
The default type for extensions that are either undefined or that do not have an explicit type.
-
-
Constructor Details
-
ExtensionSlotManager
Creates a new instance without a prefix manager. Such an instance can be used when working with full-length identifiers only.- Parameters:
policy- The policy that determines how to deal with non-standard metadata slots. When the policy is set toExtraMetadataPolicy.NONE, most operations of this object are no-op.
-
ExtensionSlotManager
Creates a new instance.- Parameters:
policy- The policy that determines how to deal with non-standard metadata slots. When the policy is set toExtraMetadataPolicy.NONE, most operations of this object are no-op.prefixManager- The prefix manager used to resolve any compact IRI encountered in extension definitions.
-
-
Method Details
-
addDefinition
Defines a new extension slot.- Parameters:
slotName- The name of the slot, as it appears in the YAML metadata block (for set-level extensions) or as a column header (for mapping-level extensions).property- The property associated with the slot.typeHint- The expected type of values for this slot. May benull, in which case the default isxsd:string.- Returns:
trueif the new slot has been defined correctly. orfalseif either theslot_nameor thepropertyisnull, or if the slot name is invalid.
-
getDefinitionForSlot
Looks up for an existing definition for the specified slot name. If no definition exists and the policy is set toExtraMetadataPolicy.UNDEFINED, then a new definition is automatically generated on the fly.- Parameters:
slotName- The name of the slot for which a definition is requested.- Returns:
- The slot definition. May be
nullif the policy is set toExtraMetadataPolicy.NONE, or if it is set toExtraMetadataPolicy.DEFINEDand no prior definition exists.
-
getDefinitionForProperty
Looks up for an existing definition for the specified property.- Parameters:
property- The property of the slot for which a definition is requested.- Returns:
- The slot definition. May be
nullif the policy is set toExtraMetadataPolicy.NONE, or if no definition for the specified property exists.
-
fillFromExistingExtensions
Gets definitions for all extensions used in the specified mapping set. Existing definitions found in the set itself will be used when available, otherwise definitions will be auto-generated when needed. Note that existing definitions in the set that are never used throughout the set are ignored.- Parameters:
ms- The mapping set to get extension definitions from.
-
getUsedPrefixes
Gets all the prefix names used in extensions and extension definitions.When this object is initialised from a mapping set (through
fillFromExistingExtensions(MappingSet)), all prefix names used throughout all extension values and all extension definition will be collected. This allows to know which prefixes are required to compact all IRIs present in extensions. The prefix names are those from the prefix manager used by this object.- Returns:
- The set of all prefix names used in extensions.
-
isEmpty
public boolean isEmpty()Indicates whether this object contains any extension definition.- Returns:
trueif this object knows of no extension, otherwisetrue.
-
isExtensionSlotNameValid
Checks whether the specified name is usable as an extension slot name.- Parameters:
name- The name to check.- Returns:
trueif the name is a valid extension slot name,falseotherwise.
-
getDefinitions
Gets the definitions known to this manager.- Parameters:
sorted-trueto get a list where the definitions are sorted on their properties; iffalse, the order of definitions in the returned list is unspecified.mappingLevelOnly- Iftrue, returns only the definitions for extensions that are used at the mapping level, excluding any definition for extensions that are only found at the set level; otherwise, returns all definitions.- Returns:
- The list of definitions. This is a copy of the internal list, any change on the returned list will not affect the state of this object.
-