JNISpice
version 2.0.0

spice.basic
Class DAF

java.lang.Object
  extended by spice.basic.DAF
Direct Known Subclasses:
CK, PCK, SPK

public class DAF
extends java.lang.Object

Class DAF supports creation of and low-level read operations on DAF files.

This class supports DAF segment descriptor list traversal and comment area access.

See the subclasses SPK and CK for methods used to write those types of files.

Normal read access of SPK, CK, and binary PCK files requires that these files be loaded via KernelDatabase.load(java.lang.String). This method plays the role of the routine FURNSH in SPICELIB.

Examples

The numerical results shown for this example may differ across platforms. The results depend on the SPICE kernels used as input, the compiler and supporting libraries, and the machine specific arithmetic implementation.

   //
   // Example of DAF segment descriptor list traversal
   //

   import spice.basic.*;

   public class DAF_ex1
   {
      //
      // Load the JNISpice shared object library before program execution.
      //
      static
      {
         System.loadLibrary( "JNISpice" );
      }

      public static void main ( String[] args )
      {
         try
         {
            //
            // Constants
            //
            final String TIMFMT =  new String (
                                  "YYYY MON DD HR:MN:SC.###### (TDB)::TDB" );

            //
            // Local variables
            //
            boolean      found;
            DAF          d;
            double[]     dc;
            int          segno = 0;
            int[]        ic;
            String       bstr;
            String       estr;

            //
            // Load a leapseconds kernel to support time conversion.
            //
            KernelDatabase.load ( "naif0009.tls" );

            //
            // Create a DAF instance and open the DAF for
            // read access. We expect the name of the DAF
            // to be supplied on the command line.
            //
            if ( args.length == 0 )
            {
               System.out.println ( "Usage: java DAF_ex1 " );
               return;
            }

            d = DAF.openForRead( args[0] );

            //
            // Start a forward search through the segment list
            // of this DAF.
            //
            d.beginForwardSearch();

            found = d.findNextArray();

            while ( found )
            {
               ++segno;

               //
               // Get integer portion of current array summary
               // (aka descriptor).
               //
               ic = d.getIntegerSummaryComponent();
               dc = d.getDoubleSummaryComponent();

               System.out.format  ( "%n%nSegment%n%n", segno );

               System.out.println ( "Body ID       = " + ic[0] );
               System.out.println ( "Center ID     = " + ic[1] );
               System.out.println ( "Frame ID      = " + ic[2] );
               System.out.println ( "Data Type     = " + ic[3] );
               System.out.println ( "Begin address = " + ic[4] );
               System.out.println ( "End address   = " + ic[5] );

               bstr = CSPICE.timout ( dc[0], TIMFMT );
               estr = CSPICE.timout ( dc[1], TIMFMT );

               System.out.println ( "Start time    = " + bstr );
               System.out.println ( "Stop time     = " + estr );

               //
               // Find the next segment.
               //
               found = d.findNextArray();
            }

            //
            // Close the DAF.
            //
            d.close();
         }
         catch ( SpiceException exc )
         {
            exc.printStackTrace();
         }
      }
   }
When executed on a PC/Linux/gcc/java 1.6.0_14 platform, the output from this program was (only partial output is shown):


   Segment 1

   Body ID       = 1
   Center ID     = 0
   Frame ID      = 1
   Data Type     = 2
   Begin address = 641
   End address   = 310404
   Start time    = 1899 JUL 29 00:00:00.000000 (TDB)
   Stop time     = 2053 OCT 09 00:00:00.000000 (TDB)


   Segment 2

   Body ID       = 2
   Center ID     = 0
   Frame ID      = 1
   Data Type     = 2
   Begin address = 310405
   End address   = 423048
   Start time    = 1899 JUL 29 00:00:00.000000 (TDB)
   Stop time     = 2053 OCT 09 00:00:00.000000 (TDB)


     ...


   Segment 15

   Body ID       = 499
   Center ID     = 4
   Frame ID      = 1
   Data Type     = 2
   Begin address = 2098633
   End address   = 2098644
   Start time    = 1899 JUL 29 00:00:00.000000 (TDB)
   Stop time     = 2053 OCT 09 00:00:00.000000 (TDB)
   

Author_and_Version

Version 1.0.0 19-DEC-2009 (NJB)


Field Summary
protected  java.lang.String fileName
           
protected  int handle
           
protected  java.lang.String internalFileName
           
protected  int ND
           
protected  int NI
           
protected  boolean readable
           
protected  boolean writable
           
 
Constructor Summary
DAF(java.lang.String fileName)
          Construct a DAF instance representing a file.
 
