ctf: Add missing @since to previous patch
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / trace / CTFTrace.java
index 925a6845847faef8b23712071fc163e1dea7d280..a1a9e9c43177f768176f68db08a146743a48e6e7 100644 (file)
@@ -24,6 +24,7 @@ import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileChannel.MapMode;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -48,7 +49,6 @@ import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
 import org.eclipse.linuxtools.internal.ctf.core.event.CTFCallsiteComparator;
 import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
-import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndex;
 
 /**
  * A CTF trace on the file system.
@@ -136,12 +136,6 @@ public class CTFTrace implements IDefinitionScope {
     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>>();
-
-    /** map of all the indexes */
-    private final Map<StreamInput, StreamInputPacketIndex> indexes = new HashMap<StreamInput, StreamInputPacketIndex>();
-
     /** Callsite helpers */
     private CTFCallsiteComparator ctfCallsiteComparator = new CTFCallsiteComparator();
 
@@ -206,8 +200,8 @@ public class CTFTrace implements IDefinitionScope {
         }
 
         /* Create their index */
-        for (Map.Entry<Long, Stream> stream : streams.entrySet()) {
-            Set<StreamInput> inputs = stream.getValue().getStreamInputs();
+        for (Stream stream : getStreams()) {
+            Set<StreamInput> inputs = stream.getStreamInputs();
             for (StreamInput s : inputs) {
                 /*
                  * Copy the events
@@ -261,21 +255,7 @@ public class CTFTrace implements IDefinitionScope {
      * @since 2.0
      */
     public Map<Long, IEventDeclaration> getEvents(Long streamId) {
-        return eventDecs.get(streamId);
-    }
-
-    /**
-     * Gets an index for a given StreamInput
-     *
-     * @param id
-     *            the StreamInput
-     * @return The index
-     */
-    StreamInputPacketIndex getIndex(StreamInput id) {
-        if (!indexes.containsKey(id)) {
-            indexes.put(id, new StreamInputPacketIndex());
-        }
-        return indexes.get(id);
+        return streams.get(streamId).getEvents();
     }
 
     /**
@@ -379,11 +359,12 @@ public class CTFTrace implements IDefinitionScope {
     }
 
     /**
-     * Method majortIsSet is the major version number set?
+     * Method majorIsSet is the major version number set?
      *
      * @return boolean is the major set?
+     * @since 3.0
      */
-    public boolean majortIsSet() {
+    public boolean majorIsSet() {
         return major != null;
     }
 
@@ -479,12 +460,13 @@ public class CTFTrace implements IDefinitionScope {
     }
 
     /**
-     * Method getStreams get all the streams in a map format.
+     * Get all the streams as an iterable.
      *
-     * @return Map<Long,Stream> a map of all the streams.
+     * @return Iterable<Stream> an iterable over streams.
+     * @since 3.0
      */
-    public Map<Long, Stream> getStreams() {
-        return streams;
+    public Iterable<Stream> getStreams() {
+        return streams.values();
     }
 
     /**
@@ -531,7 +513,7 @@ public class CTFTrace implements IDefinitionScope {
             fc = fis.getChannel();
 
             /* Map one memory page of 4 kiB */
-            byteBuffer = fc.map(MapMode.READ_ONLY, 0, Math.min((int) fc.size(), 4096));
+            byteBuffer = fc.map(MapMode.READ_ONLY, 0, (int) Math.min(fc.size(), 4096L));
         } catch (IOException e) {
             /* Shouldn't happen at this stage if every other check passed */
             throw new CTFReaderException(e);
@@ -647,30 +629,19 @@ public class CTFTrace implements IDefinitionScope {
             throw new ParseException("Stream id already exists"); //$NON-NLS-1$
         }
 
-        /* It should be ok now. */
+        /* This stream is valid and has a unique id. */
         streams.put(stream.getId(), stream);
-        eventDecs.put(stream.getId(), new HashMap<Long, IEventDeclaration>());
     }
 
     /**
-     * gets the Environment variables from the trace metadata (See CTF spec)
+     * Gets the Environment variables from the trace metadata (See CTF spec)
      *
-     * @return the environment variables in a map form (key value)
+     * @return The environment variables in the form of an unmodifiable map
+     *         (key, value)
      * @since 2.0
      */
     public Map<String, String> getEnvironment() {
-        return environment;
-    }
-
-    /**
-     * Look up a specific environment variable
-     *
-     * @param key
-     *            the key to look for
-     * @return the value of the variable, can be null.
-     */
-    public String lookupEnvironment(String key) {
-        return environment.get(key);
+        return Collections.unmodifiableMap(environment);
     }
 
     /**
@@ -808,34 +779,6 @@ public class CTFTrace implements IDefinitionScope {
         return retVal - getOffset();
     }
 
-    /**
-     * Does a given stream contain any events?
-     *
-     * @param id
-     *            the stream ID
-     * @return true if the stream has events.
-     */
-    public boolean hasEvents(Long id) {
-        return eventDecs.containsKey(id);
-    }
-
-    /**
-     * 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 Map<Long, IEventDeclaration> createEvents(Long id) {
-        HashMap<Long, IEventDeclaration> value = eventDecs.get(id);
-        if (value == null) {
-            value = new HashMap<Long, IEventDeclaration>();
-            eventDecs.put(id, value);
-        }
-        return value;
-    }
-
     /**
      * Adds a callsite
      *
This page took 0.02637 seconds and 5 git commands to generate.