// Only consider options visible from the current namespace.
Options visibleOptions
= controllerState.getVisibleOptions();
for (Option option : visibleOptions.values())
{
QualifiedName qualifiedName = option.getQualifiedName();
context.put(qualifiedName.getName(), option.getValue());
}
log.debug("Put options in context " + visibleOptions.keySet());
}
else
{
log.debug("options in context are disabled");
}
SourceElement sourceElement = controllerState.getSourceElement();
if (sourceAttributesInContext)
{
Set<String> attributes = sourceElement.getAttributeNames();
for (String key : attributes)
{
Object value = sourceElement.getAttribute(key);
if (key == null)
{
// The null key cannot be accessed in the context.
// So if the attribute NULL_KEY_CONTEXT_NAME does not
// exist, use this as attribute name.
if (sourceElement.getAttributeNames().contains(
NULL_KEY_CONTEXT_NAME))
{
continue;
}
key = NULL_KEY_CONTEXT_NAME;
}
context.put(key, value);
}
log.debug("Put attributes in context " + attributes);
}
else
{
log.debug("source attributes in context are disabled");
}
if (variablesInContext)
{
// Only consider variables visible from the namespace
// of this outlet. If a name exists in different
// namespaces visible from this namespace,
// only consider the most significant name.
Namespace namespace = getName().getNamespace();
VariableStore variableStore
= controllerState.getVariableStore();
QualifiedNameMap<Variable> visibleVariables
= variableStore
.getContent()
.getInHierarchy(namespace);
for (Variable variable : visibleVariables.values())
{
QualifiedName qualifiedName = variable.getName();
context.put(
qualifiedName.getName(),
variable.getValue());
}
log.debug("Put variables in context "
+ visibleVariables.keySet());
}