projects
/
deliverable
/
tracecompass.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
afc86f7
)
Fix Sonar findings in TmfEvent
author
Francois Chouinard
<fchouinard@gmail.com>
Wed, 25 Apr 2012 20:39:05 +0000
(16:39 -0400)
committer
Francois Chouinard
<fchouinard@gmail.com>
Fri, 27 Apr 2012 03:02:51 +0000
(23:02 -0400)
14 files changed:
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngTimestamp.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTimestampStub.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
patch
|
blob
|
blame
|
history
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
patch
|
blob
|
blame
|
history
diff --git
a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngTimestamp.java
b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngTimestamp.java
index 5d6380843dff710e64ade845b424cf49a9970e2a..f85c6749fa04858748d7302af6c60486b502253c 100644
(file)
--- a/
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngTimestamp.java
+++ b/
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/internal/lttng/core/event/LttngTimestamp.java
@@
-51,7
+51,7
@@
public class LttngTimestamp extends TmfTimestamp {
}
public void setValue(final long newValue) {
}
public void setValue(final long newValue) {
-
fValue = newValue
;
+
setValue(newValue, -9, 0)
;
}
/**
}
/**
@@
-62,7
+62,7
@@
public class LttngTimestamp extends TmfTimestamp {
* @return Seconds in the object, in string.
*/
public String getSeconds() {
* @return Seconds in the object, in string.
*/
public String getSeconds() {
- return formatSecs(
fValue
);
+ return formatSecs(
getValue()
);
}
/**
}
/**
@@
-73,7
+73,7
@@
public class LttngTimestamp extends TmfTimestamp {
* @return Seconds in the object, in string.
*/
public String getNanoSeconds() {
* @return Seconds in the object, in string.
*/
public String getNanoSeconds() {
- return formatNs(
fValue
);
+ return formatNs(
getValue()
);
}
/*
}
/*
@@
-132,20
+132,21
@@
public class LttngTimestamp extends TmfTimestamp {
@SuppressWarnings("nls")
public String toString() {
@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 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 = (-
fS
cale) - sb.length() + 1;
+ final int nbZeroes = (-
s
cale) - sb.length() + 1;
for (int i = 0; i < nbZeroes; i++)
sb.insert(i, "0");
for (int i = 0; i < nbZeroes; i++)
sb.insert(i, "0");
- sb.insert(sb.length() +
fS
cale, ".");
+ sb.insert(sb.length() +
s
cale, ".");
// Prepend "-" if negative
// Prepend "-" if negative
- if (
fValue
< 0)
+ if (
getValue()
< 0)
sb.insert(0, "-");
return sb.toString();
sb.insert(0, "-");
return sb.toString();
diff --git
a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTimestampStub.java
b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTimestampStub.java
index 74e3a595b9d234c776669009b6040c1513f7c3c7..bd739dbd8cc9ea6dbb40dc18d7664e1190a9b236 100644
(file)
--- a/
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTimestampStub.java
+++ b/
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng/stubs/LTTngTimestampStub.java
@@
-33,20
+33,23
@@
public class LTTngTimestampStub extends TmfTimestamp {
@Override
public String 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 we are dealing with units of seconds (or higher),
// use the plain formatter
- if (
fS
cale >= 0) {
- Double
value = fValue * Math.pow(10, fS
cale);
- return value.toString();
+ if (
s
cale >= 0) {
+ Double
dvalue = value * Math.pow(10, s
cale);
+ return
d
value.toString();
}
// Define a format string
}
// Define a format string
- String format = String.format("%%1d.%%0%dd", -
fS
cale);
+ String format = String.format("%%1d.%%0%dd", -
s
cale);
// And format the timestamp value
// And format the timestamp value
- double
scale = Math.pow(10, fS
cale);
- long seconds = (long) (
fValue *
scale);
- long fracts =
fValue - (long) ((double) seconds /
scale);
+ double
dscale = Math.pow(10, s
cale);
+ long seconds = (long) (
value * d
scale);
+ long fracts =
value - (long) ((double) seconds / d
scale);
String result = String.format(format, seconds, fracts);
return result;
String result = String.format(format, seconds, fracts);
return result;
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java
index c9193943bdcac7443e86f7c00ac52a9cabd89df4..5b3c098e0b83ecfb45b8d4e2b71865b16ac250ee 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java
@@
-13,8
+13,7
@@
public class CtfTmfTimestamp extends TmfTimestamp implements ITmfTimestamp {
public CtfTmfTimestamp(long timestamp, CtfTmfTrace trace) {
fTrace = trace;
public CtfTmfTimestamp(long timestamp, CtfTmfTrace trace) {
fTrace = trace;
- fValue = timestamp;
- fScale = (byte) -9;
+ setValue(timestamp, -9, 0);
}
/* (non-Javadoc)
}
/* (non-Javadoc)
@@
-60,7
+59,7
@@
public class CtfTmfTimestamp extends TmfTimestamp implements ITmfTimestamp {
*/
@Override
public String toString() {
*/
@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);
final Date d = new Date(timestamp / 1000000);
final DateFormat df = new SimpleDateFormat("HH:mm:ss."); //$NON-NLS-1$
final long nanos = (timestamp % 1000000000);
@@
-71,7
+70,7
@@
public class CtfTmfTimestamp extends TmfTimestamp implements ITmfTimestamp {
}
public String toFullDateString(){
}
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);
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);
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
index 550d86de3029cc14bc26c91b4c025b8c64721f02..d27d3c44f86d4701c09eaaee81b78eb6e82b3268 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
@@
-15,8
+15,6
@@
package org.eclipse.linuxtools.tmf.core.event;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
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
* The basic event structure in TMF. In its canonical form, a data item has:
* <ul>
* <li> a parent trace
@@
-30,6
+28,10
@@
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
* used as e.g. a location marker (filename:lineno) to indicate where the event
* was generated.
*
* 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
* @see ITmfTimestamp
* @see ITmfEventType
* @see ITmfEvetnField
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
index 5c4bcf789cd13b915d3cc4b6d62e79c138d4f8c8..9cd575ec837f6af7ba0390493cd0bbf4185147fe 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
@@
-12,11
+12,17
@@
package org.eclipse.linuxtools.tmf.core.event;
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.
* 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 {
*/
public interface ITmfEventField extends Cloneable {
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
index cf0ecaf734dcde4568a1f9b364da3fa5130a0a18..20c8a92a23245274af3c73652fba0c6594085b14 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
@@
-12,13
+12,18
@@
package org.eclipse.linuxtools.tmf.core.event;
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.
* 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 {
*/
public interface ITmfEventType extends Cloneable {
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
index b72fb83e5b985cab105fb3ee44af4d36697c29ed..aad0ef4c520c6761099de164cae1efb40e59b8c8 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
@@
-13,8
+13,6
@@
package org.eclipse.linuxtools.tmf.core.event;
/**
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:
* The fundamental time reference in the TMF.
* <p>
* It defines a generic timestamp interface in its most basic form:
@@
-69,7
+67,7
@@
public interface ITmfTimestamp extends Cloneable, Comparable<ITmfTimestamp> {
* @param scale the new timestamp scale
* @return a new 'adjusted' ITmfTimestamp
*/
* @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
/**
* Compares [this] and [ts] within timestamp precision
@@
-105,6
+103,6
@@
public interface ITmfTimestamp extends Cloneable, Comparable<ITmfTimestamp> {
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
-
public
int compareTo(ITmfTimestamp ts);
+ int compareTo(ITmfTimestamp ts);
}
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
index f01a1650bc62358b6188d0ca1d9031f8d0612022..86aa033eef846cf439fe14c722748bbf0ac7e298 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
@@
-16,14
+16,20
@@
package org.eclipse.linuxtools.tmf.core.event;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
- * <b><u>TmfEvent</u></b>
- * <p>
* A basic implementation of ITmfEvent.
* 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().
* 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 {
// ------------------------------------------------------------------------
public class TmfEvent implements ITmfEvent {
// ------------------------------------------------------------------------
@@
-104,8
+110,9
@@
public class TmfEvent implements ITmfEvent {
* @param event the original event
*/
public TmfEvent(final ITmfEvent event) {
* @param event the original event
*/
public TmfEvent(final ITmfEvent event) {
- if (event == null)
+ if (event == null)
{
throw new IllegalArgumentException();
throw new IllegalArgumentException();
+ }
fTrace = event.getTrace();
fRank = event.getRank();
fTimestamp = event.getTimestamp();
fTrace = event.getTrace();
fRank = event.getRank();
fTimestamp = event.getTimestamp();
@@
-278,45
+285,61
@@
public class TmfEvent implements ITmfEvent {
*/
@Override
public boolean equals(final Object obj) {
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj)
{
return true;
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
return false;
- if (!(obj instanceof TmfEvent))
+ }
+ if (!(obj instanceof TmfEvent)) {
return false;
return false;
+ }
final TmfEvent other = (TmfEvent) obj;
if (fTrace == null) {
final TmfEvent other = (TmfEvent) obj;
if (fTrace == null) {
- if (other.fTrace != null)
+ if (other.fTrace != null)
{
return false;
return false;
- } else if (!fTrace.equals(other.fTrace))
+ }
+ } else if (!fTrace.equals(other.fTrace)) {
return false;
return false;
- if (fRank != other.fRank)
+ }
+ if (fRank != other.fRank) {
return false;
return false;
+ }
if (fTimestamp == null) {
if (fTimestamp == null) {
- if (other.fTimestamp != null)
+ if (other.fTimestamp != null)
{
return false;
return false;
- } else if (!fTimestamp.equals(other.fTimestamp))
+ }
+ } else if (!fTimestamp.equals(other.fTimestamp)) {
return false;
return false;
+ }
if (fSource == null) {
if (fSource == null) {
- if (other.fSource != null)
+ if (other.fSource != null)
{
return false;
return false;
- } else if (!fSource.equals(other.fSource))
+ }
+ } else if (!fSource.equals(other.fSource)) {
return false;
return false;
+ }
if (fType == null) {
if (fType == null) {
- if (other.fType != null)
+ if (other.fType != null)
{
return false;
return false;
- } else if (!fType.equals(other.fType))
+ }
+ } else if (!fType.equals(other.fType)) {
return false;
return false;
+ }
if (fContent == null) {
if (fContent == null) {
- if (other.fContent != null)
+ if (other.fContent != null)
{
return false;
return false;
- } else if (!fContent.equals(other.fContent))
+ }
+ } else if (!fContent.equals(other.fContent)) {
return false;
return false;
+ }
if (fReference == null) {
if (fReference == null) {
- if (other.fReference != null)
+ if (other.fReference != null)
{
return false;
return false;
- } else if (!fReference.equals(other.fReference))
+ }
+ } else if (!fReference.equals(other.fReference)) {
return false;
return false;
+ }
return true;
}
return true;
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
index 615b30f850cfbc31c32a7180a0f9fa53c5933c0a..5124489a3e179504fda1a943333962f3880ab798 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
@@
-18,11
+18,17
@@
import java.util.HashMap;
import java.util.Map;
/**
import java.util.Map;
/**
- *
<b><u>TmfEventField</u></b>
+ *
A basic implementation of ITmfEventField.
* <p>
* <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 {
*/
public class TmfEventField implements ITmfEventField {
@@
-76,8
+82,9
@@
public class TmfEventField implements ITmfEventField {
* @param fields the list of subfields
*/
public TmfEventField(final String name, final Object value, final ITmfEventField[] fields) {
* @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();
throw new IllegalArgumentException();
+ }
fName = name;
fValue = value;
fFields = (fields != null) ? Arrays.copyOf(fields, fields.length) : null;
fName = name;
fValue = value;
fFields = (fields != null) ? Arrays.copyOf(fields, fields.length) : null;
@@
-90,8
+97,9
@@
public class TmfEventField implements ITmfEventField {
* @param field the other event field
*/
public TmfEventField(final TmfEventField field) {
* @param field the other event field
*/
public TmfEventField(final TmfEventField field) {
- if (field == null)
+ if (field == null)
{
throw new IllegalArgumentException();
throw new IllegalArgumentException();
+ }
fName = field.fName;
fValue = field.fValue;
fFields = field.fFields;
fName = field.fName;
fValue = field.fValue;
fFields = field.fFields;
@@
-133,8
+141,9
@@
public class TmfEventField implements ITmfEventField {
@Override
public String getFieldName(final int index) {
final ITmfEventField field = getField(index);
@Override
public String getFieldName(final int index) {
final ITmfEventField field = getField(index);
- if (field != null)
+ if (field != null)
{
return field.getName();
return field.getName();
+ }
return null;
}
return null;
}
@@
-143,8
+152,7
@@
public class TmfEventField implements ITmfEventField {
*/
@Override
public ITmfEventField[] getFields() {
*/
@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)
}
/* (non-Javadoc)
@@
-160,8
+168,9
@@
public class TmfEventField implements ITmfEventField {
*/
@Override
public ITmfEventField getField(final int index) {
*/
@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 fFields[index];
+ }
return null;
}
return null;
}
@@
-191,10
+200,11
@@
public class TmfEventField implements ITmfEventField {
*/
public final static ITmfEventField makeRoot(final String[] labels) {
final ITmfEventField[] fields = new ITmfEventField[labels.length];
*/
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);
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);
}
/*
}
/*
@@
-253,20
+263,26
@@
public class TmfEventField implements ITmfEventField {
*/
@Override
public boolean equals(final Object obj) {
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj)
{
return true;
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
return false;
- if (!(obj instanceof TmfEventField))
+ }
+ if (!(obj instanceof TmfEventField)) {
return false;
return false;
+ }
final TmfEventField other = (TmfEventField) obj;
final TmfEventField other = (TmfEventField) obj;
- if (!fName.equals(other.fName))
+ if (!fName.equals(other.fName))
{
return false;
return false;
+ }
if (fValue == null) {
if (fValue == null) {
- if (other.fValue != null)
+ if (other.fValue != null)
{
return false;
return false;
- } else if (!fValue.equals(other.fValue))
+ }
+ } else if (!fValue.equals(other.fValue)) {
return false;
return false;
+ }
return true;
}
return true;
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java
index b35703d6bcf8ae538413ec2a9534df06801326be..dd12746c6f465d3a07c2dbbeda24d7d8068158c8 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java
@@
-15,9
+15,14
@@
package org.eclipse.linuxtools.tmf.core.event;
/**
/**
- * <b><u>TmfEventType</u></b>
- * <p>
* A basic implementation of ITmfEventType.
* 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 {
*/
public class TmfEventType implements ITmfEventType {
@@
-48,8
+53,9
@@
public class TmfEventType implements ITmfEventType {
* @param root the root field
*/
public TmfEventType(final String context, final String typeId, final ITmfEventField root) {
* @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();
throw new IllegalArgumentException();
+ }
fContext = context;
fTypeId = typeId;
fRootField = root;
fContext = context;
fTypeId = typeId;
fRootField = root;
@@
-64,8
+70,9
@@
public class TmfEventType implements ITmfEventType {
* @param type the other type
*/
public TmfEventType(final ITmfEventType type) {
* @param type the other type
*/
public TmfEventType(final ITmfEventType type) {
- if (type == null)
+ if (type == null)
{
throw new IllegalArgumentException();
throw new IllegalArgumentException();
+ }
fContext = type.getContext();
fTypeId = type.getName();
fRootField = type.getRootField();
fContext = type.getContext();
fTypeId = type.getName();
fRootField = type.getRootField();
@@
-104,8
+111,7
@@
public class TmfEventType implements ITmfEventType {
*/
@Override
public String[] getFieldNames() {
*/
@Override
public String[] getFieldNames() {
- String[] result = (fRootField != null) ? fRootField.getFieldNames() : null;
- return result;
+ return (fRootField != null) ? fRootField.getFieldNames() : null;
}
/* (non-Javadoc)
}
/* (non-Javadoc)
@@
-113,8
+119,7
@@
public class TmfEventType implements ITmfEventType {
*/
@Override
public String getFieldName(final int index) {
*/
@Override
public String getFieldName(final int index) {
- String result = (fRootField != null) ? fRootField.getFieldName(index) : null;
- return result;
+ return (fRootField != null) ? fRootField.getFieldName(index) : null;
}
// ------------------------------------------------------------------------
}
// ------------------------------------------------------------------------
@@
-159,17
+164,22
@@
public class TmfEventType implements ITmfEventType {
*/
@Override
public boolean equals(final Object obj) {
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj)
{
return true;
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
return false;
- if (!(obj instanceof TmfEventType))
+ }
+ if (!(obj instanceof TmfEventType)) {
return false;
return false;
+ }
final TmfEventType other = (TmfEventType) obj;
final TmfEventType other = (TmfEventType) obj;
- if (!fContext.equals(other.fContext))
+ if (!fContext.equals(other.fContext))
{
return false;
return false;
- if (!fTypeId.equals(other.fTypeId))
+ }
+ if (!fTypeId.equals(other.fTypeId)) {
return false;
return false;
+ }
return true;
}
return true;
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
index 56e5be9b08969aeebf8952171bea35a4c9cc3b93..375bde90ed7063ccc74076c332c0c059dee6160c 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java
@@
-13,14
+13,17
@@
package org.eclipse.linuxtools.tmf.core.event;
import java.util.HashMap;
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.
* 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 {
*/
public final class TmfEventTypeManager {
@@
-32,7
+35,7
@@
public final class TmfEventTypeManager {
private static TmfEventTypeManager fEventTypeManager = null;
// The available types, per context
private static TmfEventTypeManager fEventTypeManager = null;
// The available types, per context
- private final
Hash
Map<String, HashMap<String, ITmfEventType>> fEventTypes;
+ private final Map<String, HashMap<String, ITmfEventType>> fEventTypes;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
// Constructors
@@
-49,8
+52,9
@@
public final class TmfEventTypeManager {
* @return the TmfEventTypeManager singleton
*/
public static synchronized TmfEventTypeManager getInstance() {
* @return the TmfEventTypeManager singleton
*/
public static synchronized TmfEventTypeManager getInstance() {
- if (fEventTypeManager == null)
+ if (fEventTypeManager == null)
{
fEventTypeManager = new TmfEventTypeManager();
fEventTypeManager = new TmfEventTypeManager();
+ }
return fEventTypeManager;
}
return fEventTypeManager;
}
@@
-66,8
+70,9
@@
public final class TmfEventTypeManager {
*/
public synchronized void add(final String context, final ITmfEventType type) {
HashMap<String, ITmfEventType> types = fEventTypes.get(context);
*/
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 = new HashMap<String, ITmfEventType>();
+ }
types.put(type.getName(), type);
fEventTypes.put(context, types);
}
types.put(type.getName(), type);
fEventTypes.put(context, types);
}
@@
-89,8
+94,9
@@
public final class TmfEventTypeManager {
*/
public synchronized ITmfEventType[] getTypes(final String context) {
final HashMap<String, ITmfEventType> types = fEventTypes.get(context);
*/
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 types.values().toArray(new ITmfEventType[types.size()]);
+ }
return null;
}
return null;
}
@@
-103,8
+109,9
@@
public final class TmfEventTypeManager {
*/
public synchronized ITmfEventType getType(final String context, final String typeId) {
final HashMap<String, ITmfEventType> types = fEventTypes.get(context);
*/
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 types.get(typeId);
+ }
return null;
}
return null;
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
index 2dd8022c7801799912c4abc3d134f7c42b7ac165..717839c6be8b70e219d417091ffe6198f6f2f60c 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java
@@
-13,9
+13,14
@@
package org.eclipse.linuxtools.tmf.core.event;
/**
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 {
*/
public class TmfSimpleTimestamp extends TmfTimestamp {
@@
-45,11
+50,10
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
* @param timestamp the timestamp to copy
*/
public TmfSimpleTimestamp(final ITmfTimestamp timestamp) {
* @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();
throw new IllegalArgumentException();
- fValue = timestamp.getValue();
- fScale = 0;
- fPrecision = 0;
+ }
+ setValue(timestamp.getValue(), 0, 0);
}
// ------------------------------------------------------------------------
}
// ------------------------------------------------------------------------
@@
-61,8
+65,9
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
*/
@Override
public ITmfTimestamp normalize(final long offset, final int scale) throws ArithmeticException {
*/
@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);
}
return super.normalize(offset, scale);
}
@@
-72,7
+77,7
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
@Override
public int compareTo(final ITmfTimestamp ts, final boolean withinPrecision) {
if (ts instanceof TmfSimpleTimestamp) {
@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);
return (delta == 0) ? 0 : (delta > 0) ? 1 : -1;
}
return super.compareTo(ts, withinPrecision);
@@
-83,8
+88,9
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
*/
@Override
public ITmfTimestamp getDelta(final ITmfTimestamp ts) {
*/
@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);
}
return super.getDelta(ts);
}
@@
-93,7
+99,7
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
// ------------------------------------------------------------------------
/* (non-Javadoc)
// ------------------------------------------------------------------------
/* (non-Javadoc)
- * @see
java.lang.Object
#clone()
+ * @see
org.eclipse.linuxtools.tmf.core.event.TmfTimestamp
#clone()
*/
@Override
public TmfSimpleTimestamp clone() {
*/
@Override
public TmfSimpleTimestamp clone() {
@@
-117,12
+123,15
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
*/
@Override
public boolean equals(final Object other) {
*/
@Override
public boolean equals(final Object other) {
- if (this == other)
+ if (this == other)
{
return true;
return true;
- if (other == null)
+ }
+ if (other == null) {
return false;
return false;
- if (!(other instanceof TmfSimpleTimestamp))
+ }
+ if (!(other instanceof TmfSimpleTimestamp)) {
return super.equals(other);
return super.equals(other);
+ }
final TmfSimpleTimestamp ts = (TmfSimpleTimestamp) other;
return compareTo(ts, false) == 0;
final TmfSimpleTimestamp ts = (TmfSimpleTimestamp) other;
return compareTo(ts, false) == 0;
@@
-134,7
+143,7
@@
public class TmfSimpleTimestamp extends TmfTimestamp {
@Override
@SuppressWarnings("nls")
public String toString() {
@Override
@SuppressWarnings("nls")
public String toString() {
- return "TmfSimpleTimestamp [fValue=" +
fValue
+ "]";
+ return "TmfSimpleTimestamp [fValue=" +
getValue()
+ "]";
}
}
}
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
index 58da4c3b662526290aae8ae95a0ffa0b458a3ea9..534f44133d7159d16285194783f9f92c39364d4d 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java
@@
-14,9
+14,13
@@
package org.eclipse.linuxtools.tmf.core.event;
/**
package org.eclipse.linuxtools.tmf.core.event;
/**
- * <b><u>TmfTimeRange</u></b>
- * <p>
* A utility class to define and manage time ranges.
* 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 {
*/
public final class TmfTimeRange implements Cloneable {
@@
-61,8
+65,9
@@
public final class TmfTimeRange implements Cloneable {
* @param endTime end of the time range
*/
public TmfTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
* @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();
throw new IllegalArgumentException();
+ }
fStartTime = startTime;
fEndTime = endTime;
}
fStartTime = startTime;
fEndTime = endTime;
}
@@
-73,8
+78,9
@@
public final class TmfTimeRange implements Cloneable {
* @param range the other time range
*/
public TmfTimeRange(final TmfTimeRange range) {
* @param range the other time range
*/
public TmfTimeRange(final TmfTimeRange range) {
- if (range == null)
+ if (range == null)
{
throw new IllegalArgumentException();
throw new IllegalArgumentException();
+ }
fStartTime = range.getStartTime();
fEndTime = range.getEndTime();
}
fStartTime = range.getStartTime();
fEndTime = range.getEndTime();
}
@@
-109,8
+115,9
@@
public final class TmfTimeRange implements Cloneable {
*/
public boolean contains(final ITmfTimestamp ts) {
// Zero acts as a "universal donor" timestamp
*/
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 true;
+ }
return (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
}
return (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
}
@@
-137,11
+144,14
@@
public final class TmfTimeRange implements Cloneable {
* @return the intersection time range, or null if no intersection exists
*/
public TmfTimeRange getIntersection(final TmfTimeRange range) {
* @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 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);
}
: fEndTime);
}
@@
-186,17
+196,22
@@
public final class TmfTimeRange implements Cloneable {
*/
@Override
public boolean equals(final Object obj) {
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj)
+ if (this == obj)
{
return true;
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
return false;
- if (!(obj instanceof TmfTimeRange))
+ }
+ if (!(obj instanceof TmfTimeRange)) {
return false;
return false;
+ }
final TmfTimeRange other = (TmfTimeRange) obj;
final TmfTimeRange other = (TmfTimeRange) obj;
- if (!fEndTime.equals(other.fEndTime))
+ if (!fEndTime.equals(other.fEndTime))
{
return false;
return false;
- if (!fStartTime.equals(other.fStartTime))
+ }
+ if (!fStartTime.equals(other.fStartTime)) {
return false;
return false;
+ }
return true;
}
return true;
}
diff --git
a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
index b5aee95c7ef204778c04d27a65141999d37a47f8..c25f3c3f3a3b22797b7bfa1ed9ef6abf4845f3d7 100644
(file)
--- a/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
+++ b/
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
@@
-15,11
+15,16
@@
package org.eclipse.linuxtools.tmf.core.event;
/**
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
// ------------------------------------------------------------------------
// Constants
@@
-50,17
+55,17
@@
public class TmfTimestamp implements ITmfTimestamp {
/**
* The timestamp raw value (mantissa)
*/
/**
* The timestamp raw value (mantissa)
*/
- pr
otected
long fValue;
+ pr
ivate
long fValue;
/**
* The timestamp scale (magnitude)
*/
/**
* The timestamp scale (magnitude)
*/
- pr
otected
int fScale;
+ pr
ivate
int fScale;
/**
* The value precision (tolerance)
*/
/**
* The value precision (tolerance)
*/
- pr
otected
int fPrecision;
+ pr
ivate
int fPrecision;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
// Constructors
@@
-111,13
+116,24
@@
public class TmfTimestamp implements ITmfTimestamp {
* @param timestamp the timestamp to copy
*/
public TmfTimestamp(final ITmfTimestamp timestamp) {
* @param timestamp the timestamp to copy
*/
public TmfTimestamp(final ITmfTimestamp timestamp) {
- if (timestamp == null)
+ if (timestamp == null)
{
throw new IllegalArgumentException();
throw new IllegalArgumentException();
+ }
fValue = timestamp.getValue();
fScale = timestamp.getScale();
fPrecision = timestamp.getPrecision();
}
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
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// ITmfTimestamp
// ------------------------------------------------------------------------
@@
-178,14
+194,16
@@
public class TmfTimestamp implements ITmfTimestamp {
int precision = fPrecision;
// Handle the trivial case
int precision = fPrecision;
// Handle the trivial case
- if (fScale == scale && offset == 0)
+ if (fScale == scale && offset == 0)
{
return new TmfTimestamp(this);
return new TmfTimestamp(this);
+ }
// First, scale the timestamp
if (fScale != scale) {
final int scaleDiff = Math.abs(fScale - scale);
// 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$
throw new ArithmeticException("Scaling exception"); //$NON-NLS-1$
+ }
final long scalingFactor = scalingFactors[scaleDiff];
if (scale < fScale) {
final long scalingFactor = scalingFactors[scaleDiff];
if (scale < fScale) {
@@
-198,10
+216,11
@@
public class TmfTimestamp implements ITmfTimestamp {
}
// Then, apply the offset
}
// Then, apply the offset
- if (offset < 0)
+ if (offset < 0)
{
value = (value < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : value + offset;
value = (value < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : value + offset;
- else
+ } else {
value = (value > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : value + offset;
value = (value > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : value + offset;
+ }
return new TmfTimestamp(value, scale, precision);
}
return new TmfTimestamp(value, scale, precision);
}
@@
-212,22
+231,26
@@
public class TmfTimestamp implements ITmfTimestamp {
@Override
public int compareTo(final ITmfTimestamp ts, final boolean withinPrecision) {
@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()...)
// 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;
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;
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;
return 1;
+ }
try {
final ITmfTimestamp nts = ts.normalize(0, fScale);
final long delta = fValue - nts.getValue();
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 0;
+ }
return (delta > 0) ? 1 : -1;
}
catch (final ArithmeticException e) {
return (delta > 0) ? 1 : -1;
}
catch (final ArithmeticException e) {
@@
-235,12
+258,15
@@
public class TmfTimestamp implements ITmfTimestamp {
// First, look at the sign of the mantissa
final long value = ts.getValue();
// 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;
return 0;
- if (fValue < 0 && value >= 0)
+ }
+ if (fValue < 0 && value >= 0) {
return -1;
return -1;
- if (fValue >= 0 && value < 0)
+ }
+ if (fValue >= 0 && value < 0) {
return 1;
return 1;
+ }
// Otherwise, just compare the scales
final int scale = ts.getScale();
// Otherwise, just compare the scales
final int scale = ts.getScale();
@@
-312,12
+338,15
@@
public class TmfTimestamp implements ITmfTimestamp {
*/
@Override
public boolean equals(final Object other) {
*/
@Override
public boolean equals(final Object other) {
- if (this == other)
+ if (this == other)
{
return true;
return true;
- if (other == null)
+ }
+ if (other == null) {
return false;
return false;
- if (!(other instanceof TmfTimestamp))
+ }
+ if (!(other instanceof TmfTimestamp)) {
return false;
return false;
+ }
final TmfTimestamp ts = (TmfTimestamp) other;
return compareTo(ts, false) == 0;
}
final TmfTimestamp ts = (TmfTimestamp) other;
return compareTo(ts, false) == 0;
}
This page took
0.040761 seconds
and
5
git commands to generate.