Author: jruchaud Date: 2015-06-09 15:25:25 +0000 (Tue, 09 Jun 2015) New Revision: 1657 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1657 Log: Use class Modified: oipf/lib/js/impl/model/MetadataSearch.js oipf/lib/js/impl/model/ModelFactory.js oipf/lib/js/impl/model/NetworkInterface.js oipf/lib/js/impl/model/NetworkInterfaceCollection.js oipf/lib/js/impl/model/ParentalRating.js oipf/lib/js/impl/model/ParentalRatingCollection.js oipf/lib/js/impl/model/ParentalRatingScheme.js oipf/lib/js/impl/model/ParentalRatingSchemeCollection.js Modified: oipf/lib/js/impl/model/MetadataSearch.js =================================================================== --- oipf/lib/js/impl/model/MetadataSearch.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/MetadataSearch.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -9,7 +9,7 @@ * 1. Definition of the query. The application creates a MetadataSearch object, and either creates its associated * Query object, or sets a query using the findProgrammesFromStream() method, and sets any applicable * constraints and result ordering. -* +* * 2. Acquisition of results. The OITF acquires some or all of the items that match the specified query and constraints, and * caches the requested subset of the results. This is typically triggered by a call to getResults(). * @@ -17,7 +17,7 @@ * The MetadataSearch and SearchResults classes work together to manage an individual search. For every search, * the MetadataSearch object and its corresponding SearchResults object SHALL be in one of three states as * described in table below: -* +* * --------------------------------------------------------------------------------------------------------------------------------------------------------------- * State | Description * ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------- @@ -29,7 +29,7 @@ * | SearchResults object SHALL return zero. Any search results that have been cached by * | the terminal SHALL be discarded when the Idle state is entered. * | Calling the SearchResults.getResults() method SHALL cause a state transition to -* | the Searching state. +* | the Searching state. * ---------- --------------------------------------------------------------------------------------------------------------------------------------------------- * Searching | Results are being retrieved and are not yet available to applications. * | @@ -94,65 +94,57 @@ * MAY gather all search results and cache them (or cache a set of pointers into the full database), or gather only the subset * of search results determined by the getResults() parameters, or take an alternative approach not described here. */ -var MetadataSearch = Class.extend({ - - _searchManager: null, - - _currentQuery: null, - - _constraints: null, - - _ordering: null, - - /* - * Description: - * The subset of search results that has been requested by the application. - * - * Visibility Type: readonly SearchResults - */ - result: null, - - /* - * Description : - * The target(s) of the search. Valid values are: - * - * ----------------------------------------------------------------- - * Value | Description - * ------ ---------------------------------------------------------- - * 1 | Metadata relating to scheduled content SHALL be searched. - * 2 | Metadata relating to on-demand content SHALL be searched. - * - * These values SHALL be treated as a bitfield, allowing searches to be carried out across multiple search - * targets. - * - * Visibility: readonly - */ - searchTarget: null, - - init: function(searchTarget, searchManager) { - this._searchManager = searchManager; +class MetadataSearch { + + constructor(searchTarget, searchManager) { + + this._currentQuery = null; + + /* + * Description: + * The subset of search results that has been requested by the application. + * + * Visibility Type: readonly SearchResults + */ this.result = new SearchResults(this); + + /* + * Description : + * The target(s) of the search. Valid values are: + * + * ----------------------------------------------------------------- + * Value | Description + * ------ ---------------------------------------------------------- + * 1 | Metadata relating to scheduled content SHALL be searched. + * 2 | Metadata relating to on-demand content SHALL be searched. + * + * These values SHALL be treated as a bitfield, allowing searches to be carried out across multiple search + * targets. + * + * Visibility: readonly + */ this.searchTarget = searchTarget; + + this._searchManager = searchManager; this._constraints = { channels: [], ratings: [] }; this._ordering = []; - + this._fireEventModified = this._searchManager ._fireEventModified.bind(this._searchManager); + } - }, - /* - * Description: + * Description: * Set a query and constraints for retrieving metadata for programmes from a given channel * and given start time from metadata contained in the stream as defined in section 4.1.3 of * [OIPF_META2]. Setting the search parameters using this method will implicitly remove any * existing constraints, ordering or queries created by prior calls to methods on this object. * This method does not cause the search to be performed; applications must call * getResults() to retrieve the results. - * + * * Arguments: * - channel: The channel for which programme information should be found. * @@ -169,132 +161,126 @@ * getResults() even if a call to getResults() requests more results. * If this argument is not specified, no restrictions are imposed on the number of * results which may be returned by calls to getResults(). - * + * */ - findProgrammesFromStream: function(channel, startTime, count) { + findProgrammesFromStream(channel, startTime, count) { var parameters = arguments; if (parameters.length > 3) { throw new TypeError("Excessive number of arguments."); } - + if (parameters.length < 1) { throw new TypeError("Insufficient number of arguments."); } - + if (!(channel instanceof Channel) || (startTime && !Number.isInteger(startTime)) || (count && !Number.isInteger(count))) { - throw new TypeError - ("This function cannot be called with these arguments."); + throw new TypeError("This function cannot be called with these arguments."); } - + this._abortIfNecessary(); - + console.log("[INFO]: findProgrammesFromStream [IN]"); this.addChannelConstraint(channel); this._currentQuery = new Query("startTime", 0, startTime, count); console.log("[INFO]: findProgrammesFromStream [Out]"); - }, - + } + /* - * Description: - * Set the query terms to be used for this search, + * Description: + * Set the query terms to be used for this search, * discarding any previously-set query terms. - * Setting the search parameters using this method will implicitly remove - * any existing constraints, ordering or queries created + * Setting the search parameters using this method will implicitly remove + * any existing constraints, ordering or queries created * by prior calls to methods on this object. - * + * * Arguments: - * -query: The query terms to be used. - * + * -query: The query terms to be used. + * */ - setQuery: function(query) { + setQuery(query) { var parameters = arguments; - + if (parameters.length > 1) { throw new TypeError("Excessive number of arguments."); } - + if (parameters.length < 1) { throw new TypeError("Insufficient number of arguments."); } - + if (!(query instanceof Query)) { - - throw new TypeError - ("This function cannot be called with this argument."); - + throw new TypeError("This function cannot be called with this argument."); } - + this._abortIfNecessary(); this._currentQuery = query; - }, - + } + /* * Description: - * Constrain the search to only include results from - * the specified channel(s). - * If a channelconstraint has already been set, subsequent calls to - * addChannelConstraint() SHALL add the specified channel(s) to the list of + * Constrain the search to only include results from + * the specified channel(s). + * If a channelconstraint has already been set, subsequent calls to + * addChannelConstraint() SHALL add the specified channel(s) to the list of * channels from which results should be returned. * For CoD searches, adding a channel constraint SHALL have no effect. - * + * * Arguments: - * -channels: The channel(s) from which results SHALL be returned. - * If the value of this argument is null, any existing channel - * constraint SHALL be removed. - * + * -channels: The channel(s) from which results SHALL be returned. + * If the value of this argument is null, any existing channel + * constraint SHALL be removed. + * */ - addChannelConstraint: function(channels) { + addChannelConstraint(channels) { var parameters = arguments; - + if (parameters.length > 1) { throw new TypeError("Excessive number of arguments."); } - + if (parameters.length < 1) { throw new TypeError("Insufficient number of arguments."); } - + if (!channels) { this._constraints.channels.length = 0; - + } else if (!(channels instanceof ChannelList) && !(channels instanceof Channel)) { - throw new TypeError - ("This function cannot be called with this argument."); - + throw new TypeError("This function cannot be called with this argument."); + } - + this._abortIfNecessary(); - + if (this._constraints.channels) { this._constraints.channels = this._constraints.channels.concat(channels); - + } - - }, - + } + /* * Description: - * Description Constrain the search to only include results whose + * Description Constrain the search to only include results whose * parental rating value is below the specified threshold. - * + * * Arguments: - * -scheme: The parental rating scheme upon which the constraint - * SHALL be based. If the value of this argument is null, + * -scheme: The parental rating scheme upon which the constraint + * SHALL be based. If the value of this argument is null, * any existing parental rating constraints SHALL be cleared. - * - * -threshold: The threshold above which results SHALL NOT be returned. - * If the value of this argument is null, + * + * -threshold: The threshold above which results SHALL NOT be returned. + * If the value of this argument is null, * any existing constraint for the specified parental - * rating scheme SHALL be cleared. + * rating scheme SHALL be cleared. */ - addRatingConstraint: function(scheme, threshold) { + addRatingConstraint(scheme, threshold) { this._abortIfNecessary(); - + if (scheme && threshold) { var rating = { scheme: scheme, @@ -303,93 +289,87 @@ this._constraints.ratings && this._constraints.ratings.push(rating); - + } else if (this._constraints.ratings) { this._constraints.ratings.length = 0; } - - }, - + } + /* * Description: - * Description Constrain the search to only include results whose + * Description Constrain the search to only include results whose * parental rating value is below the specified threshold. */ - addCurrentRatingConstraint: function() { - - }, - + addCurrentRatingConstraint() { + + } + /* * Description: - * Create a metadata query for a specific value in a specific - * field within the metadata. Simple queries MAY be combined to + * Create a metadata query for a specific value in a specific + * field within the metadata. Simple queries MAY be combined to * create more complex queries. Applications SHALL follow the - * JavaScript type conversion rules to convert non-string values + * JavaScript type conversion rules to convert non-string values * into their string representation, if necessary. */ - createQuery: function(field, comparison, value) { + createQuery(field, comparison, value) { var parameters = arguments; if (parameters.length > 3) { - throw new TypeError - ("Excessive number of arguments."); + throw new TypeError("Excessive number of arguments."); } - - if (!(typeof field === "string") || + + if (!(typeof field === "string") || !Number.isInteger(comparison) || (!Number.isInteger(value) && !(typeof value === "string"))) { - - throw new TypeError - ("This function cannot be called with these arguments."); - + + throw new TypeError("This function cannot be called with these arguments."); + } return new Query(field, comparison, value); - }, - + } + /* * Description: - * Set the order in which results SHOULD be returned in future. - * Any existing search results SHALL not be re-ordered. Subsequent calls + * Set the order in which results SHOULD be returned in future. + * Any existing search results SHALL not be re-ordered. Subsequent calls * to orderBy() will apply further levels of ordering within the order * defined by previous calls. * For example: * orderBy("ServiceName", true); * orderBy("PublishedStart", true); - * will cause results to be ordered by service name and then by start time + * will cause results to be ordered by service name and then by start time * for results with the same channel number. - * + * * Arguments: * -field: The name of the field by which results SHOULD be sorted. - * A value of null indicates that any currently-set order SHALL be cleared + * A value of null indicates that any currently-set order SHALL be cleared * and the default sort order should be used. - * - * -ascending: Flag indicating whether the results SHOULD + * + * -ascending: Flag indicating whether the results SHOULD * be returned in ascending or descending order. */ - orderBy: function(field, ascending) { + orderBy(field, ascending) { var parameters = arguments; - if (parameters.length != 2) { - throw new TypeError - ("Excessive number of arguments."); - } - - if ((!(typeof field === "string") && - field && - Number.isInteger(field)) || + if (parameters.length !== 2) { + throw new TypeError("Excessive number of arguments."); + } + + if (!(typeof field === "string") && + field && + Number.isInteger(field) || !(typeof ascending === "boolean")) { throw new TypeError("This function cannot be called with these arguments."); } - + if (this._ordering) { this._ordering.push({ field: field, ascending: ascending }); } + } - }, - - _removeConstraints: function() { - + _removeConstraints() { var keys = Object.keys(this._constraints); for (var i = 0, l = keys.length; i < l; i++) { var constraint = this._constraints[keys[i]]; @@ -397,21 +377,21 @@ constraint.length = 0; } } - }, - - _removeQuery: function() { + } + + _removeQuery() { this._currentQuery = null; - }, - - _removeOrdering: function() { + } + + _removeOrdering() { this._ordering = null; - }, - - _abortIfNecessary: function() { - if (this.result._timerManager.timer) { - this.result.abort(); - this._fireEventModified(this); - } } -}); \ No newline at end of file + _abortIfNecessary() { + if (this.result._timerManager.timer) { + this.result.abort(); + this._fireEventModified(this); + } + } + +} Modified: oipf/lib/js/impl/model/ModelFactory.js =================================================================== --- oipf/lib/js/impl/model/ModelFactory.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/ModelFactory.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,93 +1,85 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ +class ModelFactory { -var ModelFactory = Class.extend({ - - init: function(metadataObject) { + constructor(metadataObject) { this.metadataObject = metadataObject; this.metadataManager = null; this.xmlTvData = null; // this.createXmlTvData(); // this.createMetadataManager(); this.capabilitiesProperties = new CapabilitiesProperties(); - }, - - createXmlTvData: function() { + } + + createXmlTvData() { console.log("Method createXmlTvData"); - return this.getProperty("xmlTvData") || - this.setProperty("xmlTvData", + return this.getProperty("xmlTvData") || + this.setProperty("xmlTvData", new XmlTvData(this.metadataObject)); - - }, - - getXmlTvData: function() { + } + + getXmlTvData() { console.log("Method createXmlTvData"); return this.getProperty("xmlTvData"); - }, - + } + /* * FIXME: Yannis - 06/05/2015 - Get a method to find an available number for * randomIndex. */ - getAProgrammeFromXmlTvData: function() { + getAProgrammeFromXmlTvData() { console.log("Method createXmlTvData"); - var randomIndex = oipf.utils.getRandomNumberBetweenMinMax(0, + var randomIndex = oipf.utils.getRandomNumberBetweenMinMax(0, this.xmlTvData.programmes.length); - + if (this.xmlTvData && this.xmlTvData.programmes[randomIndex]) { return this.xmlTvData.programmes[15]; } - - }, - - createScheduledRecording: function() { + } + + createScheduledRecording() { console.log("Method createScheduledRecording"); return new ScheduledRecording(this.getAPrgrammeFromXmlTvData()); - }, - - createRecording: function() { + } + + createRecording() { console.log("Method createRecording"); return new Recording(this.createScheduledRecording()); - }, - - createMetadataManager: function() { + } + + createMetadataManager() { console.log("Method createMetadataManager"); - + if (this.getProperty("metadataManager")) { return this.getProperty("metadataManager"); } - + this.setProperty("metadataManager", new MetadataManager()); this.getProperty("metadataManager").addMetadata(this.getXmlTvData()); - + return this.getProperty("metadataManager"); - }, - - getXmlParser: function() { + } + + getXmlParser() { return new XmlParser(); - }, - - getMetadataManager: function() { + } + + getMetadataManager() { console.log("Method getMetadataManager"); return this.getProperty("metadataManager"); - }, - - getProperty: function(propertyName) { + } + + getProperty(propertyName) { console.log("Method getProperty"); return this[propertyName]; - }, - - setProperty: function(propertyName, value) { + } + + setProperty(propertyName, value) { console.log("Method setProperty"); this[propertyName] = value; - }, - - getCapabilitiesProperties: function() { + } + + getCapabilitiesProperties() { return this.capabilitiesProperties; } - -}); + +} Modified: oipf/lib/js/impl/model/NetworkInterface.js =================================================================== --- oipf/lib/js/impl/model/NetworkInterface.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/NetworkInterface.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,52 +1,41 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ +class NetworkInterface { -var NetworkInterface = Class.extend({ - /* - * Description: - * The IP address of the network interface, in dotted-quad notation for IPv4 - * or colon-hexadecimal notation for IPv6. This property SHALL take - * the value undefined if no IP address has been assigned. The IP address - * may be link local, private or global, depending on which address block it - * belongs to, as reserved by IANA. - * - * Visibility Type: readonly String - */ - ipAddress: null, - - /* - * Description: - * The colon-separated MAC address of the network interface. - * - * Visibility Type: readonly String - */ - macAddress: null, - - /* - * Description: - * Flag indicating whether the network interface is currently connected. - * - * Visibility Type: readonly Boolean - */ - connected: null, + constructor(ipAddress, macAddress, connected, enabled) { + /* + * Description: + * The IP address of the network interface, in dotted-quad notation for IPv4 + * or colon-hexadecimal notation for IPv6. This property SHALL take + * the value undefined if no IP address has been assigned. The IP address + * may be link local, private or global, depending on which address block it + * belongs to, as reserved by IANA. + * + * Visibility Type: readonly String + */ + this.ipAddress = ipAddress; - /* - * Description: - * Flag indicating whether the network interface is enabled. - * Setting this property SHALL enable or disable the network interface. - * - * Type: Boolean - */ - enabled: null, + /* + * Description: + * The colon-separated MAC address of the network interface. + * + * Visibility Type: readonly String + */ + this.macAddress = macAddress; - init: function(ipAddress, macAddress, connected, enabled) { - this.ipAddress= ipAddress; - this.macAddress= macAddress; - this.connected= connected; - this.enabled= enabled; - } -}); + /* + * Description: + * Flag indicating whether the network interface is currently connected. + * + * Visibility Type: readonly Boolean + */ + this.connected = connected; + /* + * Description: + * Flag indicating whether the network interface is enabled. + * Setting this property SHALL enable or disable the network interface. + * + * Type: Boolean + */ + this.enabled = enabled; + } +} Modified: oipf/lib/js/impl/model/NetworkInterfaceCollection.js =================================================================== --- oipf/lib/js/impl/model/NetworkInterfaceCollection.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/NetworkInterfaceCollection.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,12 +1,5 @@ -/* - * The NetworkInterfaceCollection class represents a collection of - * NetworkInterface objects. See Annex K for the definition - * of the collection template. - */ - -var NetworkInterfaceCollection = Collection.extend({ - init: function() { - this.super.init.apply(this, arguments); - +class NetworkInterfaceCollection extends Collection { + constructor(...args) { + super(...args); } -}); +} Modified: oipf/lib/js/impl/model/ParentalRating.js =================================================================== --- oipf/lib/js/impl/model/ParentalRating.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/ParentalRating.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,58 +1,53 @@ -/* +/* * A ParentalRating object describes a parental rating value for a programme or * channel. The ParentalRating object identifies both the rating scheme in use, * and the parental rating value within that scheme. In case of a BCG the values - * of the properties in this object will be read from the ParentalGuidance + * of the properties in this object will be read from the ParentalGuidance * element that is the child of a programme’s BCG description. */ -var ParentalRating = Class.extend({ - - /* - * Visibility Type: readonly String - */ - name: null, - - /* - * Description: - * Unique name identifying the parental rating guidance scheme to which this - * parental rating value refers. - * - * Valid strings include: - * - the URI of one of the MPEG-7 classification schemes representing a - * parental rating scheme as defined by the “ uri ” attribute of one of the - * parental rating <ClassificationScheme> elements in [MPEG-7]. - * - * - the string value “ urn:oipf:GermanyFSKCS ” to represent the GermanyFSK - * rating scheme as defined in [OIPF_META2]. - * - * - the string value “ dvb-si ”: this means that the scheme of a minimum - * recommended age encoded as per [EN 300 468], is used to represent the - * parental rating values. - * - * Visibility Type: readonly String - */ - scheme: null, - - /* - * Visibility Type: readonly Integer - */ - value: null, - - /* - * Visibility Type: readonly Integer - */ - labels: null, - - /* - * Visibility Type: readonly String - */ - region: null, - - init : function(name, scheme, value, labels, region) { +class ParentalRating { + + constructor(name, scheme, value, labels, region) { + /* + * Visibility Type: readonly String + */ this.name = name; + + /* + * Description: + * Unique name identifying the parental rating guidance scheme to which this + * parental rating value refers. + * + * Valid strings include: + * - the URI of one of the MPEG-7 classification schemes representing a + * parental rating scheme as defined by the “ uri ” attribute of one of the + * parental rating <ClassificationScheme> elements in [MPEG-7]. + * + * - the string value “ urn:oipf:GermanyFSKCS ” to represent the GermanyFSK + * rating scheme as defined in [OIPF_META2]. + * + * - the string value “ dvb-si ”: this means that the scheme of a minimum + * recommended age encoded as per [EN 300 468], is used to represent the + * parental rating values. + * + * Visibility Type: readonly String + */ this.scheme = scheme; + + /* + * Visibility Type: readonly Integer + */ this.value = value; + + /* + * Visibility Type: readonly Integer + */ this.labels = labels; + + /* + * Visibility Type: readonly String + */ this.region = region; } -}); + +} Modified: oipf/lib/js/impl/model/ParentalRatingCollection.js =================================================================== --- oipf/lib/js/impl/model/ParentalRatingCollection.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/ParentalRatingCollection.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,49 +1,46 @@ -/* +/* * typedef Collection<ParentalRating> ParentalRatingCollection * A ParentalRatingCollection represents a collection of parental rating values. - * See Annex K for the definition of the collection template. In addition to + * See Annex K for the definition of the collection template. In addition to * the methods and properties defined for generic collections, * the ParentalRatingCollection class supports the additional properties and * methods defined below. */ +class ParentalRatingCollection extends Collection { -var ParentalRatingCollection = Collection.extend({ - - init: function() { - this.super.init.apply(this, arguments); - }, - + constructor(...args) { + super(...args); + } + /* * Description: - * Creates a ParentalRating object instance for a given parental rating - * scheme and parental rating value, and adds it to + * Creates a ParentalRating object instance for a given parental rating + * scheme and parental rating value, and adds it to * the ParentalRatingCollection for a programme or channel. - * + * * Arguments: * - scheme A unique string identifying the parental rating scheme to which - * this value refers. See property scheme in section 7.9.4.1 for more + * this value refers. See property scheme in section 7.9.4.1 for more * information about possible values. - * + * * -name: A string representation of the parental rating value. See property - * name in section 7.9.4.1 for more information about possible values. + * name in section 7.9.4.1 for more information about possible values. * Values are not case sensitive. - * + * * -value: The parental rating value represented as an Integer. See property * value in section 7.9.4.1 for more information about possible values. - * - * -labels: A set of content rating labels that may provide additional + * + * -labels: A set of content rating labels that may provide additional * information about the rating. See property labels in section 7.9.4.1 for * more information about possible values.- region: The region to which the - * parental rating value applies as an alpha-2 region code as defined in - * ISO 3166-1. The value of this argument must be null or undefined if no + * parental rating value applies as an alpha-2 region code as defined in + * ISO 3166-1. The value of this argument must be null or undefined if no * specific region has been identified. Values are not case sensitive. */ - addParentalRating: function(scheme, name, value, labels, region) { - var newParentalRating = + addParentalRating(scheme, name, value, labels, region) { + var newParentalRating = new ParentalRating(scheme, name, value, labels, region); - + this.push(newParentalRating); } -}); - - +} Modified: oipf/lib/js/impl/model/ParentalRatingScheme.js =================================================================== --- oipf/lib/js/impl/model/ParentalRatingScheme.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/ParentalRatingScheme.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,99 +1,93 @@ -/* +/* * typedef Collection<String> ParentalRatingScheme * A ParentalRatingScheme describes a single parental rating scheme that may be - * in use for rating content, e.g. the MPAA or BBFC rating schemes. It is a - * collection of strings representing rating values, which next to - * the properties and methods defined below SHALL support the array notation - * to access the rating values in this collection. For the natively OITF - * supported parental rating systems the values SHALL be ordered by the OITF - * to allow the rating values to be compared in the manner as defined for - * property threshold for the respective parental rating system. - * Using a threshold as defined in this API may not necessarily be the proper - * way in which parental rating filtering is applied on the OITF, - * e.g. the US FCC requirements take precedence for device to be imported - * to the US. The parental rating schemes supported by a receiver MAY vary - * between deployments. See Annex K for the definition of the collection + * in use for rating content, e.g. the MPAA or BBFC rating schemes. It is a + * collection of strings representing rating values, which next to + * the properties and methods defined below SHALL support the array notation + * to access the rating values in this collection. For the natively OITF + * supported parental rating systems the values SHALL be ordered by the OITF + * to allow the rating values to be compared in the manner as defined for + * property threshold for the respective parental rating system. + * Using a threshold as defined in this API may not necessarily be the proper + * way in which parental rating filtering is applied on the OITF, + * e.g. the US FCC requirements take precedence for device to be imported + * to the US. The parental rating schemes supported by a receiver MAY vary + * between deployments. See Annex K for the definition of the collection * template. In addition to the methods and properties defined for generic - * collections, the ParentalRatingScheme class supports the additional + * collections, the ParentalRatingScheme class supports the additional * properties and methods defined below. */ -var ParentalRatingScheme = Collection.extend({ - - name: null, - - threshold: null, - +class ParentalRatingScheme extends Collection { + /* - * - * FIXME: + * FIXME: * - Yannis 15/05/2015 Initialization of property threshold must be bone, * when name unequal to "dvb-si" but i don't know with what values. */ - init: function(name, values) { + constructor(name, values) { this._iconUri = []; this.name = name; + this.threshold = null; this._additionnalProcessing(name, values); - - }, + } /* * Description: * Return the index of the rating represented by attribute ratingValue * inside the parental rating scheme string collection, or -1 if the rating * value cannot be found in the collection. - * + * * Argument: - * - ratingValue: The string representation of a parental rating value. - * See property name in section 7.9.1.1 for more information about possible + * - ratingValue: The string representation of a parental rating value. + * See property name in section 7.9.1.1 for more information about possible * values. Values are not case sensitive. */ - indexOf: function(ratingValue) { - + indexOf(ratingValue) { + for (var i = 0, li = this.length; i < li; i++) { var rating = this[i]; - + if (ratingValue == rating) { return i; } } - + return -1; - }, - + } + /* * Description: * Return the URI of the icon representing the rating at index in the rating - * scheme, or undefined if no item is present at that position. If no icon + * scheme, or undefined if no item is present at that position. If no icon * is available, this method SHALL return null. - * + * * Argument: * - index: The index of the parental rating scheme. */ - iconUri: function(index) { + iconUri(index) { return this._iconUri[index]; - }, - - _additionnalProcessing: function(name, values) { + } + + _additionnalProcessing(name, values) { switch (name) { - case "dvb-si": + case "dvb-si": break; - - default: - var ratingValues = values.split(","); - ratingValues && this._addSeveralRatingValues(ratingValues); + + default: + var ratingValues = values.split(","); + ratingValues && this._addSeveralRatingValues(ratingValues); } - }, - - _addRatingValue: function(ratingValue) { + } + + _addRatingValue(ratingValue) { this.push(ratingValue); - }, - - _addSeveralRatingValues: function(ratingValues) { + } + + _addSeveralRatingValues(ratingValues) { for (var i = 0, li = ratingValues.length; i < li; i++) { var currentRatingValue = ratingValues[i]; this.addRatingValue(currentRatingValue); } } - -}); +} Modified: oipf/lib/js/impl/model/ParentalRatingSchemeCollection.js =================================================================== --- oipf/lib/js/impl/model/ParentalRatingSchemeCollection.js 2015-06-09 15:19:17 UTC (rev 1656) +++ oipf/lib/js/impl/model/ParentalRatingSchemeCollection.js 2015-06-09 15:25:25 UTC (rev 1657) @@ -1,74 +1,76 @@ -/* +/* * typedef Collection<ParentalRatingScheme> ParentalRatingSchemeCollection - * A ParentalRatingSchemeCollection represents a collection of parental rating - * schemes, e.g. as returned by property parentalRatingSchemes of the - * "application/oipfParentalControlManager" object as defined in section 7.9.1. - * Next to the properties and methods defined below a - * ParentalRatingSchemeCollection object SHALL support the array notation to + * A ParentalRatingSchemeCollection represents a collection of parental rating + * schemes, e.g. as returned by property parentalRatingSchemes of the + * "application/oipfParentalControlManager" object as defined in section 7.9.1. + * Next to the properties and methods defined below a + * ParentalRatingSchemeCollection object SHALL support the array notation to * access the parental rating scheme objects in this collection. See Annex K for - * the definition of the collection template. In addition to the methods and - * properties defined for generic collections, - * the ParentalRatingSchemeCollection class supports the additional properties + * the definition of the collection template. In addition to the methods and + * properties defined for generic collections, + * the ParentalRatingSchemeCollection class supports the additional properties * and methods defined below. */ +class ParentalRatingSchemeCollection extends Collection { -var ParentalRatingSchemeCollection = Collection.extend({ /* * Description: - * Create a new ParentalRatingScheme object and adds it to - * the ParentalRatingSchemeCollection . Applications MAY use this method to - * register additional parental rating schemes with the platform. - * When registered, the new parental rating scheme SHALL (temporarily) be - * accessible through the parentalRatingSchemes property of the - * "application/oipfParentalControlmanager" object as defined in section - * 7.9.1. The application SHALL make sure that the values are ordered in - * such a way to allow the rating values to be compared in the manner as - * defined for the threshold property for the respective parental rating - * system. This method returns a reference to the ParentalRatingScheme - * object representing the added scheme. If the value of the name parameter + * Create a new ParentalRatingScheme object and adds it to + * the ParentalRatingSchemeCollection . Applications MAY use this method to + * register additional parental rating schemes with the platform. + * When registered, the new parental rating scheme SHALL (temporarily) be + * accessible through the parentalRatingSchemes property of the + * "application/oipfParentalControlmanager" object as defined in section + * 7.9.1. The application SHALL make sure that the values are ordered in + * such a way to allow the rating values to be compared in the manner as + * defined for the threshold property for the respective parental rating + * system. This method returns a reference to the ParentalRatingScheme + * object representing the added scheme. If the value of the name parameter * corresponds to an already-registered rating scheme, this method returns a - * reference to the existing ParentalRatingScheme object. If the newly - * defined rating scheme was not known to the OITF, the scheme MAY be - * stored persistently, and the OITF may offer a UI to set the parental - * rating blocking criteria for the newly added parental rating scheme. - * If the OITF has successfully stored (persistently or not persistently) + * reference to the existing ParentalRatingScheme object. If the newly + * defined rating scheme was not known to the OITF, the scheme MAY be + * stored persistently, and the OITF may offer a UI to set the parental + * rating blocking criteria for the newly added parental rating scheme. + * If the OITF has successfully stored (persistently or not persistently) * the additional parental rating scheme, the method SHALL return a non-null * ParentalRatingScheme object. - * + * * Arguments: - * - name: - * A unique string identifying the parental rating scheme to which - * this value refers. See property name in section 7.9.1.1 for more + * - name: + * A unique string identifying the parental rating scheme to which + * this value refers. See property name in section 7.9.1.1 for more * information about possible values. - * - * - values: - * A comma-separated list of the possible values in the rating scheme, in - * ascending order of severity. In case the rating scheme is one of the - * [MPEG-7] rating classification schemes, this means that the list of - * parental rating values contains the values as specified by the <Name> - * elements of the <Term> elements in the order of appearance as they are + * + * - values: + * A comma-separated list of the possible values in the rating scheme, in + * ascending order of severity. In case the rating scheme is one of the + * [MPEG-7] rating classification schemes, this means that the list of + * parental rating values contains the values as specified by the <Name> + * elements of the <Term> elements in the order of appearance as they are * defined for the classification scheme, with the exception of the Internet - * Content Rating Association (ICRA) based ratings, for which the reverse - * order has to be applied. The values must be ordered in such a way to allow the rating values to be compared in the manner as defined for property threshold for the respective parental rating system. + * Content Rating Association (ICRA) based ratings, for which the reverse + * order has to be applied. The values must be ordered in such a way to allow + * the rating values to be compared in the manner as defined for property threshold for + * the respective parental rating system. */ - addParentalRatingScheme: function(name, values) { + addParentalRatingScheme(name, values) { var parentalRatingScheme = new ParentalRatingScheme(name, values); this.push(parentalRatingScheme); - }, - + } + /* * Description: - * This method returns a reference to the ParentalRatingScheme object that - * is associated with the given scheme as specified through parameter - * "name". If the value of name does not correspond to the name property of - * any of the ParentalRatingScheme objects in + * This method returns a reference to the ParentalRatingScheme object that + * is associated with the given scheme as specified through parameter + * "name". If the value of name does not correspond to the name property of + * any of the ParentalRatingScheme objects in * the ParentalRatingSchemeCollection, the method SHALL return undefined. - * + * * Arguments: * - name: * The unique name identifying a parental rating scheme. */ - getParentalRatingScheme: function(name) { + getParentalRatingScheme(name) { for (var i = 0, li = this.length; i < li; i++) { var currentParentalRatingScheme = this[i]; if (currentParentalRatingScheme.name == name) { @@ -77,6 +79,4 @@ } return undefined; } -}); - - +}