* @return a Segment instance deserialized from the stream.
*/
static Segment loadWithRecordTag(final RecordInputStream s) throws IOException {
final short[] paragraphRecordTags = SEGMENT_RECORD_TAGS;
final RecordHeaderInfo rhi = s.findRecord(paragraphRecordTags);
if (rhi == null) {
throw new IOException("Unable to find Segment record header.");
}
Segment segment;
switch (rhi.getRecordTag()) {
case ModuleSerializationTags.CALDOC_PLAIN_TEXT_SEGMENT:
segment = PlainTextSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_URL_SEGMENT:
segment = URLSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_MODULE_LINK_SEGMENT:
segment = ModuleLinkSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_FUNCTION_OR_CLASS_METHOD_LINK_SEGMENT:
segment = FunctionOrClassMethodLinkSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_TYPE_CONS_LINK_SEGMENT:
segment = TypeConsLinkSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_DATA_CONS_LINK_SEGMENT:
segment = DataConsLinkSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_TYPE_CLASS_LINK_SEGMENT:
segment = TypeClassLinkSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_CODE_SEGMENT:
segment = CodeSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_EMPHASIZED_SEGMENT:
segment = EmphasizedSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_STRONGLY_EMPHASIZED_SEGMENT:
segment = StronglyEmphasizedSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_SUPERSCRIPT_SEGMENT:
segment = SuperscriptSegment.load(s);
break;
case ModuleSerializationTags.CALDOC_SUBSCRIPT_SEGMENT:
segment = SubscriptSegment.load(s);
break;
default:
throw new IOException("Unrecognized record tag of " + rhi.getRecordTag() + " for Segment.");
}
s.skipRestOfRecord();
return segment;
}