/** * A factory method to construct specific sub-classes of section. * * @param sectionHeader the section header already read from the stream, containing the section * number * @param sections the sections that have already been read, in case values are needed for making * new sections * @return a section of the appropriate sub-class. */ public static Section makeSection(SectionHeader sectionHeader, TreeMap sections) { Section section = null; switch (sectionHeader.getSectionIDNumber()) { case 0: section = new Section0(sectionHeader); break; case 1: section = new Section1(sectionHeader); break; case 2: section = new Section2(sectionHeader); break; case 3: section = new Section3(sectionHeader); break; case 4: section = new Section4(sectionHeader); break; case 5: case 6: { Section3 section3 = (Section3) (sections.get(new Integer(3))); int numberOfleads = section3 == null ? 0 : section3.getNumberOfLeads(); section = new Section5Or6(sectionHeader, numberOfleads); } break; case 7: section = new Section7(sectionHeader); break; case 8: case 11: section = new Section8Or11(sectionHeader); break; case 10: section = new Section10(sectionHeader); break; default: section = new Section(sectionHeader); break; } return section; }
/** * Construct an empty section with the specified header. * * @param header the header (which has already been read) */ public Section(SectionHeader header) { this.header = header; bytesRead = 0; sectionBytesRemaining = header.getSectionLength() - header.getBytesRead(); }
/** Get section header information to the section node in a tree for display. */ protected void addSectionHeaderToTree(SCPTreeRecord parent) { header.getTree(parent); }
/** * Get the value to use as the value section of the section node in a tree for display. * * @return the value of just this node (not its contents) */ protected String getValueForSectionNodeInTree() { return Integer.toString(header.getSectionIDNumber()) + " " + getSectionName(); }