001: /*
002: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: BuiltinPersonalities.java,v 1.35 2008/01/02 12:09:12 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.enhanced;
008:
009: import java.io.PrintWriter;
010: import java.util.Iterator;
011: import java.util.Map;
012:
013: import com.hp.hpl.jena.ontology.*;
014: import com.hp.hpl.jena.ontology.impl.*;
015: import com.hp.hpl.jena.rdf.model.*;
016: import com.hp.hpl.jena.rdf.model.impl.*;
017:
018: /**
019: The personalities that are provided for the existing Jena classes. It is likely that this
020: should be factored.
021:
022: @author jjc + kers
023: */
024: public class BuiltinPersonalities {
025:
026: static final private GraphPersonality graph = new GraphPersonality();
027:
028: static final public GraphPersonality model = (GraphPersonality) graph
029: .copy()
030: .add(Resource.class, ResourceImpl.factory)
031: .add(Property.class, PropertyImpl.factory)
032: .add(Literal.class, LiteralImpl.factory)
033: .add(Container.class, ContainerImpl.factory)
034: .add(Alt.class, AltImpl.factory)
035: .add(Bag.class, BagImpl.factory)
036: .add(Seq.class, SeqImpl.factory)
037: .add(ReifiedStatement.class,
038: ReifiedStatementImpl.reifiedStatementFactory)
039: .add(RDFList.class, RDFListImpl.factory)
040:
041: // ontology additions
042: .add(OntResource.class, OntResourceImpl.factory)
043: .add(Ontology.class, OntologyImpl.factory)
044: .add(OntClass.class, OntClassImpl.factory)
045: .add(EnumeratedClass.class, EnumeratedClassImpl.factory)
046: .add(IntersectionClass.class, IntersectionClassImpl.factory)
047: .add(UnionClass.class, UnionClassImpl.factory).add(
048: ComplementClass.class, ComplementClassImpl.factory)
049: .add(DataRange.class, DataRangeImpl.factory)
050:
051: .add(Restriction.class, RestrictionImpl.factory).add(
052: HasValueRestriction.class,
053: HasValueRestrictionImpl.factory).add(
054: AllValuesFromRestriction.class,
055: AllValuesFromRestrictionImpl.factory).add(
056: SomeValuesFromRestriction.class,
057: SomeValuesFromRestrictionImpl.factory).add(
058: CardinalityRestriction.class,
059: CardinalityRestrictionImpl.factory).add(
060: MinCardinalityRestriction.class,
061: MinCardinalityRestrictionImpl.factory).add(
062: MaxCardinalityRestriction.class,
063: MaxCardinalityRestrictionImpl.factory).add(
064: QualifiedRestriction.class,
065: QualifiedRestrictionImpl.factory).add(
066: MinCardinalityQRestriction.class,
067: MinCardinalityQRestrictionImpl.factory).add(
068: MaxCardinalityQRestriction.class,
069: MaxCardinalityQRestrictionImpl.factory).add(
070: CardinalityQRestriction.class,
071: CardinalityQRestrictionImpl.factory)
072:
073: .add(OntProperty.class, OntPropertyImpl.factory).add(
074: ObjectProperty.class, ObjectPropertyImpl.factory)
075: .add(DatatypeProperty.class, DatatypePropertyImpl.factory)
076: .add(TransitiveProperty.class,
077: TransitivePropertyImpl.factory).add(
078: SymmetricProperty.class,
079: SymmetricPropertyImpl.factory).add(
080: FunctionalProperty.class,
081: FunctionalPropertyImpl.factory).add(
082: InverseFunctionalProperty.class,
083: InverseFunctionalPropertyImpl.factory).add(
084: AllDifferent.class, AllDifferentImpl.factory).add(
085: Individual.class, IndividualImpl.factory).add(
086: AnnotationProperty.class,
087: AnnotationPropertyImpl.factory)
088:
089: // Last and least ?
090: .add(RDFNode.class, ResourceImpl.rdfNodeFactory);
091:
092: /**
093: * For debugging purposes, list the standard personalities on the given
094: * output writer.
095: *
096: * @param writer A printwriter to list the personalities mapping to
097: */
098: static public void listPersonalities(PrintWriter writer) {
099: for (Iterator i = model.nodePersonality().getMap().entrySet()
100: .iterator(); i.hasNext();) {
101: Map.Entry e = (Map.Entry) i.next();
102:
103: writer.println("personality key "
104: + ((Class) e.getKey()).getName() + " -> value "
105: + e.getValue());
106: }
107:
108: writer.flush();
109: }
110: }
111:
112: /*
113: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
114: All rights reserved.
115:
116: Redistribution and use in source and binary forms, with or without
117: modification, are permitted provided that the following conditions
118: are met:
119:
120: 1. Redistributions of source code must retain the above copyright
121: notice, this list of conditions and the following disclaimer.
122:
123: 2. Redistributions in binary form must reproduce the above copyright
124: notice, this list of conditions and the following disclaimer in the
125: documentation and/or other materials provided with the distribution.
126:
127: 3. The name of the author may not be used to endorse or promote products
128: derived from this software without specific prior written permission.
129:
130: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
131: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
132: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
133: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
134: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
135: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
136: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
137: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
138: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
139: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
140: */
|