Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e9046d9
Create NTriples Serializer
abdessamad-abdoun Jun 11, 2025
692693d
Create NQuads Serializer
abdessamad-abdoun Jun 11, 2025
0400c31
Create NQuads Serializer
abdessamad-abdoun Jun 11, 2025
7328345
Create NTriples/NQuads Serializer
abdessamad-abdoun Jun 11, 2025
245aaf7
ajouter test unitaire sur formtConfig
abdessamad-abdoun Jun 12, 2025
cf05148
Create NTriples/NQuads Serializer
abdessamad-abdoun Jun 12, 2025
4e1fc0b
ajouter une classe constants
abdessamad-abdoun Jun 12, 2025
3d7c2fd
correction java Doc et ajouter n triples format
abdessamad-abdoun Jun 12, 2025
6c2a1a9
Correction de la JavaDoc et ajout des tests unitaires pour NTriplesFo…
abdessamad-abdoun Jun 12, 2025
23b1395
correction les erreur de sonar sur TUs
abdessamad-abdoun Jun 12, 2025
f5bbfcf
correction les erreur de sonar
abdessamad-abdoun Jun 12, 2025
015d246
Remove AbstractBNode class as part of code cleanup
remiceres Jun 12, 2025
cdcee5c
Add FileFormat and RdfFormat classes for RDF serialization support
remiceres Jun 12, 2025
42d2b3e
Merge branch 'feature/152_NTriples_NQuads_Serializer' of github.com:c…
remiceres Jun 12, 2025
0e61739
Create NTriples/NQuads Serializer
abdessamad-abdoun Jun 12, 2025
4a8fcb4
ajouter test unitaire sur Serializer
abdessamad-abdoun Jun 13, 2025
dd48b2e
Add unit tests for FileFormat class
remiceres Jun 13, 2025
d273449
ajouter test unitaire sur Serializer et fusionner rdfFormet
abdessamad-abdoun Jun 13, 2025
896cd43
ajouter test unitaire sur rdfFormet
abdessamad-abdoun Jun 13, 2025
4a404ab
Refactor FormatSerializer and FileFormat documentation; update Serial…
remiceres Jun 19, 2025
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
62 changes: 0 additions & 62 deletions src/main/java/fr/inria/corese/core/next/api/AbstractBNode.java

This file was deleted.

22 changes: 22 additions & 0 deletions src/main/java/fr/inria/corese/core/next/api/FormatSerializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fr.inria.corese.core.next.api;

import java.io.Writer;

import fr.inria.corese.core.next.impl.exception.SerializationException;

public interface FormatSerializer {

/**
* A serializer that converts a {@link Model} instance
* into a specific output format and writes it to a character stream.
*
* Implementations may follow standard RDF serialization formats
* (e.g., Turtle, N-Triples, JSON-LD), or define custom formats.
*
* @param writer the destination {@link Writer} for the serialized
* output
* @throws SerializationException if an error occurs during the serialization
* process
*/
void write(Writer writer) throws SerializationException;
}
3 changes: 2 additions & 1 deletion src/main/java/fr/inria/corese/core/next/api/Resource.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package fr.inria.corese.core.next.api;

/**
* Super interface of all resources of an RDF graph (statements, IRI, blank nodes) as defined for RDF 1.2.
* Super interface of all resources of an RDF graph (statements, IRI, blank
* nodes) as defined for RDF 1.2.
*/
public interface Resource extends Value {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package fr.inria.corese.core.next.impl.common.serialization;

import java.util.List;
import java.util.Objects;

/**
* Represents a general file format, including its name, associated file
* extensions, and MIME types.
*/
public class FileFormat {

private final String name;
private final List<String> extensions;
private final List<String> mimeTypes;

/**
* Constructs a new FileFormat instance.
*
* @param name The human-readable name of the format.
* @param extensions The list of file extensions.
* @param mimeTypes The list of MIME types.
* @throws NullPointerException if name, extensions or mimeTypes is null or
* empty.
*/
public FileFormat(String name, List<String> extensions, List<String> mimeTypes) {
this.name = Objects.requireNonNull(name, "Format name cannot be null");
this.extensions = List.copyOf(Objects.requireNonNull(extensions, "Extensions list cannot be null"));
this.mimeTypes = List.copyOf(Objects.requireNonNull(mimeTypes, "MIME types list cannot be null"));

if (extensions.isEmpty()) {
throw new IllegalArgumentException("At least one file extension must be provided");
}
if (mimeTypes.isEmpty()) {
throw new IllegalArgumentException("At least one MIME type must be provided");
}
}

/**
* Returns the name of the format.
*
* @return The format name.
*/
public String getName() {
return name;
}

/**
* Returns the list of known file extensions.
*
* @return A list of extensions.
*/
public List<String> getExtensions() {
return extensions;
}

/**
* Returns the list of associated MIME types.
*
* @return A list of MIME types.
*/
public List<String> getMimeTypes() {
return mimeTypes;
}

/**
* Returns the default (primary) file extension.
*
* @return The first extension in the list.
*/
public String getDefaultExtension() {
return extensions.get(0);
}

/**
* Returns the default (primary) MIME type.
*
* @return The first MIME type in the list.
*/
public String getDefaultMimeType() {
return mimeTypes.get(0);
}

@Override
public String toString() {
return "FileFormat{name='%s', extensions=%s, mimeTypes=%s}".formatted(name, extensions, mimeTypes);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof FileFormat other))
return false;
return name.equalsIgnoreCase(other.name)
&& extensions.equals(other.extensions)
&& mimeTypes.equals(other.mimeTypes);
}

@Override
public int hashCode() {
return Objects.hash(name.toLowerCase(), extensions, mimeTypes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package fr.inria.corese.core.next.impl.common.serialization;

import java.util.Objects;

/**
* Configuration options for the {@link NTriplesFormat} serializer.
* Use {@link FormatConfig # Builder} to create instances.
*/
public class FormatConfig {

private final String blankNodePrefix;


/**
* Private constructor to enforce usage of the Builder.
*
* @param builder The builder instance.
*/
private FormatConfig(Builder builder) {
this.blankNodePrefix = builder.blankNodePrefix;

}

/**
* Returns the prefix to use for blank nodes.
*
* @return The blank node prefix.
*/
public String getBlankNodePrefix() {
return blankNodePrefix;
}

/**
* Builder class for {@link FormatConfig}.
*/
public static class Builder {

private String blankNodePrefix = "_:";

/**
* Default constructor for the Builder.
* Initializes fields with default values.
*/
Builder() {

}

/**
* Sets the prefix to use for blank nodes. Default is "_:".
*
* @param blankNodePrefix The desired blank node prefix.
* @return The builder instance.
*/
public Builder blankNodePrefix(String blankNodePrefix) {
this.blankNodePrefix = Objects.requireNonNull(blankNodePrefix, "Blank node prefix cannot be null");
return this;
}


/**
* Builds a new {@link FormatConfig} instance.
*
* @return A new NFormatConfig instance.
*/
public FormatConfig build() {
return new FormatConfig(this);
}
}
}
Loading