Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENA-1816: Updates of the RDF namespace #671

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
JENA-1816: Updates of the RDF namespace
  • Loading branch information
afs committed Jan 15, 2020
commit c5e8d6939274df3505a8beae81901b61c9a945ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.jena.datatypes.xsd.impl;

import org.apache.jena.datatypes.BaseDatatype ;
import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.graph.impl.LiteralLabel ;

/** rdf:json.
* This only implements syntactic equality, not value equality.
*/

public class RDFjson extends BaseDatatype implements RDFDatatype {
/** Singleton instance */
// Include the string for the RDF namespace, not use RDF.getURI(), to avoid an initializer circularity
public static final RDFDatatype rdfJSON = new RDFjson("https://www.w3.org/1999/02/22-rdf-syntax-ns#JSON");

/**
* Private constructor.
*/
private RDFjson(String uri) {
super(uri);
}

/**
* Compares two instances of values of the given datatype.
*/
@Override
public boolean isEqual(LiteralLabel value1, LiteralLabel value2) {
return isEqualByTerm(value1, value2) ;
}

@Override
public Object parse(String lexicalForm) { return lexicalForm ; }

@Override
public String unparse(Object value) { return value.toString(); }
}

44 changes: 38 additions & 6 deletions jena-core/src/main/java/org/apache/jena/vocabulary/RDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.datatypes.xsd.impl.RDFLangString ;
import org.apache.jena.datatypes.xsd.impl.RDFhtml ;
import org.apache.jena.datatypes.xsd.impl.RDFjson;
import org.apache.jena.datatypes.xsd.impl.XMLLiteralType ;
import org.apache.jena.graph.Node ;
import org.apache.jena.rdf.model.Property ;
Expand Down Expand Up @@ -52,7 +53,7 @@ protected static final Property property( String local )

public static Property li( int i )
{ return property( "_" + i ); }

public static final Resource Alt = Init.Alt();
public static final Resource Bag = Init.Bag();
public static final Resource Property = Init._Property();
Expand Down Expand Up @@ -81,6 +82,23 @@ public static Property li( int i )
public static final RDFDatatype dtRDFHTML = Init.dtRDFHTML();
public static final RDFDatatype dtLangString = Init.dtLangString();
public static final RDFDatatype dtXMLLiteral = Init.dtXMLLiteral();

// Added to the RDF namespace December 2019
// https://lists.w3.org/Archives/Public/semantic-web/2019Dec/0027.html

// rdfs:comment "The datatype of RDF literals storing JSON content."
public static final RDFDatatype dtRDFJSON = Init.dtRDFJSON();
public static final Resource JSON = Init.JSON();

// rdfs:comment "A class representing a compound literal."
public static final Resource CompoundLiteral = Init.CompoundLiteral();

// rdfs:comment "The language component of a CompoundLiteral."
public static final Property language = Init.language();

// rdfs:comment "The base direction component of a CompoundLiteral."
public static final Property direction = Init.direction();


/** RDF constants are used during Jena initialization.
* <p>
Expand All @@ -90,15 +108,16 @@ public static Property li( int i )
* So for these cases, call this helper class: Init.function()
*/
public static class Init {

// JENA-1294
// Version that calculate the constant when called.
public static Resource Alt() { return resource( "Alt" ); }
public static Resource Bag() { return resource( "Bag" ); }
// Java8 bug : https://bugzilla.redhat.com/show_bug.cgi?id=1423421
// Can't have a methdo called Property() - it crashes the javadoc generation.
// Can't have a method called Property() - it crashes the javadoc generation.
// https://bugzilla.redhat.com/show_bug.cgi?id=1423421 ==>
// https://bugs.openjdk.java.net/browse/JDK-8061305
public static Resource _Property() { return resource( "Property" ); }
public static Resource _Property() { return resource( "Property" ); }
public static Resource Seq() { return resource( "Seq" ); }
public static Resource Statement() { return resource( "Statement" ); }
public static Resource List() { return resource( "List" ); }
Expand All @@ -111,13 +130,20 @@ public static class Init {
public static Property type() { return property( "type" ); }
public static Property value() { return property( "value" ); }

public static Resource langString() { return ResourceFactory.createResource(dtLangString().getURI()) ; }
public static Resource HTML() { return ResourceFactory.createResource(dtRDFHTML().getURI()) ; }
public static Resource xmlLiteral() { return ResourceFactory.createResource(dtXMLLiteral().getURI()) ; }
public static Resource langString() { return ResourceFactory.createResource(dtLangString().getURI()); }
public static Resource HTML() { return ResourceFactory.createResource(dtRDFHTML().getURI()); }
public static Resource xmlLiteral() { return ResourceFactory.createResource(dtXMLLiteral().getURI()); }
public static Resource JSON() { return ResourceFactory.createResource(dtRDFJSON().getURI()) ; }

public static Resource CompoundLiteral() { return resource( "CompoundLiteral" ); }
public static Property language() { return property( "language" ); }
public static Property direction() { return property( "direction" ); }

public static RDFDatatype dtRDFHTML() { return RDFhtml.rdfHTML; }
public static RDFDatatype dtLangString() { return RDFLangString.rdfLangString; }
public static RDFDatatype dtXMLLiteral() { return XMLLiteralType.theXMLLiteralType; }
public static RDFDatatype dtRDFJSON() { return RDFjson.rdfJSON; }

}

/**
Expand All @@ -144,5 +170,11 @@ public static final class Nodes
public static final Node langString = Init.langString().asNode();
public static final Node HTML = Init.HTML().asNode();
public static final Node xmlLiteral = Init.xmlLiteral().asNode();
// Added to the RDF namespace December 2019
// https://lists.w3.org/Archives/Public/semantic-web/2019Dec/0027.html
public static final Node JSON = Init.JSON().asNode();
public static final Node CompoundLiteral = Init.CompoundLiteral().asNode();
public static final Node language = Init.language().asNode();
public static final Node direction = Init.direction().asNode();
}
}