Skip to content
4 changes: 2 additions & 2 deletions src/main/java/fr/inria/corese/core/next/api/Namespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Represents a namespace with a prefix and the start of an IRI as its name.
*/
public interface Namespace extends Serializable, Comparable<Namespace> {
public interface Namespace extends Serializable {

/**
* @return The prefix of the namespace.
Expand All @@ -15,7 +15,7 @@ public interface Namespace extends Serializable, Comparable<Namespace> {
/**
* @return The name of the namespace, which is the start of an IRI.
*/
String getName();
String getNamespace();

/**
* @param o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class RDFFormat extends FileFormat {
public static final RDFFormat RDFXML = new RDFFormat(
"RDF/XML",
List.of("rdf", "xml"),
List.of("application/rdf+xml"),
List.of("application/rdf+xml", "application/xml", "text/xml"),
true,
false);

Expand All @@ -65,10 +65,10 @@ public class RDFFormat extends FileFormat {
false,
true);

public static final RDFFormat RDFa = new RDFFormat(
"RDFa",
List.of("html", "xhtml"),
List.of("text/html", "application/xhtml+xml"),
public static final RDFFormat RDFA = new RDFFormat(
"RDFa 1.1",
List.of("xhtml", "svg", "html"),
List.of("application/xhtml+xml", "image/svg+xml", "application/xml", "text/xml", "text/html"),
true,
false);

Expand Down Expand Up @@ -158,7 +158,7 @@ public static Optional<RDFFormat> byMimeType(String mimeType) {
* @return An unmodifiable List of all RdfFormat constants.
*/
public static List<RDFFormat> all() {
return List.of(TURTLE, NTRIPLES, NQUADS, JSONLD, RDFXML, TRIG, RDFC_1_0, RDFa);
return List.of(JSONLD, NQUADS, NTRIPLES, RDFA, RDFC_1_0, RDFXML, TRIG, TURTLE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Model unmodifiable() {
public Namespace setNamespace(String prefix, String name) {
Optional<? extends Namespace> existing = getNamespace(prefix);

if (!existing.isPresent() || !existing.get().getName().equals(name)) {
if (!existing.isPresent() || !existing.get().getNamespace().equals(name)) {
Namespace namespace = new ModelNamespace(prefix, name);
setNamespace(namespace);
return namespace;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.inria.corese.core.next.api.base.model;

import java.io.Serial;
import java.util.Comparator;
import java.util.Objects;

import fr.inria.corese.core.next.api.Namespace;
Expand All @@ -19,22 +18,6 @@ public abstract class AbstractNamespace implements Namespace {
@Serial
private static final long serialVersionUID = 1L;

/**
* Comparator that orders namespaces by prefix, then by URI.
* Null values are ordered first.
*/
private static final Comparator<Namespace> ORDERING = Comparator.nullsFirst(
Comparator.comparing(Namespace::getPrefix)
.thenComparing(Namespace::getName));

/**
* Compares this namespace to another based on prefix and name.
*/
@Override
public int compareTo(Namespace other) {
return ORDERING.compare(this, other);
}

/**
* Checks equality based on prefix and name.
*/
Expand All @@ -48,22 +31,22 @@ public boolean equals(Object object) {
}
Namespace ns = (Namespace) object;
return Objects.equals(getPrefix(), ns.getPrefix())
&& Objects.equals(getName(), ns.getName());
&& Objects.equals(getNamespace(), ns.getNamespace());
}

/**
* Computes hash code from prefix and name.
*/
@Override
public int hashCode() {
return Objects.hash(getPrefix(), getName());
return Objects.hash(getPrefix(), getNamespace());
}

/**
* Returns a readable string representation of the namespace.
*/
@Override
public String toString() {
return getPrefix() + " :: " + getName();
return getPrefix() + " :: " + getNamespace();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void setNamespace(Namespace namespace) {
if (namespace == null) {
throw new IllegalArgumentException("Namespace cannot be null");
}
setPrefix(namespace.getPrefix(), namespace.getName());
setPrefix(namespace.getPrefix(), namespace.getNamespace());
}

/**
Expand Down Expand Up @@ -441,14 +441,14 @@ public String getPrefix() {
}

@Override
public String getName() {
public String getNamespace() {
return name;
}

@SuppressWarnings("NullableProblems")
@Override
public int compareTo(Namespace o) {
Objects.requireNonNull(o);
int cmp = this.name.compareTo(o.getName());
int cmp = this.name.compareTo(o.getNamespace());
if (cmp != 0) {
return cmp;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package fr.inria.corese.core.next.impl.common.vocabulary;

import fr.inria.corese.core.next.api.IRI;
import fr.inria.corese.core.next.impl.common.BasicIRI;
import fr.inria.corese.core.next.impl.exception.IncorrectFormatException;

public enum RDFa implements Vocabulary {

PGClass("PGClass"),
Pattern("Pattern"),
PrefixOrTermMapping("PrefixOrTermMapping"),
DocumentError("DocumentError"),
Info("Info"),
PrefixRedefinition("PrefixRedefinition"),
UnresolvedCURIE("UnresolvedCURIE"),
UnresolvedTerm("UnresolvedTerm"),
VocabReferenceError("VocabReferenceError"),
context("context"),
copy("copy"),
prefix("prefix"),
term("term"),
uri("uri"),
usesVocabulary("usesVocabulary"),
vocabulary("vocabulary"),
Error("Error"),
PrefixMapping("PrefixMapping"),
TermMapping("TermMapping"),
Warning("Warning");

private final IRI iri;

/**
* Constructor for the RDFa vocabulary enum.
*
* @param localName the local name of the IRI
* @throws IncorrectFormatException if the namespace and the local name do not form a correct IRI
*/
RDFa(String localName) {
this.iri = new BasicIRI(getNamespace(), localName);
}
@Override
public IRI getIRI() {
return this.iri;
}

@Override
public String getNamespace() {
return getVocabularyNamespace();
}

@Override
public String getPreferredPrefix() {
return getVocabularyPreferredPrefix();
}

public static String getVocabularyNamespace() {
return "http://www.w3.org/ns/rdfa#";
}

public static String getVocabularyPreferredPrefix() {
return "rdfa";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public RDFParser createRDFParser(RDFFormat format, Model model, ValueFactory fac
return new TriGParser(model, factory, config);
} else if(format == RDFFormat.RDFC_1_0) {
return new NQuadsParser(model, factory, config);
} else if (format == RDFFormat.RDFa) {
} else if (format == RDFFormat.RDFA) {
return new RDFaParser(model, factory, config);
}
throw new IllegalArgumentException("Unsupported format: " + format);
Expand All @@ -80,7 +80,7 @@ public RDFParser createRDFParser(RDFFormat format, Model model, ValueFactory fac
return new RDFXMLParser(model, factory);
} else if (format == RDFFormat.TRIG) {
return new TriGParser(model, factory);
} else if (format == RDFFormat.RDFa) {
} else if (format == RDFFormat.RDFA) {
return new RDFaParser(model, factory);
}
throw new IllegalArgumentException("Unsupported format: " + format);
Expand Down
Loading