Module JNISpice
Package spice.basic

Class 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 &ltfilename&gt" );
                   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

      Fields 
      Modifier and Type Field Description
      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

      Constructors 
      Constructor Description
      DAF​(java.lang.String fileName)
      Construct a DAF instance representing a file.The file need not exist.
    • Method Summary

      Modifier and Type Method Description
      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").
      private double[] getArraySummary()
      &gt&gt&gt Decide whether this method should be public.
      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.
        Parameters:
        fileName - String
    • Method Detail

      • openForRead

        public static DAF openForRead​(java.lang.String fileName)
                               throws SpiceException
        Open a DAF for read access.
        Parameters:
        fileName - String
        Returns:
        DAF
        Throws:
        SpiceException - exception
      • 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.

        Parameters:
        fileName - String
        Returns:
        DAF
        Throws:
        SpiceException - exception
      • getHandle

        public int getHandle()
        Get file handle.
        Returns:
        int
      • getFileName

        public java.lang.String getFileName()
        Return the file name.
        Returns:
        String
      • isReadable

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

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

        Returns:
        boolean
      • isWritable

        public boolean isWritable()
        Indicate whether a DAF is writable.
        Returns:
        boolean
      • getNI

        public int getNI()
        Get number of integer summary components.
        Returns:
        int
      • getND

        public int getND()
        Get number of double precision summary components.
        Returns:
        int
      • getInternalFileName

        public java.lang.String getInternalFileName()
                                             throws SpiceException
        Get internal file name.
        Returns:
        String
        Throws:
        SpiceException - exception
      • beginForwardSearch

        public void beginForwardSearch()
                                throws SpiceException
        Begin forward search through segment list.
        Throws:
        SpiceException - exception
      • beginBackwardSearch

        public void beginBackwardSearch()
                                 throws SpiceException
        Begin backward search through segment list.
        Throws:
        SpiceException - exception
      • findNextArray

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

        This methods returns a "found" flag.

        Returns:
        boolean
        Throws:
        SpiceException - exception
      • findPreviousArray

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

        This methods returns a "found" flag.

        Returns:
        boolean
        Throws:
        SpiceException - exception
      • 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").
        Returns:
        String
        Throws:
        SpiceException - exception
      • getArraySummary

        private double[] getArraySummary()
                                  throws SpiceException
        &gt&gt&gt Decide whether this method should be public. Get the summary (also called "descriptor") of 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.
        Returns:
        double[]
        Throws:
        SpiceException - exception
      • getIntegerSummaryComponent

        public int[] getIntegerSummaryComponent()
                                         throws SpiceException
        Get the integer component of the array summary for the current segment.
        Returns:
        int[]
        Throws:
        SpiceException - exception
      • addComments

        public void addComments​(java.lang.String[] commentBuffer)
                         throws SpiceException
        Add comments to an existing DAF.
        Parameters:
        commentBuffer - String[]
        Throws:
        SpiceException - exception
      • readComments

        public java.lang.String[] readComments​(int lineLength)
                                        throws SpiceException
        Read comments from an existing DAF.
        Parameters:
        lineLength - int
        Returns:
        String[]
        Throws:
        SpiceException - exception
      • countSegments

        public int countSegments()
                          throws SpiceException
        Count the segments in a DAF file.
        Returns:
        int
        Throws:
        SpiceException - exception