- java.lang.Object
-
- spice.basic.DAS
-
- 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.
- 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
- 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)
-
-
Method Summary
Modifier and Type Method Description 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
-
-
-
-
Constructor Detail
-
DLA
protected DLA(java.lang.String filename) throws SpiceErrorException
- Parameters:
filename
-- 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)
andDAS.openForWrite(java.lang.String)
.- Parameters:
das
- DAS- Throws:
SpiceException
- exception
-
-
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
-
getNext
public DLADescriptor getNext(DLADescriptor DLADescr) throws SpiceException
Get the DLA descriptor of the successor of a given DLA segment.- Parameters:
DLADescr
- DLADescriptor- Returns:
- DLADescriptor
- Throws:
SpiceException
- exception
-
getPrevious
public DLADescriptor getPrevious(DLADescriptor DLADescr) throws SpiceException
Get the DLA descriptor of the predecessor of a given DLA segment.- Parameters:
DLADescr
- DLADescriptor- Returns:
- DLADescriptor
- Throws:
SpiceException
- exception
-
getSegmentCount
public int getSegmentCount() throws SpiceException
Count the segments in a DLA file.- Returns:
- int
- Throws:
SpiceException
- exception
-
-