Updated to worldwind release 20070817
[worldwind-tracker.git] / gov / nasa / worldwind / formats / rpf / RpfTocFile.java
blobf389d59ae068f59a91ec9a0adbe2a6a8faf2bc3e
1 package gov.nasa.worldwind.formats.rpf;
3 import gov.nasa.worldwind.*;
4 import gov.nasa.worldwind.formats.nitfs.*;
6 import java.io.*;
7 import java.text.*;
8 /*
9 Copyright (C) 2001, 2007 United States Government
10 as represented by the Administrator of the
11 National Aeronautics and Space Administration.
12 All Rights Reserved.
15 /**
16 * @author Lado Garakanidze
17 * @version $Id: RpfTocFile Apr 4, 2007 2:24:00 PM lado
19 public class RpfTocFile extends RpfFile
21 private RpfFileComponents rpfFileComponents;
23 public RpfHeaderSection getHeaderSection()
25 return (null != this.rpfFileComponents) ? this.rpfFileComponents.getRpfHeaderSection() : null;
28 public RpfFrameFileIndexSection getFrameFileIndexSection()
30 return (null != this.rpfFileComponents) ? this.rpfFileComponents.getRpfFrameFileIndexSection() : null;
33 public RpfFileComponents getRpfFileComponents()
35 return this.rpfFileComponents;
38 protected RpfTocFile(java.io.File rpfFile) throws IOException, NitfsRuntimeException
40 super(rpfFile);
42 RpfUserDefinedHeaderSegment segment =
43 (RpfUserDefinedHeaderSegment)this.getNitfsSegment( NitfsSegmentType.UserDefinedHeaderSegment );
45 if(null == segment)
46 throw new NitfsRuntimeException("NitfsReader.UserDefinedHeaderSegmentWasNotFound");
48 this.rpfFileComponents = segment.getRpfFileComponents();
49 if(null == this.rpfFileComponents)
50 throw new NitfsRuntimeException("NitfsReader.RpfFileComponents.Were.Not.Found.In.UserDefinedHeaderSegment");
53 public static RpfTocFile load(java.io.File tocFile) throws java.io.IOException
55 return new RpfTocFile(tocFile);
58 public static void main(String args[])
60 String testTocFilename = (Configuration.isWindowsOS()) ? "C:\\RPF\\A.TOC" : "/depot/WorldWindJ/utils/rpf/A.TOC";
61 try
63 long startTime = System.currentTimeMillis();
65 RpfTocFile toc = RpfTocFile.load(new File(testTocFilename));
67 System.out.println(MessageFormat.format("TOC file loaded in {0} mSec", (System.currentTimeMillis() - startTime)));
69 catch (Exception e)
71 System.out.println(e.getMessage());
72 e.printStackTrace();