public PageInformationSegment findPageSegement(int page) { foreach (Segment segment in segments) { SegmentHeader segmentHeader = segment.getSegmentHeader(); if (segmentHeader.getSegmentType() == Segment.PAGE_INFORMATION && segmentHeader.getPageAssociation() == page) { return((PageInformationSegment)segment); } } return(null); }
private void readSegmentHeader(SegmentHeader segmentHeader) { handleSegmentNumber(segmentHeader); handleSegmentHeaderFlags(segmentHeader); handleSegmentReferredToCountAndRententionFlags(segmentHeader); handleReferedToSegmentNumbers(segmentHeader); handlePageAssociation(segmentHeader); if (segmentHeader.getSegmentType() != Segment.END_OF_FILE) { handleSegmentDataLength(segmentHeader); } }
private void readSegments() { bool finished = false; while (!reader.isFinished() && !finished) { SegmentHeader segmentHeader = new SegmentHeader(); readSegmentHeader(segmentHeader); // read the Segment data Segment segment = null; int segmentType = segmentHeader.getSegmentType(); int[] referredToSegments = segmentHeader.getReferredToSegments(); int noOfReferredToSegments = segmentHeader.getReferredToSegmentCount(); switch (segmentType) { case Segment.SYMBOL_DICTIONARY: segment = new SymbolDictionarySegment(this); segment.setSegmentHeader(segmentHeader); break; case Segment.INTERMEDIATE_TEXT_REGION: segment = new TextRegionSegment(this, false); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_TEXT_REGION: segment = new TextRegionSegment(this, true); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_LOSSLESS_TEXT_REGION: segment = new TextRegionSegment(this, true); segment.setSegmentHeader(segmentHeader); break; case Segment.PATTERN_DICTIONARY: segment = new PatternDictionarySegment(this); segment.setSegmentHeader(segmentHeader); break; case Segment.INTERMEDIATE_HALFTONE_REGION: segment = new HalftoneRegionSegment(this, false); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_HALFTONE_REGION: segment = new HalftoneRegionSegment(this, true); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_LOSSLESS_HALFTONE_REGION: segment = new HalftoneRegionSegment(this, true); segment.setSegmentHeader(segmentHeader); break; case Segment.INTERMEDIATE_GENERIC_REGION: segment = new GenericRegionSegment(this, false); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_GENERIC_REGION: segment = new GenericRegionSegment(this, true); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_LOSSLESS_GENERIC_REGION: segment = new GenericRegionSegment(this, true); segment.setSegmentHeader(segmentHeader); break; case Segment.INTERMEDIATE_GENERIC_REFINEMENT_REGION: segment = new RefinementRegionSegment(this, false, referredToSegments, noOfReferredToSegments); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_GENERIC_REFINEMENT_REGION: segment = new RefinementRegionSegment(this, true, referredToSegments, noOfReferredToSegments); segment.setSegmentHeader(segmentHeader); break; case Segment.IMMEDIATE_LOSSLESS_GENERIC_REFINEMENT_REGION: segment = new RefinementRegionSegment(this, true, referredToSegments, noOfReferredToSegments); segment.setSegmentHeader(segmentHeader); break; case Segment.PAGE_INFORMATION: segment = new PageInformationSegment(this); segment.setSegmentHeader(segmentHeader); break; case Segment.END_OF_PAGE: continue; case Segment.END_OF_STRIPE: segment = new EndOfStripeSegment(this); segment.setSegmentHeader(segmentHeader); break; case Segment.END_OF_FILE: finished = true; continue; case Segment.PROFILES: break; case Segment.TABLES: break; case Segment.EXTENSION: segment = new ExtensionSegment(this); segment.setSegmentHeader(segmentHeader); break; default: break; } if (!randomAccessOrganisation) { segment.readSegment(); } segments.Add(segment); } if (randomAccessOrganisation) { foreach (Segment segment in segments) { segment.readSegment(); } } }