use of org.eclipse.titan.log.viewer.parsers.RecordParser in project titan.EclipsePlug-ins by eclipse.
the class ValueReader method getValue.
private String getValue(final URI logFilePath, final long offset, final int length) throws IOException, ParseException {
RandomAccessFile random = null;
String message = null;
try {
random = new RandomAccessFile(new File(logFilePath), MSCConstants.READ_ONLY);
random.seek(offset);
byte[] buffer = new byte[length];
random.read(buffer, 0, length);
RecordParser recordParser = new RecordParser();
LogRecord logRecord = recordParser.parse(buffer);
message = logRecord.getMessage();
} finally {
IOUtils.closeQuietly(random);
}
return message;
}
use of org.eclipse.titan.log.viewer.parsers.RecordParser in project titan.EclipsePlug-ins by eclipse.
the class ValueReader method getLogRecord.
private LogRecord getLogRecord(final URI logFilePath, final long offset, final int length) throws IOException, ParseException {
RandomAccessFile random = null;
LogRecord logRecord = null;
try {
random = new RandomAccessFile(new File(logFilePath), MSCConstants.READ_ONLY);
random.seek(offset);
byte[] buffer = new byte[length];
random.read(buffer, 0, length);
RecordParser recordParser = new RecordParser();
logRecord = recordParser.parse(buffer);
} finally {
IOUtils.closeQuietly(random);
}
return logRecord;
}
use of org.eclipse.titan.log.viewer.parsers.RecordParser in project titan.EclipsePlug-ins by eclipse.
the class TestFileReader method getNextRecord.
/**
* Reads a record
*
* REQUIRES that hasNextRecord() is true
*
* @return a record or null
* @throws IOException
* @throws ParseException
*/
public LogRecord getNextRecord() throws IOException, ParseException {
String logData = readNextRecord();
LogRecord aRecord;
try {
RecordParser recordParser = new RecordParser();
aRecord = recordParser.parse(logData);
aRecord.setRecordOffset(this.logRecordIndexes[this.currentRecord].getFileOffset());
aRecord.setRecordLength(this.logRecordIndexes[this.currentRecord].getRecordLength());
aRecord.setRecordNumber(this.currentRecord);
this.currentRecord++;
} catch (ParseException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
ParseException throwable = new ParseException("Could not parse the " + currentRecord + "th record ", 0);
throwable.initCause(e);
throw throwable;
}
return aRecord;
}
Aggregations