--- /dev/null
+package org.simantics.db.layer0.variable;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+abstract public class VariableMapImpl implements VariableMap {\r
+\r
+ @Override\r
+ public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {\r
+ return getVariables(graph, context, null).get(name);\r
+ }\r
+\r
+ @Override\r
+ public Map<String, Variable> getVariables(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {\r
+ \r
+ Map<String,Variable> all = getVariables(graph, context, null);\r
+ if(all.isEmpty()) return all;\r
+ \r
+ for(Map.Entry<String, Variable> entry : all.entrySet()) {\r
+ Set<String> classifications = entry.getValue().getClassifications(graph);\r
+ if(classifications.contains(classification)) {\r
+ if(map == null) map = new HashMap<String,Variable>();\r
+ map.put(entry.getKey(), entry.getValue());\r
+ }\r
+ }\r
+ \r
+ return map;\r
+ \r
+ }\r
+\r
+}\r