+

Search Tips   |   Advanced Search

Set metadata

We can set metadata on all modifiable instances that implement the ModifiableMetaDataProvider interface.

  1. Obtain a modifiable instance of the resource for which to set metadata.

  2. 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.

  3. Obtain a modifiable instance of the metadata of the resource.

  4. 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