Module JNISpice
Package spice.basic

Class DLA

  • Direct Known Subclasses:
    DSK

    public class DLA
    extends DAS
    Class DLA supports forward and backward list traversal of DLA files.

    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.

    1. Open a DLA file for read access, traverse the segment list from front to back, and display segment address and size attributes.

      At the prompt, enter the name of the DSK file phobos_3_3.bds.

      Example code begins here.

      
      import java.io.*;
      import spice.basic.*;
      
      public class DLAEx1
      {
         //
         // Load the JNISpice shared library.
         //
         static{  System.loadLibrary( "JNISpice" );  }
      
      
         public static void main( String[] args )
         {
            //
            // Local variables
            //
            DLA                               dla;
            DLADescriptor                     dladsc;
            String                            dlaname;
            boolean                           found;     
            int                               segno;
      
            
            try
            {
               //
               // Get the name of the DLA file to read; open the file
               // for read access.
               //
               dlaname = IOUtils.prompt( "Name of DLA file &gt " );
      
               dla     = DLA.openForRead( dlaname );
      
               //
               // Begin a forward search. An exception will be thrown 
               // if the file doesn't contain at least one segment.
               //
               segno  = 0;
               dladsc = dla.beginForwardSearch();
               found  = true;
               
               while ( found )
               {
                  ++segno;
      
                  System.out.format ( "%n"                      +
                                      "Segment number = %d%n"   +
                                      "%n"                      +
                                      "   Backward segment pointer         = %d%n" +
                                      "   Forward segment pointer          = %d%n" +
                                      "   Integer component base address   = %d%n" +
                                      "   Integer component size           = %d%n" +
                                      "   D.p. component base address      = %d%n" +
                                      "   D.p. component size              = %d%n" +
                                      "   Character component base address = %d%n" +
                                      "   Character component size         = %d%n" +
                                      "%n",
                                      segno,
                                      dladsc.getBackwardPointer(),
                                      dladsc.getForwardPointer(),
                                      dladsc.getIntBase(),
                                      dladsc.getIntSize(),
                                      dladsc.getDoubleBase(),
                                      dladsc.getDoubleSize(),
                                      dladsc.getCharBase(),
                                      dladsc.getCharSize()                        );
      
                  //
                  // Find the next segment, if there is one.
                  //
                  found = dla.hasNext( dladsc );
      
                  if ( found )
                  {
                     dladsc = dla.getNext( dladsc );
                  }
               }
      
            }
            catch ( java.io.IOException exc )
            {
               //
               // Handle exception raised by IOUtils.prompt call.
               //
               exc.printStackTrace();
            }
            catch ( SpiceException exc )
            {
               exc.printStackTrace();
            }
         }
      }
      
      
      

      When this program was executed on a PC/Linux/gcc/64-bit/java 1.5 platform, the output was:

      
      Name of DLA file &gt phobos_3_3.bds
      
      Segment number = 1
      
         Backward segment pointer         = -1
         Forward segment pointer          = -1
         Integer component base address   = 11
         Integer component size           = 3311271
         D.p. component base address      = 0
         D.p. component size              = 494554
         Character component base address = 0
         Character component size         = 0
      
      
      
    2. Open a DLA file for read access, traverse the segment list from back to front, and display segment address and size attributes.

      At the prompt, enter the name of the DSK file phobos_3_3.bds.

      Example code begins here.

      
      import java.io.*;
      import spice.basic.*;
      
      public class DLAEx2
      {
         //
         // Load the JNISpice shared library.
         //
         static{  System.loadLibrary( "JNISpice" );  }
      
      
         public static void main( String[] args )
         {
            //
            // Local variables
            //
            DLA                               dla;
            DLADescriptor                     dladsc;
            String                            dlaname;
            boolean                           found;     
            int                               segno;
      
            
            try
            {
               //
               // Get the name of the DLA file to read; open the file
               // for read access.
               //
               System.out.format( "%n" );
      
               dlaname = IOUtils.prompt( "Name of DLA file &gt " );
      
               dla     = DLA.openForRead( dlaname );
      
               //
               // Begin a backward search. An exception will be thrown 
               // if the file doesn't contain at least one segment.
               //
               segno  = 0;
               dladsc = dla.beginBackwardSearch();
               found  = true;
               
               while ( found )
               {
                  ++segno;
      
                  System.out.format ( "%n"                                         +
                                      "Segment number (offset from end of file) "  +
                                      "= %d%n"                                     +
                                      "%n"                                         +
                                      "   Backward segment pointer         = %d%n" +
                                      "   Forward segment pointer          = %d%n" +
                                      "   Integer component base address   = %d%n" +
                                      "   Integer component size           = %d%n" +
                                      "   D.p. component base address      = %d%n" +
                                      "   D.p. component size              = %d%n" +
                                      "   Character component base address = %d%n" +
                                      "   Character component size         = %d%n" +
                                      "%n",
                                      segno - 1,
                                      dladsc.getBackwardPointer(),
                                      dladsc.getForwardPointer(),
                                      dladsc.getIntBase(),
                                      dladsc.getIntSize(),
                                      dladsc.getDoubleBase(),
                                      dladsc.getDoubleSize(),
                                      dladsc.getCharBase(),
                                      dladsc.getCharSize()                        );
      
                  //
                  // Find the previous segment, if there is one.
                  //
                  found = dla.hasPrevious( dladsc );
      
                  if ( found )
                  {
                     dladsc = dla.getPrevious( dladsc );
                  }
               }
      
            }
            catch ( java.io.IOException exc )
            {
               //
               // Handle exception raised by IOUtils.prompt call.
               //
               exc.printStackTrace();
            }
            catch ( SpiceException exc )
            {
               exc.printStackTrace();
            }
         }
      }
      
      

      When this program was executed on a PC/Linux/gcc/64-bit/java 1.5 platform, the output was:

      
      Name of DLA file &gt phobos_3_3.bds
      
      Segment number (offset from end of file) = 0
      
         Backward segment pointer         = -1
         Forward segment pointer          = -1
         Integer component base address   = 11
         Integer component size           = 3311271
         D.p. component base address      = 0
         D.p. component size              = 494554
         Character component base address = 0
         Character component size         = 0
      
      
      

    Author_and_Version

    Version 1.0.0 09-JAN-2017 (NJB)
    • Method Detail

      • openForRead

        public static DLA openForRead​(java.lang.String filename)
                               throws SpiceException
        Open a DLA file for read access.
        Parameters:
        filename - String
        Returns:
        DLA
        Throws:
        SpiceException - exception
      • beginForwardSearch

        public DLADescriptor beginForwardSearch()
                                         throws SpiceException
        Start a forward search on a DLA file.

        An exception is thrown if the file contains no segments.

        Returns:
        DLADescriptor
        Throws:
        SpiceException - exception
      • beginBackwardSearch

        public DLADescriptor beginBackwardSearch()
                                          throws SpiceException
        Start a backward search on a DLA file.

        An exception is thrown if the file contains no segments.

        Returns:
        DLADescriptor
        Throws:
        SpiceException - exception
      • hasNext

        public boolean hasNext​(DLADescriptor DLADescr)
                        throws SpiceException
        Indicate whether a DLA segment has a successor.
        Parameters:
        DLADescr - DLADescriptor
        Returns:
        boolean
        Throws:
        SpiceException - exception
      • hasPrevious

        public boolean hasPrevious​(DLADescriptor DLADescr)
                            throws SpiceException
        Indicate whether a DLA segment has a predecessor.
        Parameters:
        DLADescr - DLADescriptor
        Returns:
        boolean
        Throws:
        SpiceException - exception
      • getSegmentCount

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