JNISpice
version 2.0.0

spice.basic
Class DLA

java.lang.Object
  extended by spice.basic.DAS
      extended by spice.basic.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 > " );
    
             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 > 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 > " );
    
             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 > 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)


Field Summary
 
Fields inherited from class spice.basic.DAS
fileName, handle, readable, writable
 
Constructor Summary
  DLA()
          No-args constructor.
protected DLA(DAS das)
          Construct a DLA instance from a DAS instance.
protected DLA(java.lang.String filename)
           
 
Method Summary
 DLADescriptor beginBackwardSearch()
          Start a backward search on a DLA file.
 DLADescriptor beginForwardSearch()
          Start a forward search on a DLA file.
 DLADescriptor getNext(DLADescriptor DLADescr)
          Get the DLA descriptor of the successor of a given DLA segment.
 DLADescriptor getPrevious(DLADescriptor DLADescr)
          Get the DLA descriptor of the predecessor of a given DLA segment.
 int getSegmentCount()
          Count the segments in a DLA file.
 boolean hasNext(DLADescriptor DLADescr)
          Indicate whether a DLA segment has a successor.
 boolean hasPrevious(DLADescriptor DLADescr)
          Indicate whether a DLA segment has a predecessor.
static DLA openForRead(java.lang.String filename)
          Open a DLA file for read access.
 
Methods inherited from class spice.basic.DAS
addComments, close, deleteComments, getCommentCharacterCount, getCommentRecordCount, getFileName, getHandle, getInternalFileName, isReadable, isWritable, openForWrite, readComments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DLA

protected DLA(java.lang.String filename)
       throws SpiceErrorException
Throws:
SpiceErrorException

DLA

public DLA()
No-args constructor.


DLA

protected DLA(DAS das)
       throws SpiceException
Construct a DLA instance from a DAS instance. This constructor creates a deep copy.

The DAL file must have type DLA or DSK.

User applications will not need to call this constructor directly. See the methods openForRead(java.lang.String) and DAS.openForWrite(java.lang.String).

Throws:
SpiceException
Method Detail

openForRead

public static DLA openForRead(java.lang.String filename)
                       throws SpiceException
Open a DLA file for read access.

Throws:
SpiceException

beginForwardSearch

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

An exception is thrown if the file contains no segments.

Throws:
SpiceException

beginBackwardSearch

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

An exception is thrown if the file contains no segments.

Throws:
SpiceException

hasNext

public boolean hasNext(DLADescriptor DLADescr)
                throws SpiceException
Indicate whether a DLA segment has a successor.

Throws:
SpiceException

hasPrevious

public boolean hasPrevious(DLADescriptor DLADescr)
                    throws SpiceException
Indicate whether a DLA segment has a predecessor.

Throws:
SpiceException

getNext

public DLADescriptor getNext(DLADescriptor DLADescr)
                      throws SpiceException
Get the DLA descriptor of the successor of a given DLA segment.

Throws:
SpiceException

getPrevious

public DLADescriptor getPrevious(DLADescriptor DLADescr)
                          throws SpiceException
Get the DLA descriptor of the predecessor of a given DLA segment.

Throws:
SpiceException

getSegmentCount

public int getSegmentCount()
                    throws SpiceException
Count the segments in a DLA file.

Throws:
SpiceException

JNISpice
version 2.0.0

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