Skip to content

Commit

Permalink
overhaul serizalition code
Browse files Browse the repository at this point in the history
* unify access to Input(De)Serializers behind facades to leverage the default methods for various input/output channels
* drop implicit buffering/decompressing as this should be decided where the stream are constructed (user-land)
* remove/cleanup the (now) unused code
  • Loading branch information
mtf90 committed Aug 2, 2024
1 parent c186e65 commit 5b9f3c9
Show file tree
Hide file tree
Showing 65 changed files with 2,080 additions and 1,763 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* The `Visualization` factory has been moved from the `automata-core` artifact to the `automata-api` artifact. Furthermore, the previous `DummyVP` has been replaced with a `NoopVP` that does not show a swing window anymore when no proper VisualizationProvider is configured but instead logs an error message. This allows us to drop the `java.desktop` (module) dependency for headless setups and only require it in actual visualizers (DOT, JUNG, etc.).
* The `DirectPowersetDTS` class has been renamed to `PowersetView`.
* The `FormatException` is now a checked exception because we can [reasonably expect clients to recover from this error](https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html). Furthermore, all parsing-related code has been aligned to use the `FormatException` instead of leaking implementation details (such as the `ParseException`s generated by JavaCC).
* The serializers have been overhauled to allow for better integration of custom automaton types (especially when parsing). Some of the changes introduce new facades which may require some refactoring but the previous functionality is still available. As a part of this streamlining, many parsers no longer automatically un-compress or buffer the input streams to reduce overhead. The need for this can be determined best where the streams are created (in user-land).

### Removed

* `SimpleTS#getSuccessors(S state, Iterable<? extends I> input)` has been removed. In order to traverse a (non-deterministic) transition system, use `TransitionSystem#powersetView` instead.
* The `net.automatalib:automata-serialization-core` artifact has been dropped. Its contents are now part of the `net.automatalib:automata-api` artifact.
* `TAFParseDiagnosticListener` has been removed. Reporting is now done via (slf4j) logging.

### Fixed

Expand Down
1 change: 0 additions & 1 deletion api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
exports net.automatalib.graph.visualization;
exports net.automatalib.modelchecking;
exports net.automatalib.serialization;
exports net.automatalib.serialization.automaton;
exports net.automatalib.ts;
exports net.automatalib.ts.acceptor;
exports net.automatalib.ts.modal;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

import net.automatalib.alphabet.Alphabet;
import net.automatalib.common.util.IOUtil;
Expand All @@ -35,7 +36,8 @@
public interface InputModelSerializer<I, M extends SimpleTS<?, I>> extends ModelSerializer<InputModelData<I, M>> {

/**
* Writes the model to the given output stream.
* Writes the model to the given output stream. If the format is a textual one, the output is typically encoded in
* {@link StandardCharsets#UTF_8 UTF-8}.
* <p>
* Note: the output stream will <b>not</b> be closed.
*
Expand All @@ -52,7 +54,8 @@ public interface InputModelSerializer<I, M extends SimpleTS<?, I>> extends Model
void writeModel(OutputStream os, M model, Alphabet<I> alphabet) throws IOException;

/**
* Writes the model to the given file.
* Writes the model to the given file. If the format is a textual one, the output is typically encoded in
* {@link StandardCharsets#UTF_8 UTF-8}.
*
* @param f
* the file to write to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import net.automatalib.common.util.IOUtil;
import net.automatalib.exception.FormatException;
Expand All @@ -33,7 +34,8 @@
public interface ModelDeserializer<M> {

/**
* Reads the contents from the given input stream and de-serializes it into a model instance.
* Reads the contents from the given input stream and de-serializes it into a model instance. If the format is a
* textual one, the input stream is typically interpreted in {@link StandardCharsets#UTF_8 UTF-8}.
* <p>
* Note: the input stream will <b>not</b> be closed.
*
Expand All @@ -50,7 +52,8 @@ public interface ModelDeserializer<M> {
M readModel(InputStream is) throws IOException, FormatException;

/**
* Reads the contents from the given URL and de-serializes it into a model instance.
* Reads the contents from the given URL and de-serializes it into a model instance. If the format is a textual one,
* the input stream is typically interpreted in {@link StandardCharsets#UTF_8 UTF-8}.
*
* @param url
* the url to read data from
Expand All @@ -69,7 +72,8 @@ default M readModel(URL url) throws IOException, FormatException {
}

/**
* Reads the contents from the given file and de-serializes it into a model instance.
* Reads the contents from the given file and de-serializes it into a model instance. If the format is a textual
* one, the input stream is typically interpreted in {@link StandardCharsets#UTF_8 UTF-8}.
*
* @param f
* the file to read data from
Expand All @@ -88,7 +92,8 @@ default M readModel(File f) throws IOException, FormatException {
}

/**
* Reads the contents from the given byte buffer and de-serializes it into a model instance.
* Reads the contents from the given byte buffer and de-serializes it into a model instance. If the format is a
* textual one, the input stream is typically interpreted in {@link StandardCharsets#UTF_8 UTF-8}.
*
* @param buf
* the buffer to read data from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

import net.automatalib.common.util.IOUtil;

Expand All @@ -30,7 +31,8 @@
public interface ModelSerializer<M> {

/**
* Writes the model to the given output stream.
* Writes the model to the given output stream. If the format is a textual one, the output is typically encoded in
* {@link StandardCharsets#UTF_8 UTF-8}.
* <p>
* Note: the output stream will <b>not</b> be closed.
*
Expand All @@ -45,7 +47,8 @@ public interface ModelSerializer<M> {
void writeModel(OutputStream os, M model) throws IOException;

/**
* Writes the model to the given file.
* Writes the model to the given file. If the format is a textual one, the output is typically encoded in
* {@link StandardCharsets#UTF_8 UTF-8}.
*
* @param f
* the file to write to
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5b9f3c9

Please sign in to comment.