001 package org.hackystat.telemetry.analyzer.configuration; 002 003 import org.hackystat.telemetry.analyzer.language.TelemetryLanguageException; 004 import org.hackystat.telemetry.analyzer.language.ast.TelemetryChartYAxisDefinition; 005 import org.hackystat.telemetry.analyzer.language.parser.TelemetryLanguageParser; 006 import org.hackystat.sensorbase.resource.users.jaxb.User; 007 008 /** 009 * Provides information about a telemetry chart y-axis definition, including its 010 * name, type, and definition. 011 * 012 * @author (Cedric) Qin Zhang 013 */ 014 public class TelemetryChartYAxisDefinitionInfo extends TelemetryDefinitionInfo { 015 016 private TelemetryChartYAxisDefinition chartYAxisDefinition; 017 018 /** 019 * Constructs this instance. 020 * 021 * @param fullDefinitionString The defintion string. 022 * @param owner The owner of this definition. 023 * @param shareScope The share scope of this definition. 024 * 025 * @throws TelemetryConfigurationException If the definition string cannot be parsed. 026 */ 027 public TelemetryChartYAxisDefinitionInfo(String fullDefinitionString, User owner, 028 ShareScope shareScope) throws TelemetryConfigurationException { 029 super(fullDefinitionString, owner, shareScope); 030 try { 031 this.chartYAxisDefinition = TelemetryLanguageParser.parseChartYAxisDef(fullDefinitionString); 032 } 033 catch (TelemetryLanguageException ex) { 034 throw new TelemetryConfigurationException(ex); 035 } 036 //TODO: though the definition is syntatically correct, need to perform semantic validation! 037 } 038 039 /** 040 * Constructs this instance. 041 * 042 * @param chartYAxisDefinition The telemetry chart y-axis definition. 043 * @param owner The owner of this definition. 044 * @param shareScope The share scope of this definition. 045 * 046 * @throws TelemetryConfigurationException If the definition string cannot be parsed. 047 */ 048 public TelemetryChartYAxisDefinitionInfo(TelemetryChartYAxisDefinition chartYAxisDefinition, 049 User owner, ShareScope shareScope) throws TelemetryConfigurationException { 050 super(chartYAxisDefinition.getDefinitionString(), owner, shareScope); 051 this.chartYAxisDefinition = chartYAxisDefinition; 052 } 053 054 055 /** 056 * Gets the name of this telemetry definition. 057 * 058 * @return The name. 059 */ 060 @Override 061 public String getName() { 062 return this.chartYAxisDefinition.getName(); 063 } 064 065 /** 066 * Gets telemetry definition type. 067 * 068 * @return Telemetry definition type. 069 */ 070 @Override 071 public TelemetryDefinitionType getType() { 072 return TelemetryDefinitionType.YAXIS; 073 } 074 075 /** 076 * Gets the abstract syntax tree representation of this telemetry chart y-axis. 077 * 078 * @return The abstract syntax tree representation. 079 */ 080 public TelemetryChartYAxisDefinition getChartYAxisDefinitionObject() { 081 return this.chartYAxisDefinition; 082 } 083 }