Package com.softwaremining.files
Class SequentialNIOFile
java.lang.Object
com.softwaremining.wrappers.CBLBean
com.softwaremining.wrappers.AbstractBasePersistence
com.softwaremining.files.AbstractFile
com.softwaremining.files.AbstractSequentialFile
com.softwaremining.files.SequentialNIOFile
- All Implemented Interfaces:
IPersistence
,AbstractDataObject
,ICBLBeanNGroup
,ICBLContainer
,IFieldContainer
,ISMBean
,ISMDataType
- Direct Known Subclasses:
AbstractCSVFile
,CachedIndexedFile
,CicsSequential
This is a simplified/faster version of SequentialFile .
(See SequentialFile documentation for more detail description of the functionality). For every read/write, the SequentialFile re-positions an internal . SequentialFile class utilises an instance of randomAccessFile class. This allows the system to UPDATE records written in middle of a data-file. However, where this functionality is not required, the continuous re-calculation and repositioning read /write position has huge performance implications.
Therefore a new class SequentialNIOFile has been introduced which whilst does not offer "deleteRecod" and "UpdateRecord" functionality, have a significant higher Read and Insert performance.
(See SequentialFile documentation for more detail description of the functionality). For every read/write, the SequentialFile re-positions an internal . SequentialFile class utilises an instance of randomAccessFile class. This allows the system to UPDATE records written in middle of a data-file. However, where this functionality is not required, the continuous re-calculation and repositioning read /write position has huge performance implications.
Therefore a new class SequentialNIOFile has been introduced which whilst does not offer "deleteRecod" and "UpdateRecord" functionality, have a significant higher Read and Insert performance.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected FileInputStream
protected FileOutputStream
protected static Log
protected static ByteBuffer
protected static ByteBuffer
protected static ByteBuffer
protected boolean
Fields inherited from class com.softwaremining.files.AbstractSequentialFile
ADVANCE_NOT_INITIALIZED, advanceContinuation, advanceSize, advanceType, CRLFcharCount, currentRecordNumber, EJECT, FIRST_LINE_POS, firstLineTerminators, firstRead, fixedLenghtRecordsEndWithNewLine, fixedLengthRecord, justRead, LINE, lineCounter, numberOfInitialRecords, PAGE, rdw_format, RDW_LENGTH, rdw_Null, recordDependingField, targetIsPrinter, TOP_OF_PAGE, totalRuntime, useRDW
Fields inherited from class com.softwaremining.files.AbstractFile
openMode
Fields inherited from class com.softwaremining.wrappers.AbstractBasePersistence
fileName, ownerClassName, status
Fields inherited from class com.softwaremining.wrappers.CBLBean
EBCDIC_JIT_PD_SUPPORT_FOR_SEQ_FILES, INDEX_FOR_NON_ARRAY_VERSION_OF_FIELD, INDEX_ZERO, tmp_lengthofAssignedValue, totalRuntime_allocate, totalRuntime_calcFieldOffsets, totalRuntime_getMemoryPosition, totalRuntime_setFieldFormatted
Fields inherited from interface com.softwaremining.sql.IPersistence
ACCESS_MODE_DYNAMIC, ACCESS_MODE_RANDOM, ACCESS_MODE_SEQUENTIAL, ASCENDING_RECORD_KEY, CONDITION_TYPE_EQUALS, CONDITION_TYPE_GREATER, CONDITION_TYPE_GREATER_OR_EQUALS, CONDITION_TYPE_IGNORE, CONDITION_TYPE_IGNORE_FOR_SQL_LIKE, CONDITION_TYPE_LESS, CONDITION_TYPE_LESS_OR_EQUALS, CONDITION_TYPE_LIKE, CONDITION_TYPE_NO_CONDITION, CONDITION_TYPE_NOT_ASSIGNED, DESCENDING_RECORD_KEY, OPEN_MODE_EXTEND, OPEN_MODE_I_O, OPEN_MODE_INPUT, OPEN_MODE_NOT_OPENED, OPEN_MODE_OUTPUT, STATUS_AT_END, STATUS_DUP_KEY, STATUS_FAILED_CLOSING, STATUS_INCORRECT_READ_OF_UNOPENED_FILE, STATUS_INCORRECT_RECORDSIZE_REWRITE, STATUS_INSERT_ERR_INAPPROPRIATE_FILE, STATUS_INSERT_ERR_INVALID_KEY, STATUS_LOCK, STATUS_NOT_FOUND, STATUS_REWRITE_WITHOUT_READ, STATUS_SM_FAIL_UNKOWN_REASON, STATUS_SM_NOT_ASSIGNED, STATUS_SUCCESS, UNCERTAIN_OF_RETURN_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
_insertRecord
(int groupSize) Used Internally by SoftwareMining Framework Insert (write) the current data into file.void
assignUseMultiByteReader
(boolean newValue) Should be used before the .open(...) statement.int
clear()
int
close()
Close file and change status to STATUS_SUCCEED.protected int
Get the size of the record - taking any DEPENDING-ON into consideration.protected final void
Auxilary method (not present in COBOL).boolean
supporting UNISYS IF ATTRIBUTE OPEN OF record = VALUE TRUEprotected int
Used Internally by SoftwareMining Framework read the next record from file.protected int
protected final int
Used Internally by SoftwareMining Framework read the next record from file.protected int
Used Internally by SoftwareMining Framework read the next record from file.int
open
(int openMode) Open file for reading.int
open
(int openMode, boolean prefixFileNameWithCallingProgram) Open file for reading.int
Scroll back to previous record When end (or beginning) of file is reached, it does not throw an exceptionprotected final String
readLine_FromFileChannel
(int readSize) FileChannel does not come with a read-line, so we need to construct our ownprotected final String
readLine_FromFileReader
(int readSize) FileChannel does not come with a read-line, so we need to contruct our ownint
Update the current record with the current record structure.Methods inherited from class com.softwaremining.files.AbstractSequentialFile
advance, advance, advance, assignDependingField, assignEncodedBytes, assignFileName, assignFixedLenghtRecordsEndWithNewLine, assignRecordsAreFixedLength, assignRecordSize, assignTargetIsPrinter, assignUsesRDW, closeReel, deleteRecord, exists, getCRLFcharCount, getRecordSize, insert, insertRecord, insertRecord, isFixedLenghtRecordsEndWithNewLine, isRDW, nextRecord, prevRecord, println, read, readRecord, retrieveCurrentRecordNumber, retrieveEncodedBytesForWrite, retrieveFieldLineCounter, retrieveFieldPageCounter, retrieveLineCounter, retrieveNumberOfInitialRecords, retrievePageCounter, retrieveRecordDependingField, setCRLFcharCount
Methods inherited from class com.softwaremining.files.AbstractFile
resetDataDirectory, retrieveDataDirectory, retrieveFullFileName, retrieveOpenMode
Methods inherited from class com.softwaremining.wrappers.AbstractBasePersistence
assignAccessMode, assignLock, assignStatus, assignStatus, assignStatusAsPrimitive, assignStatusValue, assignStatusValue, assignTableName, delete, insert, next, prev, readRow, retrieveAccessMode, retrieveFileName, retrieveFileName, retrieveFirstLevelEntry, retrieveSessionId, retrieveStatusField, retrieveStatusValue, update
Methods inherited from class com.softwaremining.wrappers.CBLBean
addCorrespondingValue, addCorrespondingValue, allocate, assignAddressTo, assignAddressTo, assignBean, assignBytesEncoded, assignCachedInitializationValue, assignCorrespondingValue, assignCorrespondingValue, assignDefaultValue, assignEbcdicBytes, assignEbcdicJIT_PdSupportForSequentialFiles, assignEncodedValue, assignExemptFromMemRelease, assignExternal, assignHighValues, assignInternalVars, assignLowValues, assignRawEbcdicBytes, assignRedefines, assignRedefines, assignSessionId, assignStringFormatted, assignSubstring, assignSubstring, assignToAddressOf, assignToAddressOf, assignToAddressOf, assignToAddressOf, assignToAllFields, assignValue, assignValue, assignValue, assignValue, assignValue, assignValue, assignValue, calculateStorageSize, containsPointers, equals, equals, equals, equals, equalsRightTrimmed, fieldsCount, fill, fill, fill, fill, fill, getValue, hasPackedDecimalFields, initDefaultValues, initialize, initialize, isExemptFromMemRelease, isFilled, isFilled, isFilled, isFilled, isGreaterThan, isGreaterThan, isGreaterThan, isHighValues, isInvolvedInDependency, isInvolvedInExternalDependency, isLessOrEqualTo, isLessOrEqualTo, isLessOrEqualTo, isLessOrEqualTo, isLessOrEqualTo, isLessThan, isLessThan, isLessThan, isLessThan, isLessThan, isLowValues, isRedefinedByAnotherClass, isResourceAlreadyReleased, lengthOf, printFieldPosition, printFieldValues, printOrderedFieldPosition, PrintOrderedFieldPositionsAndValue, releaseResources, releaseResources, resetCachedValues, resetCompressedFieldList, resetStructure, resize, retrieveActualLength, retrieveAsInt, retrieveAsString, retrieveCachedInitializationValue, retrieveCompressedFields, retrieveDependedFieldsList, retrieveEbcdicBytes, retrieveEbcdicValue, retrieveEncodedValue, retrieveField, retrieveField, retrieveFieldAtMemoryPosition, retrieveFieldFormatted, retrieveFields, retrieveIsTargetOfPointers, retrievePrimitiveFields, retrieveRawEbcdicBytes, retrieveSQLObject, retrieveStorageCellSize, retrieveStorageChars, retrieveSubstring, retrieveSubstring, retrieveTopLevelField, retrieveValue, retrieveValue, setValue, stringValue, subtractCorrespondingValue, subtractCorrespondingValue, toString
-
Field Details
-
fileInputStream
-
fileOutputStream
-
log
-
_recordSize
protected int _recordSize -
ONE_ByteBuffer
-
PAGE_ByteBuffer
-
SPACE_ByteBuffer
-
useMultiByteReader
protected boolean useMultiByteReader
-
-
Constructor Details
-
SequentialNIOFile
public SequentialNIOFile()constructor -
SequentialNIOFile
default Constructor- Parameters:
owner
-
-
-
Method Details
-
open
Open file for reading.- Specified by:
open
in classAbstractBasePersistence
- Parameters:
openMode
- refers to:
IPersistence.OPEN_MODE_INPUT ( read )
IPersistence.OPEN_MODE_OUTPUT (Write)
IPersistence.OPEN_MODE_I_O (read-write)
IPersistence.OPEN_MODE_EXTEND: (read-write)- Throws:
IOCriticalException
-
open
Open file for reading.- Specified by:
open
in classAbstractSequentialFile
- Parameters:
openMode
- refers to:
IPersistence.OPEN_MODE_INPUT ( read )
IPersistence.OPEN_MODE_OUTPUT (Write)
IPersistence.OPEN_MODE_I_O (read-write)
IPersistence.OPEN_MODE_EXTEND: (read-write)prefixFileNameWithCallingProgram
- - when true the name of the calling program will be prefixed to the outputfilename. This is useful for REPORT files.- Returns:
- Throws:
IOCriticalException
-
close
Close file and change status to STATUS_SUCCEED.- Specified by:
close
in classAbstractBasePersistence
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOCriticalException
-
isFileOpened
public boolean isFileOpened()Description copied from class:AbstractSequentialFile
supporting UNISYS IF ATTRIBUTE OPEN OF record = VALUE TRUE- Specified by:
isFileOpened
in classAbstractSequentialFile
- Returns:
-
getReadSize
Get the size of the record - taking any DEPENDING-ON into consideration. IF no DEPENDING-ON is present, then it will return th RecordSize- Returns:
- Throws:
IOException
-
nextWithException_UseExactRecordLenght
Used Internally by SoftwareMining Framework read the next record from file. At end throw an exception- Specified by:
nextWithException_UseExactRecordLenght
in classAbstractSequentialFile
- Throws:
IOCriticalException
AtEndException
-
nextWithException_UseExactRecordLenght_UsingFileChannel
protected int nextWithException_UseExactRecordLenght_UsingFileChannel() throws IOCriticalException, AtEndException- Throws:
IOCriticalException
AtEndException
-
nextWithException_UseExactRecordLenght_UsingFileReader
protected final int nextWithException_UseExactRecordLenght_UsingFileReader() throws IOCriticalException, AtEndExceptionUsed Internally by SoftwareMining Framework read the next record from file. At end throw an exception- Throws:
IOCriticalException
AtEndException
-
nextWithException_UseLineBreaks
Used Internally by SoftwareMining Framework read the next record from file. At end throw an exception- Specified by:
nextWithException_UseLineBreaks
in classAbstractSequentialFile
- Throws:
IOCriticalException
AtEndException
-
readLine_FromFileChannel
protected final String readLine_FromFileChannel(int readSize) throws IOException, UnsupportedEncodingException FileChannel does not come with a read-line, so we need to construct our own- Parameters:
readSize
-- Returns:
- Throws:
IOException
UnsupportedEncodingException
-
readLine_FromFileReader
protected final String readLine_FromFileReader(int readSize) throws IOException, UnsupportedEncodingException FileChannel does not come with a read-line, so we need to contruct our own- Parameters:
readSize
-- Returns:
- Throws:
IOException
UnsupportedEncodingException
-
prevWithException
Scroll back to previous record When end (or beginning) of file is reached, it does not throw an exception- Specified by:
prevWithException
in classAbstractSequentialFile
- Throws:
IOCriticalException
AtEndException
-
updateRecord
Update the current record with the current record structure. If at end of file is reached, it throws an exception- Specified by:
updateRecord
in classAbstractBasePersistence
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOCriticalException
-
_insertRecord
Description copied from class:AbstractSequentialFile
Used Internally by SoftwareMining Framework Insert (write) the current data into file.- Specified by:
_insertRecord
in classAbstractSequentialFile
- Parameters:
groupSize
- : Used for multi 01 files ... defines the size of the group- Throws:
IOCriticalException
-
insertNewLine
Auxilary method (not present in COBOL). Adds a new CRLF to the file.- Throws:
IOCriticalException
-
clear
- Specified by:
clear
in classAbstractBasePersistence
- Returns:
- when successful it returns IPersistence.STATUS_SUCCESS
- Throws:
IOCriticalException
-
assignUseMultiByteReader
public void assignUseMultiByteReader(boolean newValue) Should be used before the .open(...) statement. Default is false.
Multi-byte files can be read using BufferedReader - which uses chars[] instead of bytes[].
This will delegate reading multi-byte characters to Java, rather than trying to construct them from the bytes arrays (some chars may be single byte, others multi-byte). The Multi-byte handling may reduce the performance,- Parameters:
newValue
-
-