01: /*
02: (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved - see end of file.
04: $Id: DocumentManagerAssembler.java,v 1.6 2008/01/02 12:09:36 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.assembler.assemblers;
08:
09: import com.hp.hpl.jena.assembler.*;
10: import com.hp.hpl.jena.ontology.OntDocumentManager;
11: import com.hp.hpl.jena.rdf.model.*;
12: import com.hp.hpl.jena.util.*;
13:
14: public class DocumentManagerAssembler extends AssemblerBase {
15: public Object open(Assembler a, Resource root, Mode irrelevant) {
16: checkType(root, JA.DocumentManager);
17: OntDocumentManager result = createDocumentManager();
18: result.setMetadataSearchPath(getPath(a, root), false);
19: result.configure(ResourceUtils.reachableClosure(root), false);
20: result.setFileManager(getFileManager(a, root));
21: return result;
22: }
23:
24: private String getPath(Assembler a, Resource root) {
25: String s = getUniqueString(root, JA.policyPath);
26: return s == null ? OntDocumentManager.DEFAULT_METADATA_PATH : s;
27: }
28:
29: private FileManager getFileManager(Assembler a, Resource root) {
30: Resource fm = getUniqueResource(root, JA.fileManager);
31: return fm == null ? FileManager.get() : (FileManager) a
32: .open(fm);
33: }
34:
35: /**
36: Tests may subclass and override to supply testable objects.
37: */
38: protected OntDocumentManager createDocumentManager() {
39: return new OntDocumentManager("");
40: }
41: }
42:
43: /*
44: * (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
45: * All rights reserved.
46: *
47: * Redistribution and use in source and binary forms, with or without
48: * modification, are permitted provided that the following conditions
49: * are met:
50: * 1. Redistributions of source code must retain the above copyright
51: * notice, this list of conditions and the following disclaimer.
52: * 2. Redistributions in binary form must reproduce the above copyright
53: * notice, this list of conditions and the following disclaimer in the
54: * documentation and/or other materials provided with the distribution.
55: * 3. The name of the author may not be used to endorse or promote products
56: * derived from this software without specific prior written permission.
57: *
58: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68: */
|