-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.db.layer0.variable;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.exception.MissingVariableException;\r
-\r
-final public class VariableRepository {\r
-\r
- final private static HashMap<String, Variable> repository = new HashMap<String, Variable>(); \r
- \r
- public static synchronized void register(String uri, Variable variable) {\r
- repository.put(uri, variable);\r
- }\r
-\r
- public static synchronized void unregister(String uri) {\r
- repository.remove(uri);\r
- }\r
-\r
- public static synchronized Variable get(ReadGraph graph, String uri) throws DatabaseException {\r
- for(Map.Entry<String, Variable> e : repository.entrySet()) {\r
- if(uri.startsWith(e.getKey())) {\r
- return e.getValue().browse(graph, uri.substring(e.getKey().length()));\r
- }\r
- }\r
- throw new MissingVariableException(uri);\r
- }\r
- \r
- public static void clear() {\r
- repository.clear();\r
- }\r
- \r
-}\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.layer0.variable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.MissingVariableException;
+
+final public class VariableRepository {
+
+ final private static HashMap<String, Variable> repository = new HashMap<String, Variable>();
+
+ public static synchronized void register(String uri, Variable variable) {
+ repository.put(uri, variable);
+ }
+
+ public static synchronized void unregister(String uri) {
+ repository.remove(uri);
+ }
+
+ public static synchronized Variable get(ReadGraph graph, String uri) throws DatabaseException {
+ for(Map.Entry<String, Variable> e : repository.entrySet()) {
+ if(uri.startsWith(e.getKey())) {
+ return e.getValue().browse(graph, uri.substring(e.getKey().length()));
+ }
+ }
+ throw new MissingVariableException(uri, null);
+ }
+
+ public static void clear() {
+ repository.clear();
+ }
+
+}