Search in sources :

Example 1 with RecordParser

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;
}
Also used : RandomAccessFile(java.io.RandomAccessFile) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) RecordParser(org.eclipse.titan.log.viewer.parsers.RecordParser) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 2 with RecordParser

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;
}
Also used : RandomAccessFile(java.io.RandomAccessFile) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) RecordParser(org.eclipse.titan.log.viewer.parsers.RecordParser) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 3 with RecordParser

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;
}
Also used : LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) RecordParser(org.eclipse.titan.log.viewer.parsers.RecordParser) ParseException(java.text.ParseException)

Aggregations

RecordParser (org.eclipse.titan.log.viewer.parsers.RecordParser)3 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)3 File (java.io.File)2 RandomAccessFile (java.io.RandomAccessFile)2 ParseException (java.text.ParseException)1