public class SPSSFile extends RandomAccessFile
| Constructor and Description |
|---|
SPSSFile(File file)
Constructor
|
SPSSFile(File file,
Charset charset)
Constructor
|
SPSSFile(File file,
String mode)
Constructor
|
SPSSFile(File file,
String mode,
Charset charset)
Constructor
|
SPSSFile(String name)
Constructor
|
SPSSFile(String name,
Charset charset)
Constructor
|
SPSSFile(String name,
String mode)
Constructor
|
SPSSFile(String name,
String mode,
Charset charset)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
dumpData()
Dumps the file data to the console (for debugging purposes)
|
void |
dumpData(int nRecords)
Dumps the file data to the console (for debugging purposes)
|
void |
dumpData(int nRecords,
FileFormatInfo dataFormat)
Dumps the file data (for debugging purposes)
|
void |
dumpDDI2()
Dumps the DDI2 metadata (for debugging purposes).
|
void |
dumpDDI3()
Dumps the DDI3 metadata(for debugging purposes).
|
void |
dumpMetadata()
Dumps the file metadata to the console (for debugging purposes)
|
long |
exportData(File file,
FileFormatInfo dataFormat)
Reads the data from the disk and exports a file based on the specified
format
|
Document |
getDDI2()
Creates a DDI 2.0 XML Document based for the SPSS data format
|
Document |
getDDI2(FileFormatInfo dataFormat)
Creates a DDI 2.0 XML Document based for the specified data file format
|
String |
getDDI3DefaultLogicalProductID()
Returns a default Physical Data Product identifier based on the file
unique identifier.
|
String |
getDDI3DefaultPhysicalDataProductID(FileFormatInfo dataFormat)
Returns a default Physical Data Product identifier based on the file
unique identifier and the data format.
|
String |
getDDI3DefaultPhysicalInstanceID(FileFormatInfo dataFormat)
Returns a default Physical Instance identifier based on the file unique
identifier and the data format.
|
String |
getDDI3DefaultPhysicalStructureSchemeID(FileFormatInfo dataFormat)
Returns a default Physical Structure Scheme identifier based on the file
unique identifier and the data format.
|
String |
getDDI3DefaultRecordLayoutSchemeID(FileFormatInfo dataFormat)
Returns a default Record Layout Scheme identifier based on the file
unique identifier and the data format.
|
String |
getDDI3DefaultVariableSchemeID()
Returns a default Variable Scheme identifier based on the file unique
identifier.
|
Document |
getDDI3LogicalProduct()
Creates a DDI 3.0 Logical Product XML Module for this file.
|
Document |
getDDI3LogicalProduct(String uniqueID)
Creates a DDI 3.0 Logical Product XML Module for this file.
|
Document |
getDDI3LogicalProduct(String uniqueID,
String identifyingAgency)
Creates a DDI 3.0 LogiclaProduct XML Document for this file.
|
Document |
getDDI3PhysicalDataProduct(FileFormatInfo dataFormat)
Creates a DDI 3.0 PhysicalDataProduct XML Document for this file based on
the specified file format using the default logical product ID.
|
Document |
getDDI3PhysicalDataProduct(FileFormatInfo dataFormat,
String logicalProductID)
Creates a DDI 3.0 PhysicalDataProduct XML Document for this file based on
the specified file format.
|
Document |
getDDI3PhysicalDataProduct(FileFormatInfo dataFormat,
String logicalProductID,
String uniqueID)
Creates a DDI 3.0 PhysicalDataProduct XML Document for this file based on
the specified file format.
|
Document |
getDDI3PhysicalInstance(URI uri,
FileFormatInfo dataFormat)
Creates a DDI 3.0 PhysicalInstance XML Document for this file based on
the specified file format using default indentifiers.
|
Document |
getDDI3PhysicalInstance(URI uri,
FileFormatInfo dataFormat,
String recordLayoutSchemeID)
Creates a DDI 3.0 PhysicalInstance XML Document for this file based on
the specified file format.
|
Document |
getDDI3PhysicalInstance(URI uri,
FileFormatInfo dataFormat,
String recordLayoutSchemeID,
String uniqueID)
Creates a DDI 3.0 PhysicalInstance XML Document for this file based on
the specified file format.
|
String |
getRecord(int obsNumber,
FileFormatInfo dataFormat)
Gets a data record from data in memory based on on the record number and
specified format.
|
int |
getRecordCount()
Returns the total number of records (cases) in the file.
|
String |
getRecordFromDisk(FileFormatInfo dataFormat,
boolean rewind)
Gets a data record in the specified format.
|
String |
getUniqueID()
Gets the unique identifier for this file.
|
SPSSVariable |
getVariable(int index)
Gets a SPSSVariable based on its 0-based file index position.
|
int |
getVariableCount()
Returns the total number of variables in the file.
|
boolean |
isCompressed()
Determines if the data section of the file is compressed
|
void |
loadData()
Load the data section of the file into the variables in memory.
|
void |
loadMetadata()
Loads the dictionary and other SPSS metadata from the file
|
void |
log(String msg)
Logs a message to the console.
|
double |
readSPSSDouble()
Reads a 8-byte IEEE 754 from SPSS file
|
int |
readSPSSInt()
Reads a 4-byte integer from the SPSS file
|
String |
readSPSSString(int length)
Reads a string from the SPSS file
|
void |
setUniqueID(String str)
Sets the unique identifier for this file.
|
close, getChannel, getFD, getFilePointer, length, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, skipBytes, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFpublic static final int VERSION_MAJOR
public static final int VERSION_MINOR
public static final String DDI2_NAMESPACE
public static final String DDI3_ARCHIVE_NAMESPACE
public static final String DDI3_INSTANCE_NAMESPACE
public static final String DDI3_LOGICAL_PRODUCT_NAMESPACE
public static final String DDI3_PHYSICAL_PRODUCT_NAMESPACE
public static final String DDI3_PHYSICAL_INSTANCE_NAMESPACE
public static final String DDI3_PROPRIETARY_RECORD_NAMESPACE
public static final String DDI3_REUSABLE_NAMESPACE
public static final String DDI3_STUDY_UNIT_NAMESPACE
public String categorySchemeIDSuffix
public String codeSchemeIDSuffix
public String dataRelationshipID
public String grossFileID
public String grossRecordStructureID
public String logicalRecordID
public String physicalRecordSegmentID
public String logicalProductIDSuffix
public String physicalDataProductIDSuffix
public String physicalStructureSchemeSuffix
public String physicalStructureID
public String recordLayoutSchemeSuffix
public String physicalInstanceIDSuffix
public String physicalInstanceFileID
public String variableSchemeIDSuffix
public String variableCategoryPrefix
public String variableIDPrefix
public Boolean logFlag
public File logFile
public File file
public boolean isMetadataLoaded
public boolean isDataLoaded
public SPSSFile(File file) throws FileNotFoundException
file - FileNotFoundExceptionpublic SPSSFile(File file, String mode) throws FileNotFoundException
file - mode - FileNotFoundExceptionpublic SPSSFile(String name) throws FileNotFoundException
name - FileNotFoundExceptionpublic SPSSFile(String name, String mode) throws FileNotFoundException
name - mode - FileNotFoundExceptionpublic SPSSFile(File file, Charset charset) throws FileNotFoundException
file - charset - FileNotFoundExceptionpublic SPSSFile(File file, String mode, Charset charset) throws FileNotFoundException
file - mode - charset - FileNotFoundExceptionpublic SPSSFile(String name, Charset charset) throws FileNotFoundException
name - charset - FileNotFoundExceptionpublic SPSSFile(String name, String mode, Charset charset) throws FileNotFoundException
name - mode - charset - FileNotFoundExceptionpublic void dumpData()
throws SPSSFileException,
IOException
IOExceptionSPSSFileExceptionpublic void dumpData(int nRecords)
throws SPSSFileException,
IOException
nRecords - the number of records to dump (0 for all)IOExceptionSPSSFileExceptionpublic void dumpData(int nRecords,
FileFormatInfo dataFormat)
throws SPSSFileException,
IOException
nRecords - the number of records to dump (0 for all)dataFormat - IOExceptionSPSSFileExceptionpublic void dumpDDI2()
throws SPSSFileException,
TransformerException
public void dumpDDI3()
throws SPSSFileException,
TransformerException
public void dumpMetadata()
public long exportData(File file, FileFormatInfo dataFormat) throws IOException, SPSSFileException
file - dataFormat - SPSSFileExceptionIOExceptionpublic boolean isCompressed()
throws SPSSFileException
SPSSFileExceptionpublic Document getDDI2() throws SPSSFileException
SPSSFileExceptionpublic Document getDDI2(FileFormatInfo dataFormat) throws SPSSFileException
SPSSFileExceptionpublic String getDDI3DefaultLogicalProductID()
public String getDDI3DefaultPhysicalDataProductID(FileFormatInfo dataFormat)
public String getDDI3DefaultPhysicalInstanceID(FileFormatInfo dataFormat)
dataFormat - public String getDDI3DefaultPhysicalStructureSchemeID(FileFormatInfo dataFormat)
public String getDDI3DefaultRecordLayoutSchemeID(FileFormatInfo dataFormat)
public String getDDI3DefaultVariableSchemeID()
public Document getDDI3LogicalProduct() throws SPSSFileException
SPSSFileExceptionpublic Document getDDI3LogicalProduct(String uniqueID) throws SPSSFileException
uniqueID - a String value for the r:ID element. If null, a unique ID will
be generated automatically based on the java.util.UUID classSPSSFileExceptionpublic Document getDDI3LogicalProduct(String uniqueID, String identifyingAgency) throws SPSSFileException
uniqueID - a String value for the r:ID element. If null, a unique ID will
be generated automatically based on the java.util.UUID classidentifyingAgency - SPSSFileExceptionpublic Document getDDI3PhysicalDataProduct(FileFormatInfo dataFormat) throws SPSSFileException
dataFormat - SPSSFileExceptionpublic Document getDDI3PhysicalDataProduct(FileFormatInfo dataFormat, String logicalProductID) throws SPSSFileException
dataFormat - logicalProductID - the r:ID of the Logical Product this is refering toSPSSFileExceptionpublic Document getDDI3PhysicalDataProduct(FileFormatInfo dataFormat, String logicalProductID, String uniqueID) throws SPSSFileException
dataFormat - logicalProductID - the r:ID of the Logical Product this is referring touniqueID - a String value for the r:ID element. If null, a unique ID will
be generated automatically based on the java.util.UUID classSPSSFileExceptionpublic Document getDDI3PhysicalInstance(URI uri, FileFormatInfo dataFormat) throws SPSSFileException
uri - dataFormat - SPSSFileExceptionpublic Document getDDI3PhysicalInstance(URI uri, FileFormatInfo dataFormat, String recordLayoutSchemeID) throws SPSSFileException
uri - dataFormat - recordLayoutSchemeID - the Record Layout Scheme Data Product this instance refers toSPSSFileExceptionpublic Document getDDI3PhysicalInstance(URI uri, FileFormatInfo dataFormat, String recordLayoutSchemeID, String uniqueID) throws SPSSFileException
uri - dataFormat - recordLayoutSchemeID - the Record Layout Scheme Data Product this instance refers touniqueID - a String value for the r:ID element. If null, a unique ID will
be generated automatically based on the java.util.UUID classSPSSFileExceptionpublic String getRecord(int obsNumber, FileFormatInfo dataFormat) throws SPSSFileException
obsNumber - dataFormat - SPSSFileExceptionpublic String getRecordFromDisk(FileFormatInfo dataFormat, boolean rewind) throws SPSSFileException, IOException
dataFormat - rewind - If true start reading from first record otherwise continue
from current location until end of file is reachedSPSSFileExceptionIOExceptionpublic int getRecordCount()
public String getUniqueID()
public SPSSVariable getVariable(int index)
SPSSFileExceptionpublic int getVariableCount()
public void loadData()
throws IOException,
SPSSFileException
SPSSFileExceptionIOExceptionpublic void loadMetadata()
throws FileNotFoundException,
IOException,
SPSSFileException
public void log(String msg)
msg - IOExceptionpublic double readSPSSDouble()
throws IOException
IOExceptionpublic int readSPSSInt()
throws IOException
IOExceptionpublic String readSPSSString(int length) throws IOException
length - Number of characters to readIOExceptionpublic void setUniqueID(String str)
str - Copyright © 2016. All rights reserved.