}
public void setValue(final long newValue) {
- fValue = newValue;
+ setValue(newValue, -9, 0);
}
/**
* @return Seconds in the object, in string.
*/
public String getSeconds() {
- return formatSecs(fValue);
+ return formatSecs(getValue());
}
/**
* @return Seconds in the object, in string.
*/
public String getNanoSeconds() {
- return formatNs(fValue);
+ return formatNs(getValue());
}
/*
@SuppressWarnings("nls")
public String toString() {
- long value = fValue;
- if (fValue < 0)
- value = -fValue;
+ int scale = getScale();
+ long value = getValue();
+ if (value < 0)
+ value = -value;
final StringBuilder sb = new StringBuilder(String.valueOf(value));
// Prepend the correct number of "0" so we can insert a "." at the right location
- final int nbZeroes = (-fScale) - sb.length() + 1;
+ final int nbZeroes = (-scale) - sb.length() + 1;
for (int i = 0; i < nbZeroes; i++)
sb.insert(i, "0");
- sb.insert(sb.length() + fScale, ".");
+ sb.insert(sb.length() + scale, ".");
// Prepend "-" if negative
- if (fValue < 0)
+ if (getValue() < 0)
sb.insert(0, "-");
return sb.toString();
@Override
public String toString() {
+ long value = getValue();
+ int scale = getScale();
+
// If we are dealing with units of seconds (or higher),
// use the plain formatter
- if (fScale >= 0) {
- Double value = fValue * Math.pow(10, fScale);
- return value.toString();
+ if (scale >= 0) {
+ Double dvalue = value * Math.pow(10, scale);
+ return dvalue.toString();
}
// Define a format string
- String format = String.format("%%1d.%%0%dd", -fScale);
+ String format = String.format("%%1d.%%0%dd", -scale);
// And format the timestamp value
- double scale = Math.pow(10, fScale);
- long seconds = (long) (fValue * scale);
- long fracts = fValue - (long) ((double) seconds / scale);
+ double dscale = Math.pow(10, scale);
+ long seconds = (long) (value * dscale);
+ long fracts = value - (long) ((double) seconds / dscale);
String result = String.format(format, seconds, fracts);
return result;
public CtfTmfTimestamp(long timestamp, CtfTmfTrace trace) {
fTrace = trace;
- fValue = timestamp;
- fScale = (byte) -9;
+ setValue(timestamp, -9, 0);
}
/* (non-Javadoc)
*/
@Override
public String toString() {
- final long timestamp = fValue;
+ final long timestamp = getValue();
final Date d = new Date(timestamp / 1000000);
final DateFormat df = new SimpleDateFormat("HH:mm:ss."); //$NON-NLS-1$
final long nanos = (timestamp % 1000000000);
}
public String toFullDateString(){
- final long timestamp = fValue;
+ final long timestamp = getValue();
final Date d = new Date(timestamp / 1000000);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); //$NON-NLS-1$
final long nanos = (timestamp % 1000000000);
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
- * <b><u>ITmfEvent</u></b>
- * <p>
* The basic event structure in TMF. In its canonical form, a data item has:
* <ul>
* <li> a parent trace
* used as e.g. a location marker (filename:lineno) to indicate where the event
* was generated.
*
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ *
* @see ITmfTimestamp
* @see ITmfEventType
* @see ITmfEvetnField
package org.eclipse.linuxtools.tmf.core.event;
+
/**
- * <b><u>ITmfEventField</u></b>
- * <p>
* The TMF event payload structure. Each field can be either a terminal or
* further decomposed into subfields.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ *
+ * @see TmfEventField
+ * @see ITmfEvent
*/
public interface ITmfEventField extends Cloneable {
package org.eclipse.linuxtools.tmf.core.event;
+
/**
- * <b><u>ITmfEventType</u></b>
- * <p>
* The TMF event event type. It contains a reference to the full field structure
* for that event type.
* <p>
* Types are unique within their context space.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see TmfEventType
+ * @see ITmfEvent
*/
public interface ITmfEventType extends Cloneable {
package org.eclipse.linuxtools.tmf.core.event;
/**
- * <b><u>ITmfTimestamp</u></b>
- * <p>
* The fundamental time reference in the TMF.
* <p>
* It defines a generic timestamp interface in its most basic form:
* @param scale the new timestamp scale
* @return a new 'adjusted' ITmfTimestamp
*/
- public ITmfTimestamp normalize(long offset, int scale) throws ArithmeticException;
+ public ITmfTimestamp normalize(long offset, int scale);
/**
* Compares [this] and [ts] within timestamp precision
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo(ITmfTimestamp ts);
+ int compareTo(ITmfTimestamp ts);
}
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
- * <b><u>TmfEvent</u></b>
- * <p>
* A basic implementation of ITmfEvent.
- *
+ * <p>
* Note that for performance reasons TmfEvent is NOT immutable. If a shallow
* copy of the event is needed, use the copy constructor. Otherwise (deep copy)
* use clone().
- */
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfTimestamp
+ * @see ITmfEventType
+ * @see ITmfEventField
+ * @see ITmfTrace
+*/
public class TmfEvent implements ITmfEvent {
// ------------------------------------------------------------------------
* @param event the original event
*/
public TmfEvent(final ITmfEvent event) {
- if (event == null)
+ if (event == null) {
throw new IllegalArgumentException();
+ }
fTrace = event.getTrace();
fRank = event.getRank();
fTimestamp = event.getTimestamp();
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof TmfEvent))
+ }
+ if (!(obj instanceof TmfEvent)) {
return false;
+ }
final TmfEvent other = (TmfEvent) obj;
if (fTrace == null) {
- if (other.fTrace != null)
+ if (other.fTrace != null) {
return false;
- } else if (!fTrace.equals(other.fTrace))
+ }
+ } else if (!fTrace.equals(other.fTrace)) {
return false;
- if (fRank != other.fRank)
+ }
+ if (fRank != other.fRank) {
return false;
+ }
if (fTimestamp == null) {
- if (other.fTimestamp != null)
+ if (other.fTimestamp != null) {
return false;
- } else if (!fTimestamp.equals(other.fTimestamp))
+ }
+ } else if (!fTimestamp.equals(other.fTimestamp)) {
return false;
+ }
if (fSource == null) {
- if (other.fSource != null)
+ if (other.fSource != null) {
return false;
- } else if (!fSource.equals(other.fSource))
+ }
+ } else if (!fSource.equals(other.fSource)) {
return false;
+ }
if (fType == null) {
- if (other.fType != null)
+ if (other.fType != null) {
return false;
- } else if (!fType.equals(other.fType))
+ }
+ } else if (!fType.equals(other.fType)) {
return false;
+ }
if (fContent == null) {
- if (other.fContent != null)
+ if (other.fContent != null) {
return false;
- } else if (!fContent.equals(other.fContent))
+ }
+ } else if (!fContent.equals(other.fContent)) {
return false;
+ }
if (fReference == null) {
- if (other.fReference != null)
+ if (other.fReference != null) {
return false;
- } else if (!fReference.equals(other.fReference))
+ }
+ } else if (!fReference.equals(other.fReference)) {
return false;
+ }
return true;
}
import java.util.Map;
/**
- * <b><u>TmfEventField</u></b>
+ * A basic implementation of ITmfEventField.
* <p>
- * A basic implementation of ITmfEventField. Non-value fields are structural
- * (i.e. used to represent the event structure including optional fields) while
- * the valued fields are actual event fields.
+ * Non-value fields are structural (i.e. used to represent the event structure
+ * including optional fields) while the valued fields are actual event fields.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfEventField
+ * @see ITmfEventType
+ * @see ITmfEvent
*/
public class TmfEventField implements ITmfEventField {
* @param fields the list of subfields
*/
public TmfEventField(final String name, final Object value, final ITmfEventField[] fields) {
- if (name == null)
+ if (name == null) {
throw new IllegalArgumentException();
+ }
fName = name;
fValue = value;
fFields = (fields != null) ? Arrays.copyOf(fields, fields.length) : null;
* @param field the other event field
*/
public TmfEventField(final TmfEventField field) {
- if (field == null)
+ if (field == null) {
throw new IllegalArgumentException();
+ }
fName = field.fName;
fValue = field.fValue;
fFields = field.fFields;
@Override
public String getFieldName(final int index) {
final ITmfEventField field = getField(index);
- if (field != null)
+ if (field != null) {
return field.getName();
+ }
return null;
}
*/
@Override
public ITmfEventField[] getFields() {
- ITmfEventField[] result = (fFields != null) ? Arrays.copyOf(fFields, fFields.length) : null;
- return result;
+ return (fFields != null) ? Arrays.copyOf(fFields, fFields.length) : null;
}
/* (non-Javadoc)
*/
@Override
public ITmfEventField getField(final int index) {
- if (fFields != null && index >= 0 && index < fFields.length)
+ if (fFields != null && index >= 0 && index < fFields.length) {
return fFields[index];
+ }
return null;
}
*/
public final static ITmfEventField makeRoot(final String[] labels) {
final ITmfEventField[] fields = new ITmfEventField[labels.length];
- for (int i = 0; i < labels.length; i++)
+ for (int i = 0; i < labels.length; i++) {
fields[i] = new TmfEventField(labels[i], null);
- final ITmfEventField rootField = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, fields);
- return rootField;
+ }
+ // Return a new root field;
+ return new TmfEventField(ITmfEventField.ROOT_FIELD_ID, fields);
}
/*
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof TmfEventField))
+ }
+ if (!(obj instanceof TmfEventField)) {
return false;
+ }
final TmfEventField other = (TmfEventField) obj;
- if (!fName.equals(other.fName))
+ if (!fName.equals(other.fName)) {
return false;
+ }
if (fValue == null) {
- if (other.fValue != null)
+ if (other.fValue != null) {
return false;
- } else if (!fValue.equals(other.fValue))
+ }
+ } else if (!fValue.equals(other.fValue)) {
return false;
+ }
return true;
}
/**
- * <b><u>TmfEventType</u></b>
- * <p>
* A basic implementation of ITmfEventType.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfEventType
+ * @see ITmfEventField
+ * @see ITmfEvent
*/
public class TmfEventType implements ITmfEventType {
* @param root the root field
*/
public TmfEventType(final String context, final String typeId, final ITmfEventField root) {
- if (context == null || typeId == null)
+ if (context == null || typeId == null) {
throw new IllegalArgumentException();
+ }
fContext = context;
fTypeId = typeId;
fRootField = root;
* @param type the other type
*/
public TmfEventType(final ITmfEventType type) {
- if (type == null)
+ if (type == null) {
throw new IllegalArgumentException();
+ }
fContext = type.getContext();
fTypeId = type.getName();
fRootField = type.getRootField();
*/
@Override
public String[] getFieldNames() {
- String[] result = (fRootField != null) ? fRootField.getFieldNames() : null;
- return result;
+ return (fRootField != null) ? fRootField.getFieldNames() : null;
}
/* (non-Javadoc)
*/
@Override
public String getFieldName(final int index) {
- String result = (fRootField != null) ? fRootField.getFieldName(index) : null;
- return result;
+ return (fRootField != null) ? fRootField.getFieldName(index) : null;
}
// ------------------------------------------------------------------------
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof TmfEventType))
+ }
+ if (!(obj instanceof TmfEventType)) {
return false;
+ }
final TmfEventType other = (TmfEventType) obj;
- if (!fContext.equals(other.fContext))
+ if (!fContext.equals(other.fContext)) {
return false;
- if (!fTypeId.equals(other.fTypeId))
+ }
+ if (!fTypeId.equals(other.fTypeId)) {
return false;
+ }
return true;
}
package org.eclipse.linuxtools.tmf.core.event;
import java.util.HashMap;
+import java.util.Map;
/**
- * <b><u>TmfEventTypeManager</u></b>
- * <p>
* The TmfEventTypeManager acts as a central repository for the available
* event types. Types are managed in their context space.
- * <p>
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfEventType
*/
public final class TmfEventTypeManager {
private static TmfEventTypeManager fEventTypeManager = null;
// The available types, per context
- private final HashMap<String, HashMap<String, ITmfEventType>> fEventTypes;
+ private final Map<String, HashMap<String, ITmfEventType>> fEventTypes;
// ------------------------------------------------------------------------
// Constructors
* @return the TmfEventTypeManager singleton
*/
public static synchronized TmfEventTypeManager getInstance() {
- if (fEventTypeManager == null)
+ if (fEventTypeManager == null) {
fEventTypeManager = new TmfEventTypeManager();
+ }
return fEventTypeManager;
}
*/
public synchronized void add(final String context, final ITmfEventType type) {
HashMap<String, ITmfEventType> types = fEventTypes.get(context);
- if (types == null)
+ if (types == null) {
types = new HashMap<String, ITmfEventType>();
+ }
types.put(type.getName(), type);
fEventTypes.put(context, types);
}
*/
public synchronized ITmfEventType[] getTypes(final String context) {
final HashMap<String, ITmfEventType> types = fEventTypes.get(context);
- if (types != null)
+ if (types != null) {
return types.values().toArray(new ITmfEventType[types.size()]);
+ }
return null;
}
*/
public synchronized ITmfEventType getType(final String context, final String typeId) {
final HashMap<String, ITmfEventType> types = fEventTypes.get(context);
- if (types != null)
+ if (types != null) {
return types.get(typeId);
+ }
return null;
}
package org.eclipse.linuxtools.tmf.core.event;
/**
- * <b><u>TmfSimpleTimestamp</u></b>
- * <p>
- * A simplified timestamp where scale and precision are set to 0.
+ * A simplified timestamp where scale and precision are set to 0 i.e. timestamps
+ * are represented by the tuple { value, 0, 0 }.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfTimestamp
+ * @see TmfTimestamp
*/
public class TmfSimpleTimestamp extends TmfTimestamp {
* @param timestamp the timestamp to copy
*/
public TmfSimpleTimestamp(final ITmfTimestamp timestamp) {
- if (timestamp == null || timestamp.getScale() != 0 || timestamp.getPrecision() != 0)
+ if (timestamp == null || timestamp.getScale() != 0 || timestamp.getPrecision() != 0) {
throw new IllegalArgumentException();
- fValue = timestamp.getValue();
- fScale = 0;
- fPrecision = 0;
+ }
+ setValue(timestamp.getValue(), 0, 0);
}
// ------------------------------------------------------------------------
*/
@Override
public ITmfTimestamp normalize(final long offset, final int scale) throws ArithmeticException {
- if (scale == 0)
- return new TmfSimpleTimestamp(fValue + offset);
+ if (scale == 0) {
+ return new TmfSimpleTimestamp(getValue() + offset);
+ }
return super.normalize(offset, scale);
}
@Override
public int compareTo(final ITmfTimestamp ts, final boolean withinPrecision) {
if (ts instanceof TmfSimpleTimestamp) {
- final long delta = fValue - ts.getValue();
+ final long delta = getValue() - ts.getValue();
return (delta == 0) ? 0 : (delta > 0) ? 1 : -1;
}
return super.compareTo(ts, withinPrecision);
*/
@Override
public ITmfTimestamp getDelta(final ITmfTimestamp ts) {
- if (ts instanceof TmfSimpleTimestamp)
- return new TmfSimpleTimestamp(fValue - ts.getValue());
+ if (ts instanceof TmfSimpleTimestamp) {
+ return new TmfSimpleTimestamp(getValue() - ts.getValue());
+ }
return super.getDelta(ts);
}
// ------------------------------------------------------------------------
/* (non-Javadoc)
- * @see java.lang.Object#clone()
+ * @see org.eclipse.linuxtools.tmf.core.event.TmfTimestamp#clone()
*/
@Override
public TmfSimpleTimestamp clone() {
*/
@Override
public boolean equals(final Object other) {
- if (this == other)
+ if (this == other) {
return true;
- if (other == null)
+ }
+ if (other == null) {
return false;
- if (!(other instanceof TmfSimpleTimestamp))
+ }
+ if (!(other instanceof TmfSimpleTimestamp)) {
return super.equals(other);
+ }
final TmfSimpleTimestamp ts = (TmfSimpleTimestamp) other;
return compareTo(ts, false) == 0;
@Override
@SuppressWarnings("nls")
public String toString() {
- return "TmfSimpleTimestamp [fValue=" + fValue + "]";
+ return "TmfSimpleTimestamp [fValue=" + getValue() + "]";
}
}
package org.eclipse.linuxtools.tmf.core.event;
/**
- * <b><u>TmfTimeRange</u></b>
- * <p>
* A utility class to define and manage time ranges.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfTimestamp
+ * @see TmfTimestamp
*/
public final class TmfTimeRange implements Cloneable {
* @param endTime end of the time range
*/
public TmfTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
- if (startTime == null || endTime == null)
+ if (startTime == null || endTime == null) {
throw new IllegalArgumentException();
+ }
fStartTime = startTime;
fEndTime = endTime;
}
* @param range the other time range
*/
public TmfTimeRange(final TmfTimeRange range) {
- if (range == null)
+ if (range == null) {
throw new IllegalArgumentException();
+ }
fStartTime = range.getStartTime();
fEndTime = range.getEndTime();
}
*/
public boolean contains(final ITmfTimestamp ts) {
// Zero acts as a "universal donor" timestamp
- if (ts.equals(TmfTimestamp.ZERO))
+ if (ts.equals(TmfTimestamp.ZERO)) {
return true;
+ }
return (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
}
* @return the intersection time range, or null if no intersection exists
*/
public TmfTimeRange getIntersection(final TmfTimeRange range) {
- if (fStartTime.compareTo(range.fEndTime, true) > 0 || fEndTime.compareTo(range.fStartTime, true) < 0)
+ if (fStartTime.compareTo(range.fEndTime, true) > 0 || fEndTime.compareTo(range.fStartTime, true) < 0) {
return null; // no intersection
+ }
- return new TmfTimeRange(fStartTime.compareTo(range.fStartTime, true) < 0 ? range.fStartTime
- : fStartTime, fEndTime.compareTo(range.fEndTime, true) > 0 ? range.fEndTime
+ return new TmfTimeRange(fStartTime.compareTo(range.fStartTime, true) < 0
+ ? range.fStartTime
+ : fStartTime, fEndTime.compareTo(range.fEndTime, true) > 0
+ ? range.fEndTime
: fEndTime);
}
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (!(obj instanceof TmfTimeRange))
+ }
+ if (!(obj instanceof TmfTimeRange)) {
return false;
+ }
final TmfTimeRange other = (TmfTimeRange) obj;
- if (!fEndTime.equals(other.fEndTime))
+ if (!fEndTime.equals(other.fEndTime)) {
return false;
- if (!fStartTime.equals(other.fStartTime))
+ }
+ if (!fStartTime.equals(other.fStartTime)) {
return false;
+ }
return true;
}
package org.eclipse.linuxtools.tmf.core.event;
/**
- * <b><u>TmfTimestamp</u></b>
- * <p>
- * A generic implementation of ITmfTimestamp.
+ * A generic timestamp implementation. The timestamp is represented by the
+ * tuple { value, scale, precision }.
+ *
+ * @since 1.0
+ * @version 1.0
+ * @author Francois Chouinard
+ * @see ITmfTimestamp
+ * @see TmfSimpleTimestamp
*/
-public class TmfTimestamp implements ITmfTimestamp {
+public class TmfTimestamp implements ITmfTimestamp, Cloneable {
// ------------------------------------------------------------------------
// Constants
/**
* The timestamp raw value (mantissa)
*/
- protected long fValue;
+ private long fValue;
/**
* The timestamp scale (magnitude)
*/
- protected int fScale;
+ private int fScale;
/**
* The value precision (tolerance)
*/
- protected int fPrecision;
+ private int fPrecision;
// ------------------------------------------------------------------------
// Constructors
* @param timestamp the timestamp to copy
*/
public TmfTimestamp(final ITmfTimestamp timestamp) {
- if (timestamp == null)
+ if (timestamp == null) {
throw new IllegalArgumentException();
+ }
fValue = timestamp.getValue();
fScale = timestamp.getScale();
fPrecision = timestamp.getPrecision();
}
+ // ------------------------------------------------------------------------
+ // Setters
+ // ------------------------------------------------------------------------
+
+ protected void setValue(long value, int scale, int precision) {
+ fValue = value;
+ fScale = scale;
+ fPrecision = precision;
+ }
+
// ------------------------------------------------------------------------
// ITmfTimestamp
// ------------------------------------------------------------------------
int precision = fPrecision;
// Handle the trivial case
- if (fScale == scale && offset == 0)
+ if (fScale == scale && offset == 0) {
return new TmfTimestamp(this);
+ }
// First, scale the timestamp
if (fScale != scale) {
final int scaleDiff = Math.abs(fScale - scale);
- if (scaleDiff >= scalingFactors.length)
+ if (scaleDiff >= scalingFactors.length) {
throw new ArithmeticException("Scaling exception"); //$NON-NLS-1$
+ }
final long scalingFactor = scalingFactors[scaleDiff];
if (scale < fScale) {
}
// Then, apply the offset
- if (offset < 0)
+ if (offset < 0) {
value = (value < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : value + offset;
- else
+ } else {
value = (value > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : value + offset;
+ }
return new TmfTimestamp(value, scale, precision);
}
@Override
public int compareTo(final ITmfTimestamp ts, final boolean withinPrecision) {
- if (ts == null)
- return 1;
-
// Check the corner cases (we can't use equals() because it uses compareTo()...)
- if (this == ts || (fValue == ts.getValue() && fScale == ts.getScale()))
+ if (ts == null) {
+ return 1;
+ }
+ if (this == ts || (fValue == ts.getValue() && fScale == ts.getScale())) {
return 0;
- if ((fValue == BIG_BANG.getValue() && fScale == BIG_BANG.getScale()) || (ts.getValue() == BIG_CRUNCH.getValue() && ts.getScale() == BIG_CRUNCH.getScale()))
+ }
+ if ((fValue == BIG_BANG.getValue() && fScale == BIG_BANG.getScale()) || (ts.getValue() == BIG_CRUNCH.getValue() && ts.getScale() == BIG_CRUNCH.getScale())) {
return -1;
- if ((fValue == BIG_CRUNCH.getValue() && fScale == BIG_CRUNCH.getScale()) || (ts.getValue() == BIG_BANG.getValue() && ts.getScale() == BIG_BANG.getScale()))
+ }
+ if ((fValue == BIG_CRUNCH.getValue() && fScale == BIG_CRUNCH.getScale()) || (ts.getValue() == BIG_BANG.getValue() && ts.getScale() == BIG_BANG.getScale())) {
return 1;
+ }
try {
final ITmfTimestamp nts = ts.normalize(0, fScale);
final long delta = fValue - nts.getValue();
- if ((delta == 0) || (withinPrecision && (Math.abs(delta) <= (fPrecision + nts.getPrecision()))))
+ if ((delta == 0) || (withinPrecision && (Math.abs(delta) <= (fPrecision + nts.getPrecision())))) {
return 0;
+ }
return (delta > 0) ? 1 : -1;
}
catch (final ArithmeticException e) {
// First, look at the sign of the mantissa
final long value = ts.getValue();
- if (fValue == 0 && value == 0)
+ if (fValue == 0 && value == 0) {
return 0;
- if (fValue < 0 && value >= 0)
+ }
+ if (fValue < 0 && value >= 0) {
return -1;
- if (fValue >= 0 && value < 0)
+ }
+ if (fValue >= 0 && value < 0) {
return 1;
+ }
// Otherwise, just compare the scales
final int scale = ts.getScale();
*/
@Override
public boolean equals(final Object other) {
- if (this == other)
+ if (this == other) {
return true;
- if (other == null)
+ }
+ if (other == null) {
return false;
- if (!(other instanceof TmfTimestamp))
+ }
+ if (!(other instanceof TmfTimestamp)) {
return false;
+ }
final TmfTimestamp ts = (TmfTimestamp) other;
return compareTo(ts, false) == 0;
}