01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.nativerdf.config;
07:
08: import org.openrdf.sail.Sail;
09: import org.openrdf.sail.config.SailConfigException;
10: import org.openrdf.sail.config.SailFactory;
11: import org.openrdf.sail.config.SailImplConfig;
12: import org.openrdf.sail.nativerdf.NativeStore;
13:
14: /**
15: * A {@link SailFactory} that creates {@link NativeStore}s based on RDF
16: * configuration data.
17: *
18: * @author Arjohn Kampman
19: */
20: public class NativeStoreFactory implements SailFactory {
21:
22: /**
23: * The type of repositories that are created by this factory.
24: *
25: * @see SailFactory#getSailType()
26: */
27: public static final String SAIL_TYPE = "openrdf:NativeStore";
28:
29: /**
30: * Returns the Sail's type: <tt>openrdf:NativeStore</tt>.
31: */
32: public String getSailType() {
33: return SAIL_TYPE;
34: }
35:
36: public SailImplConfig getConfig() {
37: return new NativeStoreConfig();
38: }
39:
40: public Sail getSail(SailImplConfig config)
41: throws SailConfigException {
42: if (!SAIL_TYPE.equals(config.getType())) {
43: throw new SailConfigException("Invalid Sail type: "
44: + config.getType());
45: }
46:
47: NativeStore nativeStore = new NativeStore();
48:
49: if (config instanceof NativeStoreConfig) {
50: NativeStoreConfig nativeConfig = (NativeStoreConfig) config;
51: nativeStore.setTripleIndexes(nativeConfig
52: .getTripleIndexes());
53: }
54:
55: return nativeStore;
56: }
57: }
|