001    package org.hackystat.telemetry.analyzer.evaluator;
002    
003    import java.util.ArrayList;
004    import java.util.Collections;
005    import java.util.List;
006    
007    import org.hackystat.telemetry.analyzer.language.ast.TelemetryStreamsDefinition;
008    import org.hackystat.telemetry.analyzer.model.TelemetryStream;
009    
010    /**
011     * The evaluation result after resolving a telemetry streams definition. 
012     *
013     * @author (Cedric) Qin Zhang
014     */
015    public class TelemetryStreamsObject {
016      
017      private TelemetryStreamsDefinition definition;
018      private List<Stream> streams = new ArrayList<Stream>();
019      
020      /**
021       * Constructs this instance.
022       * 
023       * @param definition The telemetry streams definition.
024       */
025      TelemetryStreamsObject(TelemetryStreamsDefinition definition) {
026        this.definition = definition;
027      }
028      
029      /**
030       * Gets the telemetry streams definition.
031       * 
032       * @return The telemetry steams definiton. 
033       */
034      public TelemetryStreamsDefinition getTelemetryStreamsDefinition() {
035        return this.definition;
036      }
037      
038      /**
039       * Adds a telemetry stream.
040       * 
041       * @param stream The telemetry stream to be added.
042       */
043      void addStream(Stream stream) {
044        this.streams.add(stream);
045      }
046      
047      /**
048       * Gets a read-only list of all telemetry streams..
049       * 
050       * @return A read-only list containing <code>Stream</code> objects.
051       */
052      public List<Stream> getStreams() {
053        return Collections.unmodifiableList(this.streams);
054      }
055      
056      /**
057       * A telemetry stream.
058       * 
059       * @author (Cedric) Qin ZHANG
060       * @version $Id$
061       */
062      public static class Stream {
063        
064        private String name;    
065        private TelemetryStream stream;
066    
067        /**
068         * Constructs this instance.
069         * 
070         * @param name The name of the telemetry stream.
071         * @param stream A <code>TelemetryStream</code> object.
072         */
073        Stream(String name, TelemetryStream stream) {
074          this.name = name;
075          this.stream = stream;
076        }
077        
078        /**
079         * Gets the name of the telemetry stream.
080         * 
081         * @return The name.
082         */
083        public String getName() {
084          return this.name;
085        }
086        
087        /**
088         * Gets the <code>TelemetryStream</code> object.
089         * 
090         * @return The <code>TelemetryStream</code> object.
091         */
092        public TelemetryStream getTelemetryStream() {
093          return this.stream;
094        }
095      }
096    }