SCViewer/plugins/com.minres.scviewer.databas.../src/com/minres/scviewer/database/sqlite/TxEvent.java

66 lines
1.6 KiB
Java
Raw Normal View History

/*******************************************************************************
2021-01-09 14:26:49 +01:00
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
2015-01-20 18:50:15 +01:00
package com.minres.scviewer.database.sqlite;
2020-11-28 10:22:22 +01:00
import com.minres.scviewer.database.EventKind;
import com.minres.scviewer.database.IEvent;
2020-11-28 14:08:34 +01:00
import com.minres.scviewer.database.WaveformType;
2020-11-28 14:47:43 +01:00
import com.minres.scviewer.database.tx.ITx;
import com.minres.scviewer.database.tx.ITxEvent;
2015-01-20 18:50:15 +01:00
public class TxEvent implements ITxEvent {
2020-11-28 10:22:22 +01:00
private final EventKind type;
2015-01-20 18:50:15 +01:00
private ITx tx;
2020-11-28 10:22:22 +01:00
public TxEvent(EventKind type, ITx tx) {
2015-01-20 18:50:15 +01:00
super();
this.type = type;
this.tx = tx;
}
@Override
2021-02-27 14:59:00 +01:00
public long getTime() {
2020-11-28 10:22:22 +01:00
return type==EventKind.BEGIN?tx.getBeginTime():tx.getEndTime();
2015-01-20 18:50:15 +01:00
}
@Override
2020-11-28 10:22:22 +01:00
public IEvent duplicate() throws CloneNotSupportedException {
2015-01-20 18:50:15 +01:00
return new TxEvent(type, tx);
}
@Override
public ITx getTransaction() {
return tx;
}
@Override
2020-11-28 10:22:22 +01:00
public EventKind getKind() {
2015-01-20 18:50:15 +01:00
return type;
}
@Override
public String toString() {
return type.toString()+"@"+getTime()+" of tx #"+tx.getId();
}
2020-11-28 10:22:22 +01:00
@Override
2020-11-28 14:08:34 +01:00
public WaveformType getType() {
return WaveformType.TRANSACTION;
2020-11-28 10:22:22 +01:00
}
2021-01-14 23:13:11 +01:00
@Override
public int getRowIndex() {
return ((Tx)tx).getConcurrencyIndex();
}
2015-01-20 18:50:15 +01:00
}