Skip to content

Commit ae3b628

Browse files
committed
ASAPMessage has got a format
1 parent 5fff264 commit ae3b628

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/net/sharksystem/asap/ASAPChunkStorage.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
* @author thsc
1717
*/
1818
public interface ASAPChunkStorage {
19+
String getFormat();
1920

20-
public ASAPChunk getChunk(CharSequence uri, int era) throws IOException;
21+
ASAPChunk getChunk(CharSequence uri, int era) throws IOException;
2122

22-
public boolean existsChunk(CharSequence uri, int era) throws IOException;
23+
boolean existsChunk(CharSequence uri, int era) throws IOException;
2324

24-
public List<ASAPChunk> getChunks(int era) throws IOException;
25+
List<ASAPChunk> getChunks(int era) throws IOException;
2526

26-
public void dropChunks(int era) throws IOException;
27+
void dropChunks(int era) throws IOException;
2728

2829
/**
2930
*

src/net/sharksystem/asap/ASAPChunkStorageFS.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
class ASAPChunkStorageFS implements ASAPChunkStorage {
1919

2020
private final String rootDirectory;
21+
private final String format;
2122

22-
ASAPChunkStorageFS(String rootDirectory) {
23+
ASAPChunkStorageFS(String rootDirectory, String format) {
2324
this.rootDirectory = rootDirectory;
25+
this.format = format;
26+
}
27+
28+
public String getFormat() {
29+
return format;
2430
}
2531

2632
@Override
@@ -123,6 +129,7 @@ public ASAPMessages getASAPChunkCache(CharSequence uri, int toEra) throws IOExce
123129
}
124130

125131
return new ASAPInMemoMessages(this,
132+
this.getFormat(),
126133
uri,
127134
fromEra, // set starting era
128135
toEra // anything before

src/net/sharksystem/asap/ASAPEngineFS.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private ASAPEngineFS(String owner,
2222
String rootDirectory, ASAPChunkStorageFS chunkStorage, CharSequence format)
2323
throws ASAPException, IOException {
2424

25-
super(new ASAPChunkStorageFS(rootDirectory), format);
25+
super(new ASAPChunkStorageFS(rootDirectory, format.toString()), format);
2626

2727
this.owner = owner;
2828
this.rootDirectory = rootDirectory;
@@ -84,10 +84,11 @@ static ASAPEngineFS getASAPEngineFS(String owner, String rootDirectory, CharSequ
8484
throw new ASAPException("chunk root directory must exist when creating an ASAPEngine");
8585
}
8686

87+
String formatString = format != null ? format.toString() : ASAP_1_0.ANY_FORMAT;
8788
ASAPEngineFS engine = new ASAPEngineFS(
8889
owner,
8990
rootDirectory,
90-
new ASAPChunkStorageFS(rootDirectory),
91+
new ASAPChunkStorageFS(rootDirectory, formatString),
9192
ASAP_1_0.ANY_FORMAT // set to default - real value is restored by memento anyway
9293
);
9394

@@ -168,7 +169,7 @@ private ASAPMementoFS getMemento(String rootDirectory) {
168169
@Override
169170
public ASAPChunkStorage getIncomingChunkStorage(CharSequence sender) {
170171
String dir = this.rootDirectory + "/" + sender;
171-
return new ASAPChunkStorageFS(dir);
172+
return new ASAPChunkStorageFS(dir, this.format);
172173
}
173174

174175
public ASAPStorage getExistingIncomingStorage(CharSequence sender) throws IOException, ASAPException {

src/net/sharksystem/asap/ASAPInMemoMessages.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ASAPInMemoMessages implements ASAPMessages {
1818
private final ASAPChunkStorageFS chunkStorage;
1919
private final int fromEra;
2020
private final int toEra;
21+
private final String format;
2122

2223
private List<ASAPChunk> chunkList;
2324

@@ -30,8 +31,9 @@ class ASAPInMemoMessages implements ASAPMessages {
3031
private int numberOfMessages = 0;
3132

3233
public ASAPInMemoMessages(ASAPChunkStorageFS chunkStorage,
33-
CharSequence uri, int fromEra, int toEra, int maxCacheLen) {
34+
String format, CharSequence uri, int fromEra, int toEra, int maxCacheLen) {
3435

36+
this.format = format;
3537
this.uri = uri;
3638
this.chunkStorage = chunkStorage;
3739
this.fromEra = fromEra;
@@ -40,9 +42,9 @@ public ASAPInMemoMessages(ASAPChunkStorageFS chunkStorage,
4042
}
4143

4244
public ASAPInMemoMessages(ASAPChunkStorageFS chunkStorage,
43-
CharSequence uri, int fromEra, int toEra) {
45+
String format, CharSequence uri, int fromEra, int toEra) {
4446

45-
this(chunkStorage, uri, fromEra, toEra, DEFAULT_MAX_CACHE_SIZE);
47+
this(chunkStorage, format, uri, fromEra, toEra, DEFAULT_MAX_CACHE_SIZE);
4648
}
4749

4850
private boolean initialized = false;

0 commit comments

Comments
 (0)