Browse Source

Update javadoc and clean naming.

Mikael Capelle 6 years ago
parent
commit
85fb193808

+ 15
- 12
src/main/org/insa/graph/io/BadFormatException.java View File

@@ -2,20 +2,23 @@ package org.insa.graph.io;
2 2
 
3 3
 import java.io.IOException;
4 4
 
5
+/**
6
+ * Exception thrown when a format-error is detected when reading a graph (e.g.,
7
+ * non-matching check bytes).
8
+ *
9
+ */
5 10
 public class BadFormatException extends IOException {
6 11
 
7
-	/**
8
-	 * 
9
-	 */
10
-	private static final long serialVersionUID = -5455552814725826052L;
12
+    /**
13
+     * 
14
+     */
15
+    private static final long serialVersionUID = 1L;
11 16
 
12
-	/**
13
-	 * 
14
-	 * @param actualVersion
15
-	 * @param expectedVersion
16
-	 */
17
-	public BadFormatException() {
18
-		super();
19
-	}
17
+    /**
18
+     *
19
+     */
20
+    public BadFormatException() {
21
+        super();
22
+    }
20 23
 
21 24
 }

+ 39
- 30
src/main/org/insa/graph/io/BadMagicNumberException.java View File

@@ -1,36 +1,45 @@
1 1
 package org.insa.graph.io;
2 2
 
