KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > enhanced > BuiltinPersonalities


1 /*
2   (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: BuiltinPersonalities.java,v 1.31 2005/02/21 12:03:37 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.enhanced;
8 import com.hp.hpl.jena.rdf.model.*;
9 import com.hp.hpl.jena.rdf.model.impl.*;
10 import com.hp.hpl.jena.ontology.*;
11 import com.hp.hpl.jena.ontology.daml.*;
12 import com.hp.hpl.jena.ontology.daml.impl.*;
13 import com.hp.hpl.jena.ontology.impl.*;
14
15 import java.io.*;
16 import java.util.*;
17
18 /**
19     The personailities that are provided for the existing Jena classes. It is likely that this
20     should be factored.
21     
22     @author jjc + kers
23 */

24 public class BuiltinPersonalities {
25
26     static final private GraphPersonality graph = new GraphPersonality();
27
28     static final public GraphPersonality model = (GraphPersonality)graph.copy()
29         .add( Resource.class, ResourceImpl.factory )
30         .add( Property.class, PropertyImpl.factory )
31         .add( Literal.class,LiteralImpl.factory )
32         .add( Container.class, ContainerImpl.factory )
33         .add( Alt.class, AltImpl.factory )
34         .add( Bag.class, BagImpl.factory )
35         .add( Seq.class, SeqImpl.factory )
36         .add( ReifiedStatement.class, ReifiedStatementImpl.reifiedStatementFactory )
37         .add( RDFList.class, RDFListImpl.factory )
38         
39         // ontology additions
40
.add( OntResource.class, OntResourceImpl.factory )
41         .add( Ontology.class, OntologyImpl.factory )
42         .add( OntClass.class, OntClassImpl.factory )
43         .add( EnumeratedClass.class, EnumeratedClassImpl.factory )
44         .add( IntersectionClass.class, IntersectionClassImpl.factory )
45         .add( UnionClass.class, UnionClassImpl.factory )
46         .add( ComplementClass.class, ComplementClassImpl.factory )
47         .add( DataRange.class, DataRangeImpl.factory )
48         
49         .add( Restriction.class, RestrictionImpl.factory )
50         .add( HasValueRestriction.class, HasValueRestrictionImpl.factory )
51         .add( AllValuesFromRestriction.class, AllValuesFromRestrictionImpl.factory )
52         .add( SomeValuesFromRestriction.class, SomeValuesFromRestrictionImpl.factory )
53         .add( CardinalityRestriction.class, CardinalityRestrictionImpl.factory )
54         .add( MinCardinalityRestriction.class, MinCardinalityRestrictionImpl.factory )
55         .add( MaxCardinalityRestriction.class, MaxCardinalityRestrictionImpl.factory )
56         .add( QualifiedRestriction.class, QualifiedRestrictionImpl.factory )
57         .add( MinCardinalityQRestriction.class, MinCardinalityQRestrictionImpl.factory )
58         .add( MaxCardinalityQRestriction.class, MaxCardinalityQRestrictionImpl.factory )
59         .add( CardinalityQRestriction.class, CardinalityQRestrictionImpl.factory )
60     
61         .add( OntProperty.class, OntPropertyImpl.factory )
62         .add( ObjectProperty.class, ObjectPropertyImpl.factory )
63         .add( DatatypeProperty.class, DatatypePropertyImpl.factory )
64         .add( TransitiveProperty.class, TransitivePropertyImpl.factory )
65         .add( SymmetricProperty.class, SymmetricPropertyImpl.factory )
66         .add( FunctionalProperty.class, FunctionalPropertyImpl.factory )
67         .add( InverseFunctionalProperty.class, InverseFunctionalPropertyImpl.factory )
68         .add( AllDifferent.class, AllDifferentImpl.factory )
69         .add( Individual.class, IndividualImpl.factory )
70         .add( AnnotationProperty.class, AnnotationPropertyImpl.factory )
71         
72         // daml
73
.add( DAMLCommon.class, DAMLCommonImpl.factory )
74         .add( DAMLClass.class, DAMLClassImpl.factory )
75         .add( DAMLRestriction.class, DAMLRestrictionImpl.factory )
76         .add( DAMLProperty.class, DAMLPropertyImpl.factory )
77         .add( DAMLObjectProperty.class, DAMLObjectPropertyImpl.factory )
78         .add( DAMLDatatypeProperty.class, DAMLDatatypePropertyImpl.factory )
79         .add( DAMLOntology.class, DAMLOntologyImpl.factory )
80         .add( DAMLInstance.class, DAMLInstanceImpl.factory )
81         .add( DAMLList.class, DAMLListImpl.factory )
82         .add( DAMLDataInstance.class, DAMLDataInstanceImpl.factory )
83         .add( DAMLDatatype.class, DAMLDatatypeImpl.factory )
84         
85         // Last and least ?
86
.add( RDFNode.class, ResourceImpl.rdfNodeFactory )
87         ;
88         
89         
90     /**
91      * For debugging purposes, list the standard personalities on the given
92      * output writer.
93      *
94      * @param writer A printwriter to list the personalities mapping to
95      */

96     static public void listPersonalities( PrintWriter writer ) {
97         for (Iterator i = model.nodePersonality().getMap().entrySet().iterator(); i.hasNext(); ) {
98             Map.Entry e = (Map.Entry) i.next();
99             
100             writer.println( "personality key " + ((Class JavaDoc) e.getKey()).getName() + " -> value " + e.getValue() );
101         }
102         
103         writer.flush();
104     }
105 }
106
107 /*
108     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
109     All rights reserved.
110
111     Redistribution and use in source and binary forms, with or without
112     modification, are permitted provided that the following conditions
113     are met:
114
115     1. Redistributions of source code must retain the above copyright
116        notice, this list of conditions and the following disclaimer.
117
118     2. Redistributions in binary form must reproduce the above copyright
119        notice, this list of conditions and the following disclaimer in the
120        documentation and/or other materials provided with the distribution.
121
122     3. The name of the author may not be used to endorse or promote products
123        derived from this software without specific prior written permission.
124
125     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
126     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
127     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
128     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
129     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
130     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
131     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
132     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
133     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
134     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
135 */

136
Popular Tags