Method Summary
 void addComments(java.lang.String[] commentBuffer)
          Add comments to an existing DAF.
 void beginBackwardSearch()
          Begin backward search through segment list.
 void beginForwardSearch()
          Begin forward search through segment list.
 void close()
          Close a specified DAF, thereby freeing resources.
 int countSegments()
          Count the segments in a DAF file.
 void deleteComments()
          Delete comments from a DAF.
 boolean findNextArray()
          Find the next array in the segment list.
 boolean findPreviousArray()
          Find the previous array in the segment list.
 java.lang.String getArrayName()
          Get the array name (also called the "segment identifier") (also called the "array name") for the current array (also called "segment").
 double[] getDoubleSummaryComponent()
          Get the double precision component of the array summary for the current segment.
 java.lang.String getFileName()
          Return the file name.
 int getHandle()
          Get file handle.
 int[] getIntegerSummaryComponent()
          Get the integer component of the array summary for the current segment.
 java.lang.String getInternalFileName()
          Get internal file name.
 int getND()
          Get number of double precision summary components.
 int getNI()
          Get number of integer summary components.
 boolean isReadable()
          Indicate whether a DAF is readable.
 boolean isWritable()
          Indicate whether a DAF is writable.
static DAF openForRead(java.lang.String fileName)
          Open a DAF for read access.
static DAF openForWrite(java.lang.String fileName)
          Open an existing DAF for write access.
 java.lang.String[] readComments(int lineLength)
          Read comments from an existing DAF.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileName

protected java.lang.String fileName

handle

protected int handle

internalFileName

protected java.lang.String internalFileName

ND

protected int ND

NI

protected int NI

readable

protected boolean readable

writable

protected boolean writable
Constructor Detail

DAF

public DAF(java.lang.String fileName)
Construct a DAF instance representing a file. The file need not exist.

Method Detail

openForRead

public static DAF openForRead(java.lang.String fileName)
                       throws SpiceException
Open a DAF for read access.

Throws:
SpiceException

openForWrite

public static DAF openForWrite(java.lang.String fileName)
                        throws SpiceException
Open an existing DAF for write access.

Note that a DAF cannot be opened for write access if it has already been opened for read access.

Throws:
SpiceException

getHandle

public int getHandle()
Get file handle.


getFileName

public java.lang.String getFileName()
Return the file name.


isReadable

public boolean isReadable()
Indicate whether a DAF is readable.

A DAF is readable if it has been opened for read OR write access.


isWritable

public boolean isWritable()
Indicate whether a DAF is writable.


getNI

public int getNI()
Get number of integer summary components.


getND

public int getND()
Get number of double precision summary components.


getInternalFileName

public java.lang.String getInternalFileName()
                                     throws SpiceException
Get internal file name.

Throws:
SpiceException

beginForwardSearch

public void beginForwardSearch()
                        throws SpiceException
Begin forward search through segment list.

Throws:
SpiceException

beginBackwardSearch

public void beginBackwardSearch()
                         throws SpiceException
Begin backward search through segment list.

Throws:
SpiceException

findNextArray

public boolean findNextArray()
                      throws SpiceException
Find the next array in the segment list.

This methods returns a "found" flag.

Throws:
SpiceException

findPreviousArray

public boolean findPreviousArray()
                          throws SpiceException
Find the previous array in the segment list.

This methods returns a "found" flag.

Throws:
SpiceException

getArrayName

public java.lang.String getArrayName()
                              throws SpiceException
Get the array name (also called the "segment identifier") (also called the "array name") for the current array (also called "segment").

Throws:
SpiceException

getDoubleSummaryComponent

public double[] getDoubleSummaryComponent()
                                   throws SpiceException
Get the double precision component of the array summary for the current segment.

Throws:
SpiceException

getIntegerSummaryComponent

public int[] getIntegerSummaryComponent()
                                 throws SpiceException
Get the integer component of the array summary for the current segment.

Throws:
SpiceException

close

public void close()
           throws SpiceException
Close a specified DAF, thereby freeing resources.

Throws:
SpiceException

addComments

public void addComments(java.lang.String[] commentBuffer)
                 throws SpiceException
Add comments to an existing DAF.

Throws:
SpiceException

readComments

public java.lang.String[] readComments(int lineLength)
                                throws SpiceException
Read comments from an existing DAF.

Throws:
SpiceException

deleteComments

public void deleteComments()
                    throws SpiceException
Delete comments from a DAF.

Throws:
SpiceException

countSegments

public int countSegments()
                  throws SpiceException
Count the segments in a DAF file.

Throws:
SpiceException

JNISpice
version 2.0.0

JNISpice Alpha Test Version 2.0.0 28-JAN-2017 (NJB)