From: Matthew Khouzam Date: Tue, 10 Apr 2012 21:23:59 +0000 (-0400) Subject: Fix warnings X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=cbfd482220c7e6cac1c97b22982429425d206e07;p=deliverable%2Ftracecompass.git Fix warnings --- diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java index 41977a7bb4..f6daa8473f 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java @@ -38,7 +38,6 @@ public class Benchmark { try { System.in.read(); } catch (IOException e1) { - // TODO Auto-generated catch block e1.printStackTrace(); } // Work variables diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java index 64a51252c1..67bf70891b 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java @@ -119,6 +119,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext, return curLocation; } + @SuppressWarnings("unused") @Override public void updateRank(int rank) { // not needed I think diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java index 5cab5cb62f..f70b569df2 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java @@ -8,7 +8,7 @@ public class CtfLocation implements ITmfLocation { public CtfLocation(Long location) { setLocation(location); } - + public CtfLocation(ITmfTimestamp timestamp) { setLocation(timestamp.getValue()); } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java index 8ca36fe46c..76a325e0a5 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java @@ -20,7 +20,6 @@ import org.eclipse.linuxtools.ctf.core.event.EventDefinition; import org.eclipse.linuxtools.ctf.core.event.types.Definition; import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition; import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader; -import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.ITmfEventType; diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java index 20234a1fde..c7b71e02ba 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java @@ -138,7 +138,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { /** * Return the int representing this field's value type - * + * * @return the field type */ public abstract int getFieldType(); @@ -146,7 +146,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { /** * Return this field's value. You can cast it to the correct type depending * on what getFieldType says. - * + * * @return the field value */ @Override @@ -155,7 +155,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { /** * Other methods defined by ITmfEventField, but not used here: the CTF * fields do not have sub-fields (yet!) - * + * * @return the field names */ @Override @@ -163,6 +163,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { return null; } + @SuppressWarnings("unused") @Override public String getFieldName(int index) { return null; @@ -173,11 +174,13 @@ public abstract class CtfTmfEventField implements ITmfEventField { return null; } + @SuppressWarnings("unused") @Override public ITmfEventField getField(String fieldName) { return null; } + @SuppressWarnings("unused") @Override public ITmfEventField getField(int index) { return null; @@ -212,7 +215,7 @@ final class CTFIntegerField extends CtfTmfEventField { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override @@ -245,7 +248,7 @@ final class CTFStringField extends CtfTmfEventField { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override 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 276d99de52..c9193943bd 100644 --- 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 @@ -17,6 +17,42 @@ public class CtfTmfTimestamp extends TmfTimestamp implements ITmfTimestamp { fScale = (byte) -9; } + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = (prime * result) + ((fTrace == null) ? 0 : fTrace.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof CtfTmfTimestamp)) { + return false; + } + CtfTmfTimestamp other = (CtfTmfTimestamp) obj; + if (fTrace == null) { + if (other.fTrace != null) { + return false; + } + } else if (!fTrace.equals(other.fTrace)) { + return false; + } + return true; + } + /* * (non-Javadoc) * @@ -24,6 +60,17 @@ public class CtfTmfTimestamp extends TmfTimestamp implements ITmfTimestamp { */ @Override public String toString() { + final long timestamp = fValue; + final Date d = new Date(timestamp / 1000000); + final DateFormat df = new SimpleDateFormat("HH:mm:ss."); //$NON-NLS-1$ + final long nanos = (timestamp % 1000000000); + StringBuilder output = new StringBuilder(); + output.append(df.format(d)); + output.append(String.format("%09d", nanos)); //$NON-NLS-1$ + return output.toString(); + } + + public String toFullDateString(){ final long timestamp = fValue; final Date d = new Date(timestamp / 1000000); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java index b55c1e970f..c06820f488 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java @@ -57,6 +57,7 @@ public class CtfTmfTrace extends TmfEventProvider implements super(); } + @SuppressWarnings("unused") @Override public void initTrace(String name, String path, Class eventType) throws FileNotFoundException { @@ -68,7 +69,6 @@ public class CtfTmfTrace extends TmfEventProvider implements * was not found or was not recognized as a CTF trace. Throw into * the new type of exception expected by the rest of TMF. */ - System.err.println("Cannot find file " + path); //$NON-NLS-1$ throw new FileNotFoundException(e.getMessage()); } this.iterator = new CtfIterator(this, 0, 0); @@ -83,8 +83,10 @@ public class CtfTmfTrace extends TmfEventProvider implements // this.fEndTime.clone())); } + @SuppressWarnings("unused") @Override public void indexTrace(boolean waitForCompletion) { + // do nothing } @Override @@ -97,6 +99,7 @@ public class CtfTmfTrace extends TmfEventProvider implements TmfSignalManager.dispatchSignal(signal); } + @SuppressWarnings("unused") @Override public boolean validate(IProject project, String path) { try { @@ -223,6 +226,7 @@ public class CtfTmfTrace extends TmfEventProvider implements * FIXME merge with getNextEvent below once they both use the same parameter * type. */ + @SuppressWarnings("unused") @Override public CtfTmfEvent getNext(ITmfContext context) { iterator.advance(); @@ -235,19 +239,21 @@ public class CtfTmfTrace extends TmfEventProvider implements @Override public ITmfContext seekLocation(ITmfLocation location) { - if (location == null) { - location = new CtfLocation(0L); + CtfLocation currentLocation = (CtfLocation) location; + if (currentLocation == null) { + currentLocation = new CtfLocation(0L); } - iterator.setLocation(location); + iterator.setLocation(currentLocation); return iterator; } @Override public double getLocationRatio(ITmfLocation location) { - CtfIterator curLocation = (CtfIterator) location; - return ((double) curLocation.getCurrentEvent().getTimestampValue() - curLocation + CtfLocation curLocation = (CtfLocation) location; + iterator.seek(curLocation.getLocation()); + return ((double) iterator.getCurrentEvent().getTimestampValue() - iterator .getStartTime()) - / (curLocation.getEndTime() - curLocation.getStartTime()); + / (iterator.getEndTime() - iterator.getStartTime()); } @Override @@ -279,12 +285,14 @@ public class CtfTmfTrace extends TmfEventProvider implements return iterator; } + @SuppressWarnings("unused") @Override - public CtfTmfEvent getNextEvent(ITmfContext context) { + public CtfTmfEvent getNextEvent( ITmfContext context) { iterator.advance(); return iterator.getCurrentEvent(); } + @SuppressWarnings("unused") @Override public CtfTmfEvent parseEvent(ITmfContext context) { return iterator.getCurrentEvent();