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) classSpjFile.FirstHeaderClass representing first headerclassSpjFile.HeaderClass representing a header record.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.Filefile(package private) SpjFile.FirstHeaderh0(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 voiddispose()SpjFile.HeaderfindSdfHeader()java.lang.StringgetComment()SpjFile.HeadergetHeader(int index)java.lang.StringgetMapEntry(int i)Find the map entry (character string) that corresponds to a particular handle number.(package private) voidloadMapCache()intnumHeaders()Number of headers present in the file.voidread()Read the file whose name was provided earlier.voidsave(java.lang.String name)Save this file.(package private) voidwriteSubFile(int i, java.lang.String name)Write the content from a specific header as a new "subfile".voidwriteSubFiles()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()
-
-