Set metadata
We can set metadata on all modifiable instances that implement the ModifiableMetaDataProvider interface.
- Obtain a modifiable instance of the resource for which to set metadata.
- Check whether the resource implements the ModifiableMetaDataProvider interface.
Use the operator instanceof. If the resource does not implement the ModifiableMetaDataProvider interface, we cannot modify it.
- Obtain a modifiable instance of the metadata of the resource.
- Set the metadata using, for example, the setValue method.
Set metadata for a resource:
final Modifiable modifiable = controller.getModifiableNode(node); if (modifiable instanceof ModifiableMetaDataProvider) { final ModifiableMetaData modifiableMetaData = ((ModifiableMetaDataProvider) modifiable).getModifiableMetaData(); modifiableMetaData.setValue("MyKey", "MyValue"); }
Parent Modify properties