Minor reformatting.

This commit is contained in:
Jonathan Bernard 2013-07-19 18:47:45 -05:00
parent b56a708a09
commit 988ed2bb51

View File

@ -26,8 +26,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
ReadMark,
StartNotes,
ReadNotes,
EndMarker
};
EndMarker };
private InputStream in;
@ -39,18 +38,15 @@ public class StreamBasedTimelineSource extends TimelineSource {
super(null);
this.in = inStream;
this.out = outStream;
this.comments = new ByteArrayOutputStream();
}
this.comments = new ByteArrayOutputStream(); }
/** {@inheritDoc } */
public Timeline read() throws IOException {
return readFromStream(in, comments);
}
return readFromStream(in, comments); }
/** {@inheritDoc } */
public void persist(Timeline t) throws IOException {
writeToStream(out, t);
}
writeToStream(out, t); }
public void authenticate() throws AuthenticationException { }
public boolean isAuthenticated() { return true; }
@ -60,9 +56,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
* @return a <code>byte[]</code> representing the portions of the file
* which were comments.
*/
public byte[] getCommentBytes() {
return comments.toByteArray();
}
public byte[] getCommentBytes() { return comments.toByteArray(); }
/**
* Write the a representation of the timeline to a stream. This method
@ -89,8 +83,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
for (i = 0; (i + lineWrap) < mark.length(); i+=lineWrap)
out.write(mark.substring(i, i+lineWrap) + "\\\n");
if (i < mark.length())
out.write(mark.substring(i, mark.length()) + "\n");
}
out.write(mark.substring(i, mark.length()) + "\n"); }
// write notes
String notes = tm.getNotes().replace('\n', '\u0000');
@ -101,12 +94,9 @@ public class StreamBasedTimelineSource extends TimelineSource {
for (i = 0; (i + lineWrap) < notes.length(); i+=lineWrap)
out.write(notes.substring(i, i+lineWrap) + "\\\n");
if (i < notes.length())
out.write(notes.substring(i, notes.length()) + "\n");
}
out.write("\n");
}
out.flush();
}
out.write(notes.substring(i, notes.length()) + "\n"); }
out.write("\n"); }
out.flush(); }
/**
@ -118,8 +108,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
*/
public static Timeline readFromStream(InputStream stream)
throws IOException {
return readFromStream(stream, null);
}
return readFromStream(stream, null); }
/**
* Create a <b>Timeline</b> instance from a given stream.
@ -151,8 +140,8 @@ public class StreamBasedTimelineSource extends TimelineSource {
// line is a comment
if (line.startsWith("#")) {
if (commentsWriter != null) commentsWriter.println(line);
continue; // don't parse this line as part of the timeline
}
// don't parse this line as part of the timeline
continue; }
switch (readingState) {
@ -161,8 +150,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
catch (ParseException pe) {
throw new IOException("Error parsing timeline file at line "
+ lineNumber + ": expected a new marker date but could not parse"
+ " the date. Error: " + pe.getLocalizedMessage());
}
+ " the date. Error: " + pe.getLocalizedMessage()); }
readingState = ReadingState.StartMark;
break;
@ -172,8 +160,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
case ReadMark:
if (line.endsWith("\\")) {
readingState = ReadingState.ReadMark;
line = line.substring(0, line.length() - 1);
}
line = line.substring(0, line.length() - 1); }
else readingState = ReadingState.StartNotes;
mark.append(line);
break;
@ -184,8 +171,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
case ReadNotes:
if (line.endsWith("\\")) {
readingState = ReadingState.ReadNotes;
line = line.substring(0, line.length() - 1);
}
line = line.substring(0, line.length() - 1); }
else readingState = ReadingState.EndMarker;
notes.append(line);
break;
@ -194,10 +180,7 @@ public class StreamBasedTimelineSource extends TimelineSource {
String sMark = mark.toString().replace('\u0000', '\n');
String sNotes = notes.toString().replace('\u0000', '\n');
timeline.addMarker(d, sMark, sNotes);
readingState = ReadingState.NewMarker;
}
}
readingState = ReadingState.NewMarker; } }
return timeline;
}
return timeline; }
}