X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FVariableRepository.java;h=bcb207e9e820727fa4b8368b1fe5ccae9ed877e9;hb=035118aa5f35c9e5acd1f34d22065055dfdee486;hp=ad20b95ee6c07e8ef70c4db4f7308caaa8c10f0d;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRepository.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRepository.java index ad20b95ee..bcb207e9e 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRepository.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableRepository.java @@ -1,47 +1,46 @@ -/******************************************************************************* - * 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 repository = new HashMap(); - - 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 e : repository.entrySet()) { - if(uri.startsWith(e.getKey())) { - return e.getValue().browse(graph, uri.substring(e.getKey().length())); - } - } - throw new MissingVariableException(uri); - } - - public static void clear() { - repository.clear(); - } - -} - +/******************************************************************************* + * 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 repository = new HashMap(); + + 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 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(); + } + +}