3
-import java.io.IOException;
3
+/**
4
+ * Exception thrown when there is a mismatch between expected and actual magic
5
+ * number.
6
+ *
7
+ */
8
+public class BadMagicNumberException extends BadFormatException {
4 9
 
5
-public class BadMagicNumberException extends IOException {
10
+    /**
11
+     * 
12
+     */
13
+    private static final long serialVersionUID = -2176603967548838864L;
6 14
 
7
-	/**
8
-	 * 
9
-	 */
10
-	private static final long serialVersionUID = -2176603967548838864L;
11
-	
12
-	// Actual and expected magic numbers.
13
-	private int actualNumber, expectedNumber;
14
-	
15
-	/**
16
-	 * 
17
-	 * @param actualVersion
18
-	 * @param expectedVersion
19
-	 */
20
-	public BadMagicNumberException(int actualNumber, int expectedNumber) {
21
-		super();
22
-		this.actualNumber = actualNumber;
23
-		this.expectedNumber = expectedNumber;
24
-	}
25
-	
26
-	/**
27
-	 * 
28
-	 */
29
-	public int getActualMagicNumber() { return actualNumber; }
30
-	
31
-	/**
32
-	 * 
33
-	 */
34
-	public int getExpectedMagicNumber() { return expectedNumber; }
15
+    // Actual and expected magic numbers.
16
+    private int actualNumber, expectedNumber;
17
+
18
+    /**
19
+     * Create a new BadMagicNumberException with the given expected and actual magic
20
+     * number.
21
+     * 
22
+     * @param actualNumber Actual magic number (read from a file).
23
+     * @param expectedNumber Expected magic number.
24
+     */
25
+    public BadMagicNumberException(int actualNumber, int expectedNumber) {
26
+        super();
27
+        this.actualNumber = actualNumber;
28
+        this.expectedNumber = expectedNumber;
29
+    }
30
+
31
+    /**
32
+     * @return The actual magic number.
33
+     */
34
+    public int getActualMagicNumber() {
35
+        return actualNumber;
36
+    }
37
+
38
+    /**
39
+     * @return The expected magic number.
40
+     */
41
+    public int getExpectedMagicNumber() {
42
+        return expectedNumber;
43
+    }
35 44
 
36 45
 }

+ 37
- 30
src/main/org/insa/graph/io/BadVersionException.java View File

@@ -1,35 +1,42 @@
1 1
 package org.insa.graph.io;
2 2
 
3
-import java.io.IOException;
3
+/**
4
+ * Exception thrown when the version of the file is not at least the expected
5
+ * one.
6
+ *
7
+ */
8
+public class BadVersionException extends BadFormatException {
4 9
 
5
-public class BadVersionException extends IOException {
10
+    /**
11
+     * 
12
+     */
13
+    private static final long serialVersionUID = 7776317018302386042L;
6 14
 
7
-	/**
8
-	 * 
9
-	 */
10
-	private static final long serialVersionUID = 7776317018302386042L;
11
-	
12
-	// Actual and expected version..
13
-	private int actualVersion, expectedVersion;
14
-	
15
-	/**
16
-	 * 
17
-	 * @param actualVersion
18
-	 * @param expectedVersion
19
-	 */
20
-	public BadVersionException(int actualVersion, int expectedVersion) {
21
-		super();
22
-		this.actualVersion = actualVersion;
23
-		this.expectedVersion = expectedVersion;
24
-	}
25
-	
26
-	/**
27
-	 * 
28
-	 */
29
-	public int getActualVersion() { return actualVersion; }
30
-	
31
-	/**
32
-	 * 
33
-	 */
34
-	public int getExpectedVersion() { return expectedVersion; }
15
+    // Actual and expected version..
16
+    private int actualVersion, expectedVersion;
17
+
18
+    /**
19
+     * 
20
+     * @param actualVersion Actual version of the file.
21
+     * @param expectedVersion Expected version of the file.
22
+     */
23
+    public BadVersionException(int actualVersion, int expectedVersion) {
24
+        super();
25
+        this.actualVersion = actualVersion;
26
+        this.expectedVersion = expectedVersion;
27
+    }
28
+
29
+    /**
30
+     * @return Actual version of the file.
31
+     */
32
+    public int getActualVersion() {
33
+        return actualVersion;
34
+    }
35
+
36
+    /**
37
+     * @return Expected (minimal) version of the file.
38
+     */
39
+    public int getExpectedVersion() {
40
+        return expectedVersion;
41
+    }
35 42
 }

src/main/org/insa/graph/io/BinaryGraphReaderInsa2018.java → src/main/org/insa/graph/io/BinaryGraphReader.java View File

@@ -4,6 +4,7 @@ import java.io.DataInputStream;
4 4
 import java.io.IOException;
5 5
 import java.util.ArrayList;
6 6
 import java.util.EnumMap;
7
+import java.util.List;
7 8
 
8 9
 import org.insa.graph.AccessRestrictions;
9 10
 import org.insa.graph.AccessRestrictions.AccessMode;
@@ -16,7 +17,11 @@ import org.insa.graph.Point;
16 17
 import org.insa.graph.RoadInformation;
17 18
 import org.insa.graph.RoadInformation.RoadType;
18 19
 
19
-public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphReader {
20
+/**
21
+ * Implementation of {@link GraphReader} to read graph in binary format.
22
+ *
23
+ */
24
+public class BinaryGraphReader extends BinaryReader implements GraphReader {
20 25
 
21 26
     // Map version and magic number targeted for this reader.
22 27
     private static final int VERSION = 5;
@@ -25,13 +30,17 @@ public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphRead
25 30
     // Length of the map id field (in bytes)
26 31
     protected static final int MAP_ID_FIELD_LENGTH = 32;
27 32
 
33
+    // List of observers
34
+    protected List<GraphReaderObserver> observers = new ArrayList<>();
35
+
28 36
     /**
29
-     * Create a new access information by parsing the given value (V6 version).
37
+     * Parse the given long value into a new instance of AccessRestrictions.
38
+     * 
39
+     * @param access The value to parse.
30 40
      * 
31
-     * @param access
32
-     * @return
41
+     * @return New instance of access restrictions parsed from the given value.
33 42
      */
34
-    protected static AccessRestrictions toAccessInformationV7(final long access) {
43
+    protected static AccessRestrictions toAccessInformation(final long access) {
35 44
 
36 45
         // See the following for more information:
37 46
         // https://github.com/Holt59/OSM2Graph/blob/master/src/main/org/laas/osm2graph/model/AccessData.java
@@ -77,9 +86,8 @@ public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphRead
77 86
      * 
78 87
      * @param ch Character to convert.
79 88
      * 
80
-     * @return Road type corresponding to ch.
89
+     * @return Road type corresponding to the given character.
81 90
      * 
82
-     * @see http://wiki.openstreetmap.org/wiki/Highway_tag_usage.
83 91
      */
84 92
     protected static RoadType toRoadType(char ch) {
85 93
         switch (ch) {
@@ -125,15 +133,20 @@ public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphRead
125 133
     }
126 134
 
127 135
     /**
128
-     * Create a new BinaryGraphReader using the given DataInputStream.
136
+     * Create a new BinaryGraphReader that read from the given input stream.
129 137
      * 
130
-     * @param dis
138
+     * @param dis Input stream to read from.
131 139
      */
132
-    public BinaryGraphReaderInsa2018(DataInputStream dis) {
140
+    public BinaryGraphReader(DataInputStream dis) {
133 141
         super(MAGIC_NUMBER, VERSION, dis);
134 142
     }
135 143
 
136 144
     @Override
145
+    public void addObserver(GraphReaderObserver observer) {
146
+        observers.add(observer);
147
+    }
148
+
149
+    @Override
137 150
     public Graph read() throws IOException {
138 151
 
139 152
         // Read and check magic number and file version.
@@ -257,14 +270,16 @@ public class BinaryGraphReaderInsa2018 extends BinaryReader implements GraphRead
257 270
     /**
258 271
      * Read the next road information from the stream.
259 272
      * 
260
-     * @throws IOException
273
+     * @return The next RoadInformation in the stream.
274
+     * 
275
+     * @throws IOException if an error occurs while reading from the stream.
261 276
      */
262 277
     private RoadInformation readRoadInformation() throws IOException {
263 278
         char type = (char) dis.readUnsignedByte();
264 279
         int x = dis.readUnsignedByte();
265 280
         AccessRestrictions access = new AccessRestrictions();
266 281
         if (getCurrentVersion() >= 7) {
267
-            access = toAccessInformationV7(dis.readLong());
282
+            access = toAccessInformation(dis.readLong());
268 283
         }
269 284
         else if (getCurrentVersion() >= 6) {
270 285
             // TODO: Try to create something...

+ 18
- 4
src/main/org/insa/graph/io/BinaryPathReader.java View File

@@ -8,12 +8,21 @@ import org.insa.graph.Graph;
8 8
 import org.insa.graph.Node;
9 9
 import org.insa.graph.Path;
10 10
 
11
+/**
12
+ * Implementation of {@link PathReader} to read paths in binary format.
13
+ *
14
+ */
11 15
 public class BinaryPathReader extends BinaryReader implements PathReader {
12 16
 
13 17
     // Map version and magic number targeted for this reader.
14 18
     protected static final int VERSION = 1;
15 19
     protected static final int MAGIC_NUMBER = 0xdecafe;
16 20
 
21
+    /**
22
+     * Create a new BinaryPathReader that read from the given input stream.
23
+     * 
24
+     * @param dis Input stream to read from.
25
+     */
17 26
     public BinaryPathReader(DataInputStream dis) {
18 27
         super(MAGIC_NUMBER, VERSION, dis);
19 28
     }
@@ -26,7 +35,8 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
26 35
         checkVersionOrThrow(dis.readInt());
27 36
 
28 37
         // Read map ID and check against graph.
29
-        String mapId = readFixedLengthString(BinaryGraphReaderInsa2018.MAP_ID_FIELD_LENGTH, "UTF-8");
38
+        String mapId = readFixedLengthString(BinaryGraphReader.MAP_ID_FIELD_LENGTH,
39
+                "UTF-8");
30 40
 
31 41
         if (!mapId.equals(graph.getMapId())) {
32 42
             throw new MapMismatchException(mapId, graph.getMapId());
@@ -49,10 +59,14 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
49 59
     }
50 60
 
51 61
     /**
52
-     * Read a node from the stream and returns id.
62
+     * Read a node from the input stream and returns it.
63
+     * 
64
+     * @param graph Graph containing the nodes.
65
+     * 
66
+     * @return The next node in the input stream.
53 67
      * 
54
-     * @return
55
-     * @throws IOException
68
+     * @throws IOException if something occurs while reading the note.
69
+     * @throws IndexOutOfBoundsException if the node is not in the graph.
56 70
      */
57 71
     protected Node readNode(Graph graph) throws IOException {
58 72
         // Discard zone.

+ 8
- 2
src/main/org/insa/graph/io/BinaryPathWriter.java View File

@@ -7,10 +7,16 @@ import java.util.Arrays;
7 7
 import org.insa.graph.Arc;
8 8
 import org.insa.graph.Path;
9 9
 
10
+/**
11
+ * Implementation of {@link PathWriter} to write paths in binary format.
12
+ *
13
+ */
10 14
 public class BinaryPathWriter extends BinaryWriter implements PathWriter {
11 15
 
12 16
     /**
13
-     * @param dos
17
+     * Create a new BinaryPathWriter that writes to the given output stream.
18
+     * 
19
+     * @param dos Output stream to write to.
14 20
      */
15 21
     public BinaryPathWriter(DataOutputStream dos) {
16 22
         super(dos);
@@ -25,7 +31,7 @@ public class BinaryPathWriter extends BinaryWriter implements PathWriter {
25 31
 
26 32
         // Write map id.
27 33
         byte[] bytes = Arrays.copyOf(path.getGraph().getMapId().getBytes("UTF-8"),
28
-                BinaryGraphReaderInsa2018.MAP_ID_FIELD_LENGTH);
34
+                BinaryGraphReader.MAP_ID_FIELD_LENGTH);
29 35
         dos.write(bytes);
30 36
 
31 37
         // Write number of arcs

+ 39
- 30
src/main/org/insa/graph/io/BinaryReader.java View File

@@ -2,9 +2,11 @@ package org.insa.graph.io;
2 2
 
3 3
 import java.io.DataInputStream;
4 4
 import java.io.IOException;
5
-import java.util.ArrayList;
6
-import java.util.List;
7 5
 
6
+/**
7
+ * Base class for writing binary file.
8
+ *
9
+ */
8 10
 public abstract class BinaryReader {
9 11
 
10 12
     // Map version and magic number targeted for this reader.
@@ -15,9 +17,14 @@ public abstract class BinaryReader {
15 17
     // InputStream
16 18
     protected DataInputStream dis;
17 19
 
18
-    // List of observers
19
-    protected List<GraphReaderObserver> observers = new ArrayList<>();
20
-
20
+    /**
21
+     * Create a new BinaryReader that reads from the given stream and that expected
22
+     * the given magic number and at least the given minimum version.
23
+     * 
24
+     * @param magicNumber Magic number of files to be read.
25
+     * @param minVersion Minimum version of files to be read.
26
+     * @param dis Input stream from which to read.
27
+     */
21 28
     protected BinaryReader(int magicNumber, int minVersion, DataInputStream dis) {
22 29
         this.magicNumber = magicNumber;
23 30
         this.minVersion = minVersion;
@@ -25,18 +32,13 @@ public abstract class BinaryReader {
25 32
     }
26 33
 
27 34
     /**
28
-     * {@inheritDoc}
29
-     */
30
-    public void addObserver(GraphReaderObserver observer) {
31
-        observers.add(observer);
32
-    }
33
-
34
-    /**
35 35
      * Check if the given version is greater than the minimum version, and update
36 36
      * the current version if it is.
37 37
      * 
38
-     * @param version
39
-     * @throws BadVersionException
38
+     * @param version Version to check.
39
+     * 
40
+     * @throws BadVersionException if the given version is not greater than the
41
+     * minimum version.
40 42
      */
41 43
     protected void checkVersionOrThrow(int version) throws BadVersionException {
42 44
         if (version < this.minVersion) {
@@ -46,15 +48,18 @@ public abstract class BinaryReader {
46 48
     }
47 49
 
48 50
     /**
49
-     * @return the current version.
51
+     * @return The current version.
50 52
      */
51 53
     protected int getCurrentVersion() {
52 54
         return this.curVersion;
53 55
     }
54 56
 
55 57
     /**
56
-     * @param magicNumber
57
-     * @throws BadMagicNumberException
58
+     * Check if the given number matches the expected magic number.
59
+     * 
60
+     * @param magicNumber The magic number to check.
61
+     * 
62
+     * @throws BadMagicNumberException If the two magic numbers are not equal.
58 63
      */
59 64
     protected void checkMagicNumberOrThrow(int magicNumber) throws BadMagicNumberException {
60 65
         if (this.magicNumber != magicNumber) {
@@ -63,28 +68,31 @@ public abstract class BinaryReader {
63 68
     }
64 69
 
65 70
     /**
66
-     * Check if the next byte in the input stream correspond to the given byte. This
67
-     * function consumes the next byte in the input stream.
71
+     * Check if the next byte in the input stream correspond to the given byte.
72
+     * 
73
+     * This function consumes the next byte in the input stream.
68 74
      * 
69
-     * @param i Byte to check against.
75
+     * @param b Byte to check.
70 76
      * 
71
-     * @throws IOException
77
+     * @throws IOException if an error occurs while reading the byte.
78
+     * @throws BadFormatException if the byte read is not the expected one.
72 79
      */
73
-    protected void checkByteOrThrow(int i) throws IOException {
74
-        if (dis.readUnsignedByte() != i) {
80
+    protected void checkByteOrThrow(int b) throws IOException {
81
+        if (dis.readUnsignedByte() != b) {
75 82
             throw new BadFormatException();
76 83
         }
77 84
     }
78 85
 
79 86
     /**
80
-     * Read an bytes array of fixed length from the input and convert it to a string
87
+     * Read a byte array of fixed length from the input and convert it to a string
81 88
      * using the given charset, removing any trailing '\0'.
82 89
      * 
83
-     * @param length
84
-     * @param charset
90
+     * @param length Number of bytes to read.
91
+     * @param charset Charset to use to convert the bytes into a string.
92
+     * 
93
+     * @return The convert string.
85 94
      * 
86
-     * @return an UTF-8 string read from the input.
87
-     * @throws IOException
95
+     * @throws IOException if an error occurs while reading or converting.
88 96
      */
89 97
     protected String readFixedLengthString(int length, String charset) throws IOException {
90 98
         byte[] bytes = new byte[length];
@@ -93,11 +101,12 @@ public abstract class BinaryReader {
93 101
     }
94 102
 
95 103
     /**
96
-     * Read 24 bits from the stream and return the corresponding integer value.
104
+     * Read 24 bits in BigEndian order from the stream and return the corresponding
105
+     * integer value.
97 106
      * 
98 107
      * @return Integer value read from the next 24 bits of the stream.
99 108
      * 
100
-     * @throws IOException
109
+     * @throws IOException if an error occurs while reading from the stream.
101 110
      */
102 111
     protected int read24bits() throws IOException {
103 112
         int x = dis.readUnsignedShort();

+ 10
- 4
src/main/org/insa/graph/io/BinaryWriter.java View File

@@ -3,24 +3,30 @@ package org.insa.graph.io;
3 3
 import java.io.DataOutputStream;
4 4
 import java.io.IOException;
5 5
 
6
+/**
7
+ * Base class for writing binary file.
8
+ *
9
+ */
6 10
 public abstract class BinaryWriter {
7 11
 
8 12
     // Output stream.
9 13
     protected DataOutputStream dos;
10 14
 
11 15
     /**
12
-     * @param dos
16
+     * Create a new BinaryWriter that writes to the given output stream.
17
+     * 
18
+     * @param dos Stream to write to.
13 19
      */
14 20
     protected BinaryWriter(DataOutputStream dos) {
15 21
         this.dos = dos;
16 22
     }
17 23
 
18 24
     /**
19
-     * Write a 24-bits integer in BigEndian to the output stream.
25
+     * Write a 24-bits integer in BigEndian order to the output stream.
20 26
      * 
21
-     * @param value
27
+     * @param value Value to write.
22 28
      * 
23
-     * @throws IOException
29
+     * @throws IOException if an error occurs while writing to the stream.
24 30
      */
25 31
     protected void write24bits(int value) throws IOException {
26 32
         dos.writeShort(value >> 8);

+ 8
- 3
src/main/org/insa/graph/io/GraphReader.java View File

@@ -4,20 +4,25 @@ import java.io.IOException;
4 4
 
5 5
 import org.insa.graph.Graph;
6 6
 
7
+/**
8
+ * Base interface for classes that can read graph.
9
+ *
10
+ */
7 11
 public interface GraphReader {
8 12
 
9 13
     /**
10 14
      * Add a new observer to this graph reader.
11 15
      * 
12
-     * @param observer
16
+     * @param observer Observer to add.
13 17
      */
14 18
     public void addObserver(GraphReaderObserver observer);
15 19
 
16 20
     /**
17 21
      * Read a graph an returns it.
18 22
      * 
19
-     * @return Graph.
20
-     * @throws Exception
23
+     * @return The graph read.
24
+     * 
25
+     * @throws IOException When an exception occurs while reading the graph.
21 26
      * 
22 27
      */
23 28
     public Graph read() throws IOException;

+ 8
- 3
src/main/org/insa/graph/io/GraphReaderObserver.java View File

@@ -4,6 +4,11 @@ import org.insa.graph.Arc;
4 4
 import org.insa.graph.Node;
5 5
 import org.insa.graph.RoadInformation;
6 6
 
7
+/**
8
+ * Base interface that should be implemented by classes that want to observe the
9
+ * reading of a graph by a {@link GraphReader}.
10
+ *
11
+ */
7 12
 public interface GraphReaderObserver {
8 13
 
9 14
     /**
@@ -29,7 +34,7 @@ public interface GraphReaderObserver {
29 34
     /**
30 35
      * Notify that a new nodes has been read.
31 36
      * 
32
-     * @param node
37
+     * @param node read.
33 38
      */
34 39
     public void notifyNewNodeRead(Node node);
35 40
 
@@ -43,7 +48,7 @@ public interface GraphReaderObserver {
43 48
     /**
44 49
      * Notify that a new descriptor has been read.
45 50
      * 
46
-     * @param desc
51
+     * @param desc Descriptor read.
47 52
      */
48 53
     public void notifyNewDescriptorRead(RoadInformation desc);
49 54
 
@@ -57,7 +62,7 @@ public interface GraphReaderObserver {
57 62
     /**
58 63
      * Notify that a new arc has been read.
59 64
      * 
60
-     * @param arc
65
+     * @param arc Arc read.
61 66
      */
62 67
     public void notifyNewArcRead(Arc arc);
63 68
 

+ 13
- 6
src/main/org/insa/graph/io/MapMismatchException.java View File

@@ -2,19 +2,26 @@ package org.insa.graph.io;
2 2
 
3 3
 import java.io.IOException;
4 4
 
5
+/**
6
+ * Exception thrown when there is mismatch between the expected map ID and the
7
+ * actual map ID when reading a graph.
8
+ *
9
+ */
5 10
 public class MapMismatchException extends IOException {
6 11
 
7 12
     /**
8 13
      * 
9 14
      */
10
-    private static final long serialVersionUID = 3076730078387819138L;
11
-    // Actual and expected magic numbers.
15
+    private static final long serialVersionUID = 1L;
16
+
17
+    // Actual and expected map ID.
12 18
     private String actualMapId, expectedMapId;
13 19
 
14 20
     /**
21
+     * Create a new MapMismatchException with the given IDs.
15 22
      * 
16
-     * @param actualVersion
17
-     * @param expectedVersion
23
+     * @param actualMapId Actual map ID found when reading the path.
24
+     * @param expectedMapId Expected map ID from the graph.
18 25
      */
19 26
     public MapMismatchException(String actualMapId, String expectedMapId) {
20 27
         super();
@@ -23,14 +30,14 @@ public class MapMismatchException extends IOException {
23 30
     }
24 31
 
25 32
     /**
26
-     * @return
33
+     * @return Actual ID of the map (read from the path).
27 34
      */
28 35
     public String getActualMapId() {
29 36
         return actualMapId;
30 37
     }
31 38
 
32 39
     /**
33
-     * @return
40
+     * @return Expected ID of the map.
34 41
      */
35 42
     public String getExpectedMapId() {
36 43
         return expectedMapId;

+ 7
- 2
src/main/org/insa/graph/io/PathReader.java View File

@@ -5,6 +5,10 @@ import java.io.IOException;
5 5
 import org.insa.graph.Graph;
6 6
 import org.insa.graph.Path;
7 7
 
8
+/**
9
+ * Base interface that should be implemented by class used to read paths.
10
+ *
11
+ */
8 12
 public interface PathReader {
9 13
 
10 14
     /**
@@ -12,8 +16,9 @@ public interface PathReader {
12 16
      * 
13 17
      * @param graph Graph of the path.
14 18
      * 
15
-     * @return A new path.
16
-     * @throws Exception
19
+     * @return Path read.
20
+     * 
21
+     * @throws IOException When an error occurs while reading the path.
17 22
      */
18 23
     public Path readPath(Graph graph) throws IOException;
19 24
 

+ 6
- 2
src/main/org/insa/graph/io/PathWriter.java View File

@@ -4,14 +4,18 @@ import java.io.IOException;
4 4
 
5 5
 import org.insa.graph.Path;
6 6
 
7
+/**
8
+ * Base interface that should be implemented by class used to write paths.
9
+ *
10
+ */
7 11
 public interface PathWriter {
8 12
 
9 13
     /**
10
-     * Write a path.
14
+     * Write the given path.
11 15
      * 
12 16
      * @param path Path to write.
13 17
      * 
14
-     * @throws Exception
18
+     * @throws IOException When an error occurs while writing the path.
15 19
      */
16 20
     public void writePath(Path path) throws IOException;
17 21
 

+ 2
- 2
src/main/org/insa/graphics/MainWindow.java View File

@@ -57,7 +57,7 @@ import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsAlgorithm;
57 57
 import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsData;
58 58
 import org.insa.graph.Graph;
59 59
 import org.insa.graph.Path;
60
-import org.insa.graph.io.BinaryGraphReaderInsa2018;
60
+import org.insa.graph.io.BinaryGraphReader;
61 61
 import org.insa.graph.io.BinaryPathReader;
62 62
 import org.insa.graph.io.GraphReader;
63 63
 import org.insa.graph.io.MapMismatchException;
@@ -613,7 +613,7 @@ public class MainWindow extends JFrame {
613 613
                                 "Cannot open the selected file.");
614 614
                         return;
615 615
                     }
616
-                    loadGraph(new BinaryGraphReaderInsa2018(stream));
616
+                    loadGraph(new BinaryGraphReader(stream));
617 617
                 }
618 618
             }
619 619
         }));

Loading…
Cancel
Save