ctf: Fix some Sonar warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / trace / CTFTrace.java
index 915061760bba574bb6c8886d604f6f29f953d5c2..f7b0bad5fa0ec4a1bd8596c28fd5db38384d1bdf 100644 (file)
@@ -76,11 +76,6 @@ public class CTFTrace implements IDefinitionScope {
      */
     private final File path;
 
-    /**
-     * The metadata parsing object.
-     */
-    private final Metadata metadata;
-
     /**
      * Major CTF version number
      */
@@ -138,9 +133,8 @@ public class CTFTrace implements IDefinitionScope {
     private final List<FileInputStream> fileInputStreams = new LinkedList<FileInputStream>();
 
     /** Handlers for the metadata files */
-    private final static FileFilter metadataFileFilter = new MetadataFileFilter();
-    private final static Comparator<File> metadataComparator = new MetadataComparator(); // $codepro.audit.disable
-                                                                                         // fieldJavadoc
+    private static final FileFilter METADATA_FILE_FILTER = new MetadataFileFilter();
+    private static final Comparator<File> METADATA_COMPARATOR = new MetadataComparator();
 
     /** map of all the event types */
     private final Map<Long,HashMap<Long, IEventDeclaration>> eventDecs = new HashMap<Long, HashMap<Long,IEventDeclaration>>();
@@ -151,6 +145,7 @@ public class CTFTrace implements IDefinitionScope {
 
     /** Callsite helpers */
     private Map<String, LinkedList<CTFCallsite>> callsitesByName = new HashMap<String, LinkedList<CTFCallsite>>();
+
     /** Callsite helpers */
     private TreeSet<CTFCallsite> callsitesByIP = new TreeSet<CTFCallsite>();
 
@@ -183,7 +178,7 @@ public class CTFTrace implements IDefinitionScope {
      */
     public CTFTrace(File path) throws CTFReaderException {
         this.path = path;
-        this.metadata = new Metadata(this);
+        final Metadata metadata = new Metadata(this);
 
         /* Set up the internal containers for this trace */
         if (!this.path.exists()) {
@@ -205,8 +200,8 @@ public class CTFTrace implements IDefinitionScope {
         }
 
         /* List files not called metadata and not hidden. */
-        File[] files = path.listFiles(metadataFileFilter);
-        Arrays.sort(files, metadataComparator);
+        File[] files = path.listFiles(METADATA_FILE_FILTER);
+        Arrays.sort(files, METADATA_COMPARATOR);
         /* Try to open each file */
         for (File streamFile : files) {
             openStreamInput(streamFile);
@@ -263,8 +258,9 @@ public class CTFTrace implements IDefinitionScope {
      * @param streamId
      *            The ID of the stream from which to read
      * @return The Hash map with the event declarations
+     * @since 2.0
      */
-    public HashMap<Long, IEventDeclaration> getEvents(Long streamId) {
+    public Map<Long, IEventDeclaration> getEvents(Long streamId) {
         return eventDecs.get(streamId);
     }
 
@@ -286,7 +282,7 @@ public class CTFTrace implements IDefinitionScope {
      * @return the hashmap with the event definitions
      * @since 2.0
      */
-    public HashMap<Long, EventDefinition> getEventDefs(StreamInput id) {
+    public Map<Long, EventDefinition> getEventDefs(StreamInput id) {
         if(! eventDefs.containsKey(id)){
             eventDefs.put(id, new HashMap<Long, EventDefinition>());
         }
@@ -400,8 +396,9 @@ public class CTFTrace implements IDefinitionScope {
      * Method UUIDIsSet is the UUID set?
      *
      * @return boolean is the UUID set?
+     * @since 2.0
      */
-    public boolean UUIDIsSet() {
+    public boolean uuidIsSet() {
         return uuid != null;
     }
 
@@ -455,7 +452,7 @@ public class CTFTrace implements IDefinitionScope {
      *
      * @return ByteOrder gets the trace byte order
      */
-    public ByteOrder getByteOrder() {
+    public final ByteOrder getByteOrder() {
         return byteOrder;
     }
 
@@ -533,7 +530,7 @@ public class CTFTrace implements IDefinitionScope {
             byteBuffer = fc.map(MapMode.READ_ONLY, 0, Math.min((int)fc.size(), 4096));
         } catch (IOException e) {
             /* Shouldn't happen at this stage if every other check passed */
-            throw new CTFReaderException();
+            throw new CTFReaderException(e);
         }
 
         /* Create a BitBuffer with this mapping and the trace byte order */
@@ -729,7 +726,7 @@ public class CTFTrace implements IDefinitionScope {
      *
      * @return the time offset of a clock with respect to UTC in nanoseconds
      */
-    private final double getTimeScale() {
+    private double getTimeScale() {
         if (getClock() == null) {
             return 1.0;
         }
@@ -741,7 +738,7 @@ public class CTFTrace implements IDefinitionScope {
      *
      * @return if the trace is in ns or cycles.
      */
-    private final boolean clockNeedsScale() {
+    private boolean clockNeedsScale() {
         if (getClock() == null) {
             return false;
         }
@@ -753,7 +750,7 @@ public class CTFTrace implements IDefinitionScope {
      *
      * @return 1.0 / scale
      */
-    private final double getInverseTimeScale() {
+    private double getInverseTimeScale() {
         if (getClock() == null) {
             return 1.0;
         }
@@ -811,8 +808,9 @@ public class CTFTrace implements IDefinitionScope {
      * Add an event declaration map to the events map.
      * @param id the id of a stream
      * @return the hashmap containing events.
+     * @since 2.0
      */
-    public HashMap<Long, IEventDeclaration> createEvents(Long id){
+    public Map<Long, IEventDeclaration> createEvents(Long id){
         HashMap<Long, IEventDeclaration> value = eventDecs.get(id);
         if( value == null ) {
             value = new HashMap<Long, IEventDeclaration>();
This page took 0.02647 seconds and 5 git commands to generate.