001: package org.ontoware.rdfreactor.generator;
002:
003: import java.util.Calendar;
004:
005: import org.ontoware.rdf2go.model.node.URI;
006: import org.ontoware.rdf2go.vocabulary.OWL;
007: import org.ontoware.rdf2go.vocabulary.RDF;
008: import org.ontoware.rdf2go.vocabulary.RDFS;
009: import org.ontoware.rdf2go.vocabulary.XSD;
010: import org.ontoware.rdfreactor.generator.java.JClass;
011: import org.ontoware.rdfreactor.generator.java.JModel;
012: import org.ontoware.rdfreactor.generator.java.JPackage;
013: import org.ontoware.rdfreactor.generator.java.JProperty;
014:
015: public class Semantics {
016:
017: public static final String NS_XSD = "http://www.w3.org/2001/XMLSchema#";
018:
019: /**
020: * Add the build-in mapping of URIs to classes.
021: *
022: * @param jm
023: */
024: public static void addBuiltInsCommon(JModel jm) {
025:
026: // TODO: shouldn't JPackage.RDFSCHEMA be added to 'jm' ?
027:
028: jm.addMapping(RDF.Alt, new JClass(JPackage.RDFSCHEMA,
029: JPackage.RDFSCHEMA.getName() + ".Alt", RDF.Alt));
030: jm.addMapping(RDF.Bag, new JClass(JPackage.RDFSCHEMA,
031: JPackage.RDFSCHEMA.getName() + ".Bag", RDF.Bag));
032:
033: JClass _class = new JClass(JPackage.RDFSCHEMA,
034: JPackage.RDFSCHEMA.getName() + ".Class", RDFS.Class);
035: jm.addMapping(RDFS.Class, _class);
036:
037: jm.addMapping(RDFS.Container, new JClass(JPackage.RDFSCHEMA,
038: JPackage.RDFSCHEMA.getName() + ".Container",
039: RDFS.Container));
040: jm.addMapping(RDFS.ContainerMembershipProperty, new JClass(
041: JPackage.RDFSCHEMA, JPackage.RDFSCHEMA.getName()
042: + ".ContainerMembershipProperty",
043: RDFS.ContainerMembershipProperty));
044: jm.addMapping(RDFS.Datatype, new JClass(JPackage.RDFSCHEMA,
045: JPackage.RDFSCHEMA.getName() + ".Datatype",
046: RDFS.Datatype));
047: // literal mapping
048: jm.addMapping(RDFS.Literal, JClass.STRING);
049: jm.addMapping(RDF.List, new JClass(JPackage.RDFSCHEMA,
050: JPackage.RDFSCHEMA.getName() + ".List", RDF.List));
051: jm.addMapping(RDF.nil, new JClass(JPackage.RDFSCHEMA,
052: JPackage.RDFSCHEMA.getName() + ".Nil", RDF.nil));
053: // rdf property is special
054: jm.addMapping(RDF.Seq, new JClass(JPackage.RDFSCHEMA,
055: JPackage.RDFSCHEMA.getName() + ".Seq", RDF.Seq));
056: jm.addMapping(RDF.Statement, new JClass(JPackage.RDFSCHEMA,
057: JPackage.RDFSCHEMA.getName() + ".Statement",
058: RDF.Statement));
059: jm.addMapping(RDF.XMLLiteral, new JClass(JPackage.RDFSCHEMA,
060: JPackage.RDFSCHEMA.getName() + ".XMLLiteral",
061: RDF.XMLLiteral));
062:
063: jm.addMapping(RDF.Property, new JClass(JPackage.RDFSCHEMA,
064: JPackage.RDFSCHEMA.getName() + ".Property",
065: RDF.Property));
066:
067: JClass _resource = new JClass(JPackage.RDFSCHEMA,
068: JPackage.RDFSCHEMA.getName() + ".Resource",
069: RDFS.Resource);
070: jm.addMapping(RDFS.Resource, _resource);
071: _resource.getProperties().add(
072: new JProperty(_resource, "label", RDFS.label));
073: _resource.getProperties().add(
074: new JProperty(_resource, "comment", RDFS.comment));
075: _resource.getProperties().add(
076: new JProperty(_resource, "type", RDF.type));
077: _resource.getProperties().add(
078: new JProperty(_resource, "member", RDFS.member));
079:
080: // owl mapping
081: String owl = "org.ontoware.rdfreactor.schema.owl";
082:
083: // TODO: shouldn't JPackage.OWL be added to jm ?
084:
085: jm.addMapping(OWL.Class, new JClass(JPackage.OWL, owl
086: + ".Class", OWL.Class));
087: jm.addMapping(OWL.AllDifferent, new JClass(JPackage.OWL, owl
088: + ".AllDifferent", OWL.AllDifferent));
089: jm.addMapping(OWL.AnnotationProperty, new JClass(JPackage.OWL,
090: owl + ".AnnotationProperty", OWL.AnnotationProperty));
091: jm.addMapping(OWL.DataRange, new JClass(JPackage.OWL, owl
092: + ".DataRange", OWL.DataRange));
093: jm.addMapping(OWL.DatatypeProperty, new JClass(JPackage.OWL,
094: owl + ".DatatypeProperty", OWL.DatatypeProperty));
095: jm.addMapping(OWL.DeprecatedClass, new JClass(JPackage.OWL, owl
096: + ".DeprecatedClass", OWL.DeprecatedClass));
097: jm.addMapping(OWL.DeprecatedProperty, new JClass(JPackage.OWL,
098: owl + ".DeprecatedProperty", OWL.DeprecatedProperty));
099: jm.addMapping(OWL.FunctionalProperty, new JClass(JPackage.OWL,
100: owl + ".FunctionalProperty", OWL.FunctionalProperty));
101: jm.addMapping(OWL.InverseFunctionalProperty, new JClass(
102: JPackage.OWL, owl + ".InverseFunctionalProperty",
103: OWL.InverseFunctionalProperty));
104: jm.addMapping(OWL.Nothing, new JClass(JPackage.OWL, owl
105: + ".Nothing", OWL.Nothing));
106: jm.addMapping(OWL.ObjectProperty, new JClass(JPackage.OWL, owl
107: + ".ObjectProperty", OWL.ObjectProperty));
108: jm.addMapping(OWL.Ontology, new JClass(JPackage.OWL, owl
109: + ".Ontology", OWL.Ontology));
110: jm.addMapping(OWL.OntologyProperty, new JClass(JPackage.OWL,
111: owl + ".OntologyProperty", OWL.OntologyProperty));
112: jm.addMapping(OWL.Restriction, new JClass(JPackage.OWL, owl
113: + ".Restriction", OWL.Restriction));
114: jm.addMapping(OWL.SymmetricProperty, new JClass(JPackage.OWL,
115: owl + ".SymmetricProperty", OWL.SymmetricProperty));
116: jm.addMapping(OWL.Thing, new JClass(JPackage.OWL, owl
117: + ".Thing", OWL.Thing));
118: jm.addMapping(OWL.TransitiveProperty, new JClass(JPackage.OWL,
119: owl + ".TransitiveProperty", OWL.TransitiveProperty));
120: // XML Schema
121:
122: //////////////////// java.net
123: // IDs
124: jm.addMapping(XSD._anyURI, new JClass(new JPackage("java.net"),
125: URI.class.getName() + "", XSD._anyURI));
126:
127: /////////////////// java.lang
128: // primitive types
129: jm.addMapping(XSD._byte, new JClass(JPackage.JAVA_LANG,
130: Byte.class.getName() + "", XSD._byte));
131: jm.addMapping(XSD._boolean, new JClass(JPackage.JAVA_LANG,
132: Boolean.class.getName() + "", XSD._boolean));
133:
134: // numbers
135: // TODO: better xsd handling for non negative integer
136: jm.addMapping(XSD._nonNegativeInteger, new JClass(
137: JPackage.JAVA_LANG, Integer.class.getName() + "",
138: XSD._nonNegativeInteger));
139:
140: jm.addMapping(XSD._integer, new JClass(JPackage.JAVA_LANG,
141: Integer.class.getName() + "", XSD._integer));
142: jm.addMapping(XSD._int, new JClass(JPackage.JAVA_LANG,
143: Integer.class.getName() + "", XSD._int));
144: jm.addMapping(XSD._long, new JClass(JPackage.JAVA_LANG,
145: Long.class.getName() + "", XSD._long));
146: jm.addMapping(XSD._double, new JClass(JPackage.JAVA_LANG,
147: Double.class.getName() + "", XSD._double));
148: jm.addMapping(XSD._float, new JClass(JPackage.JAVA_LANG,
149: Float.class.getName() + "", XSD._float));
150:
151: // strings
152: jm.addMapping(XSD._normalizedString, new JClass(
153: JPackage.JAVA_LANG, String.class.getName() + "",
154: XSD._normalizedString));
155: jm.addMapping(XSD._string, new JClass(JPackage.JAVA_LANG,
156: String.class.getName() + "", XSD._string));
157:
158: /////////////////////////// java.util
159:
160: // date and time -> Calendar.class
161: jm.addMapping(XSD._dateTime, new JClass(JPackage.JAVA_UTIL,
162: Calendar.class.getName() + "", XSD._dateTime));
163: jm.addMapping(XSD._date, new JClass(JPackage.JAVA_UTIL,
164: Calendar.class.getName() + "", XSD._date));
165: jm.addMapping(XSD._time, new JClass(JPackage.JAVA_UTIL,
166: Calendar.class.getName() + "", XSD._time));
167:
168: // get all properties
169: jm.knownProperties.add(RDF.first);
170: jm.knownProperties.add(RDF.rest);
171: jm.knownProperties.add(RDF.subject);
172: jm.knownProperties.add(RDF.predicate);
173: jm.knownProperties.add(RDF.object);
174: jm.knownProperties.add(RDF.type);
175: jm.knownProperties.add(RDF.value);
176: jm.knownProperties.add(RDFS.label);
177: jm.knownProperties.add(RDFS.comment);
178: jm.knownProperties.add(RDFS.seeAlso);
179: jm.knownProperties.add(RDFS.isDefinedBy);
180: jm.knownProperties.add(RDFS.member);
181: jm.knownProperties.add(RDFS.domain);
182: jm.knownProperties.add(RDFS.range);
183: jm.knownProperties.add(RDFS.subClassOf);
184: jm.knownProperties.add(RDFS.subPropertyOf);
185:
186: }
187:
188: /**
189: * @return a JModel with the common built-ins
190: */
191: public static JModel getbuiltIns_RDFS() {
192: JModel jm = new JModel(JClass.RDFS_CLASS);
193: addBuiltInsCommon(jm);
194: return jm;
195: }
196:
197: /**
198: * @return a JModel with the common built-ins
199: */
200: public static JModel getbuiltIns_OWL() {
201: JModel jm = new JModel(JClass.OWL_CLASS);
202: addBuiltInsCommon(jm);
203: return jm;
204: }
205:
206: }
|