Package jmri.jmrix.loconet.spjfile
Class SpjFile
- java.lang.Object
-
- jmri.jmrix.loconet.spjfile.SpjFile
-
public class SpjFile extends java.lang.Object
Provide tools for reading, writing and accessing Digitrax SPJ files.Four-byte quantities in SPJ files are little-endian.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
SpjFile.FirstHeader
Class representing first headerclass
SpjFile.Header
Class representing a header record.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.File
file
(package private) SpjFile.FirstHeader
h0
(package private) SpjFile.Header[]
headers
(package private) java.lang.String[]
mapCache
-
Constructor Summary
Constructors Constructor Description SpjFile(java.io.File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
SpjFile.Header
findSdfHeader()
java.lang.String
getComment()
SpjFile.Header
getHeader(int index)
java.lang.String
getMapEntry(int i)
Find the map entry (character string) that corresponds to a particular handle number.(package private) void
loadMapCache()
int
numHeaders()
Number of headers present in the file.void
read()
Read the file whose name was provided earlier.void
save(java.lang.String name)
Save this file.(package private) void
writeSubFile(int i, java.lang.String name)
Write the content from a specific header as a new "subfile".void
writeSubFiles()
Write data from headers into separate files.
-
-
-
Field Detail
-
mapCache
java.lang.String[] mapCache
-
file
java.io.File file
-
headers
SpjFile.Header[] headers
-
-
Constructor Detail
-
SpjFile
public SpjFile(java.io.File file)
-
-
Method Detail
-
numHeaders
public int numHeaders()
Number of headers present in the file.- Returns:
- -1 if error
-
getComment
public java.lang.String getComment()
-
getHeader
public SpjFile.Header getHeader(int index)
-
findSdfHeader
public SpjFile.Header findSdfHeader()
-
getMapEntry
public java.lang.String getMapEntry(int i)
Find the map entry (character string) that corresponds to a particular handle number.- Parameters:
i
- handle index.- Returns:
- string of map entry.
-
loadMapCache
void loadMapCache()
-
save
public void save(java.lang.String name) throws java.io.IOException
Save this file.It lays the file out again, changing the record start addresses into a sequential series.
- Parameters:
name
- file name.- Throws:
java.io.IOException
- if anything goes wrong
-
read
public void read() throws java.io.IOException
Read the file whose name was provided earlier.- Throws:
java.io.IOException
- on file error.
-
writeSubFiles
public void writeSubFiles() throws java.io.IOException
Write data from headers into separate files.Normally, we just work with the data within this file. This method allows us to extract the contents of the file for external use.
- Throws:
java.io.IOException
- on file error.
-
writeSubFile
void writeSubFile(int i, java.lang.String name) throws java.io.IOException
Write the content from a specific header as a new "subfile".- Parameters:
i
- index of the specific headername
- filename- Throws:
java.io.IOException
- based on underlying activity
-
dispose
public void dispose()
-
-