baja/ord/OrdQuery.js

/**
 * @copyright 2015 Tridium, Inc. All Rights Reserved.
 * @author Gareth Johnson
 */

/**
 * Defines {@link baja.OrdQuery}.
 * @module baja/ord/OrdQuery
 */
define([ "bajaScript/sys" ],
    function (baja) {
  
  "use strict";
  
  var subclass = baja.subclass,
      BaseBajaObj = baja.BaseBajaObj;
  
  /**
   * ORD Query.
   * 
   * The base class for all `OrdQuery` Objects.
   *
   * @class
   * @alias baja.OrdQuery
   * @extends baja.BaseBajaObj
   * @private
   * @inner
   */
  var OrdQuery = function OrdQuery(obj) { 
    obj = obj || {};  
    this.$scheme = obj.scheme;
    this.$schemeName = obj.schemeName;
    this.$body = obj.body;
    this.$isHost = obj.isHost || false;
    this.$isSession = obj.isSession || false;
    
    // Override any functions
    var p;
    for (p in obj) {
      if (obj.hasOwnProperty(p) && typeof obj[p] === "function") {
        this[p] = obj[p];
      }
    }
  };
  
  subclass(OrdQuery, BaseBajaObj);
  
  /**
   * Return the ORD Scheme.
   *
   * @returns {baja.OrdScheme}
   */
  OrdQuery.prototype.getScheme = function () {
    return this.$scheme;
  };
  
  /**
   * Return the ORD Scheme name.
   *
   * @returns {String}
   */
  OrdQuery.prototype.getSchemeName = function () {
    return this.$schemeName;
  };
  
  /**
   * Return the body for the query.
   *
   * @returns {String}
   */
  OrdQuery.prototype.getBody = function () {
    return this.$body;
  };
  
  /**
   * Return a String representation of the query.
   *
   * @returns {String}
   */
  OrdQuery.prototype.toString = function () {
    return this.getSchemeName() + ":" + this.getBody();
  };
    
  /**
   * Return true if the Query is a Host.
   *
   * @returns {Boolean}
   */
  OrdQuery.prototype.isHost = function () {
    return this.$isHost;
  };
  
  /**
   * Return true if the Query is a Session.
   *
   * @returns {Boolean}
   */
  OrdQuery.prototype.isSession = function () {
    return this.$isSession;
  };
  
  /**
   * Normalize the query and return true if modified.
   *
   * @private
   *
   * @param {baja.OrdQueryList} list
   * @param {Number} index
   *
   * @returns {Boolean}
   */
  OrdQuery.prototype.normalize = function (list, index) {
    return false;
  };
  
  return OrdQuery;
});