• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 10248696670

05 Aug 2024 12:21PM UTC coverage: 90.741% (+0.7%) from 90.072%
10248696670

push

github

web-flow
Serialization Overhaul (#81)

* overhaul serizalition code

* 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

* taf cleanups

* fix wording

343 of 358 new or added lines in 33 files covered. (95.81%)

7 existing lines in 2 files now uncovered.

15994 of 17626 relevant lines covered (90.74%)

1.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/serialization/taf/src/main/java/net/automatalib/serialization/taf/parser/TAFAnyParser.java
1
/* Copyright (C) 2013-2024 TU Dortmund University
2
 * This file is part of AutomataLib, http://www.automatalib.net/.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.serialization.taf.parser;
17

18
import java.io.IOException;
19
import java.io.InputStream;
20
import java.io.Reader;
21

22
import net.automatalib.automaton.FiniteAlphabetAutomaton;
23
import net.automatalib.automaton.fsa.impl.CompactDFA;
24
import net.automatalib.automaton.impl.CompactTransition;
25
import net.automatalib.automaton.transducer.impl.CompactMealy;
26
import net.automatalib.common.util.IOUtil;
27
import net.automatalib.exception.FormatException;
28
import net.automatalib.serialization.InputModelData;
29
import net.automatalib.serialization.InputModelDeserializer;
30

31
final class TAFAnyParser implements InputModelDeserializer<String, FiniteAlphabetAutomaton<?, String, ?>> {
2✔
32

33
    @Override
34
    public InputModelData<String, FiniteAlphabetAutomaton<?, String, ?>> readModel(InputStream is) throws IOException, FormatException {
35

36
        try (Reader r = IOUtil.asNonClosingUTF8Reader(is)) {
2✔
37
            final InternalTAFParser parser = new InternalTAFParser(r);
2✔
38

39
            try {
40
                final Type type = parser.type();
2✔
41
                switch (type) {
2✔
42
                    case DFA: {
43
                        final DefaultTAFBuilderDFA<CompactDFA<String>, Integer> builder =
2✔
44
                                new DefaultTAFBuilderDFA<>(parser, new CompactDFA.Creator<>());
45
                        parser.dfaBody(builder);
2✔
46
                        return new InputModelData<>(builder.finish(), builder.getAlphabet());
2✔
47
                    }
48
                    case MEALY: {
49
                        final DefaultTAFBuilderMealy<CompactMealy<String, String>, Integer, CompactTransition<String>>
50
                                builder = new DefaultTAFBuilderMealy<>(parser, new CompactMealy.Creator<>());
2✔
51
                        parser.mealyBody(builder);
2✔
52
                        return new InputModelData<>(builder.finish(), builder.getAlphabet());
2✔
53
                    }
54
                    default:
NEW
55
                        throw new IllegalStateException("Unknown type " + type);
×
56
                }
57
            } catch (ParseException ex) {
2✔
58
                throw new FormatException(ex);
2✔
59
            }
60
        }
2✔
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc