1 package org.simantics.db.layer0.variable;
3 import java.util.HashMap;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.exception.DatabaseException;
10 abstract public class VariableMapImpl implements VariableMap {
13 public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
14 return getVariables(graph, context, null).get(name);
18 public Map<String, Variable> getVariables(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
20 Map<String,Variable> all = getVariables(graph, context, null);
21 if(all.isEmpty()) return all;
23 for(Map.Entry<String, Variable> entry : all.entrySet()) {
24 Set<String> classifications = entry.getValue().getClassifications(graph);
25 if(classifications.contains(classification)) {
26 if(map == null) map = new HashMap<String,Variable>();
27 map.put(entry.getKey(), entry.getValue());