| @@ 1-110 (lines=110) @@ | ||
| 1 | var utils = require('../utils'), |
|
| 2 | Base = require('../Base'); |
|
| 3 | ||
| 4 | /** |
|
| 5 | * Qualifiers are used to supply additional details about a piece of data. |
|
| 6 | * |
|
| 7 | * @constructor |
|
| 8 | * @param {Object} [json] |
|
| 9 | */ |
|
| 10 | var Qualifier = function(json){ |
|
| 11 | ||
| 12 | // Protect against forgetting the new keyword when calling the constructor |
|
| 13 | if(!(this instanceof Qualifier)){ |
|
| 14 | return new Qualifier(json); |
|
| 15 | } |
|
| 16 | ||
| 17 | // If the given object is already an instance then just return it. DON'T copy it. |
|
| 18 | if(Qualifier.isInstance(json)){ |
|
| 19 | return json; |
|
| 20 | } |
|
| 21 | ||
| 22 | this.init(json); |
|
| 23 | }; |
|
| 24 | ||
| 25 | Qualifier.prototype = Object.create(Base.prototype); |
|
| 26 | ||
| 27 | Qualifier._gedxClass = Qualifier.prototype._gedxClass = 'GedcomX.Qualifier'; |
|
| 28 | ||
| 29 | Qualifier.jsonProps = [ |
|
| 30 | 'name', |
|
| 31 | 'value' |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Check whether the given object is an instance of this class. |
|
| 36 | * |
|
| 37 | * @param {Object} obj |
|
| 38 | * @returns {Boolean} |
|
| 39 | */ |
|
| 40 | Qualifier.isInstance = function(obj){ |
|
| 41 | return utils.isInstance(obj, this._gedxClass); |
|
| 42 | }; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Initialize from JSON |
|
| 46 | * |
|
| 47 | * @param {Object} |
|
| 48 | * @return {Qualifier} this |
|
| 49 | */ |
|
| 50 | Qualifier.prototype.init = function(json){ |
|
| 51 | ||
| 52 | Base.prototype.init.call(this, json); |
|
| 53 | ||
| 54 | if(json){ |
|
| 55 | this.setName(json.name); |
|
| 56 | this.setValue(json.value); |
|
| 57 | } |
|
| 58 | return this; |
|
| 59 | }; |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Get the name |
|
| 63 | * |
|
| 64 | * @returns {String} name |
|
| 65 | */ |
|
| 66 | Qualifier.prototype.getName = function(){ |
|
| 67 | return this.name; |
|
| 68 | }; |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Set the name |
|
| 72 | * |
|
| 73 | * @param {String} name |
|
| 74 | * @returns {Qualifier} This instance. |
|
| 75 | */ |
|
| 76 | Qualifier.prototype.setName = function(name){ |
|
| 77 | this.name = name; |
|
| 78 | return this; |
|
| 79 | }; |
|
| 80 | ||
| 81 | /** |
|
| 82 | * Get the value |
|
| 83 | * |
|
| 84 | * @returns {String} |
|
| 85 | */ |
|
| 86 | Qualifier.prototype.getValue = function(){ |
|
| 87 | return this.value; |
|
| 88 | }; |
|
| 89 | ||
| 90 | /** |
|
| 91 | * Set the value |
|
| 92 | * |
|
| 93 | * @param {String} value |
|
| 94 | * @returns {Qualifier} This instance. |
|
| 95 | */ |
|
| 96 | Qualifier.prototype.setValue = function(value){ |
|
| 97 | this.value = value; |
|
| 98 | return this; |
|
| 99 | }; |
|
| 100 | ||
| 101 | /** |
|
| 102 | * Export the object as JSON |
|
| 103 | * |
|
| 104 | * @return {Object} JSON object |
|
| 105 | */ |
|
| 106 | Qualifier.prototype.toJSON = function(){ |
|
| 107 | return this._toJSON(Base, Qualifier.jsonProps); |
|
| 108 | }; |
|
| 109 | ||
| 110 | module.exports = Qualifier; |
|
| @@ 1-110 (lines=110) @@ | ||
| 1 | var utils = require('../utils'), |
|
| 2 | Base = require('../Base'); |
|
| 3 | ||
| 4 | /** |
|
| 5 | * A text value in a specific language. |
|
| 6 | * |
|
| 7 | * @constructor |
|
| 8 | * @apram {Object} [json] |
|
| 9 | */ |
|
| 10 | var TextValue = function(json){ |
|
| 11 | ||
| 12 | // Protect against forgetting the new keyword when calling the constructor |
|
| 13 | if(!(this instanceof TextValue)){ |
|
| 14 | return new TextValue(json); |
|
| 15 | } |
|
| 16 | ||
| 17 | // If the given object is already an instance then just return it. DON'T copy it. |
|
| 18 | if(TextValue.isInstance(json)){ |
|
| 19 | return json; |
|
| 20 | } |
|
| 21 | ||
| 22 | this.init(json); |
|
| 23 | }; |
|
| 24 | ||
| 25 | TextValue.prototype = Object.create(Base.prototype); |
|
| 26 | ||
| 27 | TextValue._gedxClass = TextValue.prototype._gedxClass = 'GedcomX.TextValue'; |
|
| 28 | ||
| 29 | TextValue.jsonProps = [ |
|
| 30 | 'lang', |
|
| 31 | 'value' |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Check whether the given object is an instance of this class. |
|
| 36 | * |
|
| 37 | * @param {Object} obj |
|
| 38 | * @returns {Boolean} |
|
| 39 | */ |
|
| 40 | TextValue.isInstance = function(obj){ |
|
| 41 | return utils.isInstance(obj, this._gedxClass); |
|
| 42 | }; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Initialize from JSON |
|
| 46 | * |
|
| 47 | * @param {Object} |
|
| 48 | * @return {Conclusion} this |
|
| 49 | */ |
|
| 50 | TextValue.prototype.init = function(json){ |
|
| 51 | ||
| 52 | Base.prototype.init.call(this, json); |
|
| 53 | ||
| 54 | if(json){ |
|
| 55 | this.setLang(json.lang); |
|
| 56 | this.setValue(json.value); |
|
| 57 | } |
|
| 58 | return this; |
|
| 59 | }; |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Get the lang |
|
| 63 | * |
|
| 64 | * @returns {String} lang |
|
| 65 | */ |
|
| 66 | TextValue.prototype.getLang = function(){ |
|
| 67 | return this.lang; |
|
| 68 | }; |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Set the lang |
|
| 72 | * |
|
| 73 | * @param {String} lang |
|
| 74 | * @returns {TextValue} This instance |
|
| 75 | */ |
|
| 76 | TextValue.prototype.setLang = function(lang){ |
|
| 77 | this.lang = lang; |
|
| 78 | return this; |
|
| 79 | }; |
|
| 80 | ||
| 81 | /** |
|
| 82 | * Get the value |
|
| 83 | * |
|
| 84 | * @returns {String} value |
|
| 85 | */ |
|
| 86 | TextValue.prototype.getValue = function(){ |
|
| 87 | return this.value; |
|
| 88 | }; |
|
| 89 | ||
| 90 | /** |
|
| 91 | * Set the value |
|
| 92 | * |
|
| 93 | * @param {String} value |
|
| 94 | * @returns {TextValue} This instance |
|
| 95 | */ |
|
| 96 | TextValue.prototype.setValue = function(value){ |
|
| 97 | this.value = value; |
|
| 98 | return this; |
|
| 99 | }; |
|
| 100 | ||
| 101 | /** |
|
| 102 | * Export the object as JSON |
|
| 103 | * |
|
| 104 | * @return {Object} JSON object |
|
| 105 | */ |
|
| 106 | TextValue.prototype.toJSON = function(){ |
|
| 107 | return this._toJSON(Base, TextValue.jsonProps); |
|
| 108 | }; |
|
| 109 | ||
| 110 | module.exports = TextValue; |
|
| @@ 1-110 (lines=110) @@ | ||
| 1 | var utils = require('../utils'), |
|
| 2 | Base = require('../Base'); |
|
| 3 | ||
| 4 | /** |
|
| 5 | * Common attributes for all Atom entities |
|
| 6 | * |
|
| 7 | * @constructor |
|
| 8 | * @param {Object} [json] |
|
| 9 | */ |
|
| 10 | var AtomCommon = function(json){ |
|
| 11 | ||
| 12 | // Protect against forgetting the new keyword when calling the constructor |
|
| 13 | if(!(this instanceof AtomCommon)){ |
|
| 14 | return new AtomCommon(json); |
|
| 15 | } |
|
| 16 | ||
| 17 | // If the given object is already an instance then just return it. DON'T copy it. |
|
| 18 | if(AtomCommon.isInstance(json)){ |
|
| 19 | return json; |
|
| 20 | } |
|
| 21 | ||
| 22 | this.init(json); |
|
| 23 | }; |
|
| 24 | ||
| 25 | AtomCommon.prototype = Object.create(Base.prototype); |
|
| 26 | ||
| 27 | AtomCommon._gedxClass = AtomCommon.prototype._gedxClass = 'GedcomX.AtomCommon'; |
|
| 28 | ||
| 29 | AtomCommon.jsonProps = [ |
|
| 30 | 'base', |
|
| 31 | 'lang' |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Check whether the given object is an instance of this class. |
|
| 36 | * |
|
| 37 | * @param {Object} obj |
|
| 38 | * @returns {Boolean} |
|
| 39 | */ |
|
| 40 | AtomCommon.isInstance = function(obj){ |
|
| 41 | return utils.isInstance(obj, this._gedxClass); |
|
| 42 | }; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Initialize from JSON |
|
| 46 | * |
|
| 47 | * @param {Object} |
|
| 48 | * @return {AtomCommon} this |
|
| 49 | */ |
|
| 50 | AtomCommon.prototype.init = function(json){ |
|
| 51 | ||
| 52 | Base.prototype.init.call(this, json); |
|
| 53 | ||
| 54 | if(json){ |
|
| 55 | this.setBase(json.base); |
|
| 56 | this.setLang(json.lang); |
|
| 57 | } |
|
| 58 | return this; |
|
| 59 | }; |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Set the base attribute |
|
| 63 | * |
|
| 64 | * @param {String} base |
|
| 65 | * @return {AtomCommon} this |
|
| 66 | */ |
|
| 67 | AtomCommon.prototype.setBase = function(base){ |
|
| 68 | this.base = base; |
|
| 69 | return this; |
|
| 70 | }; |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Get the base |
|
| 74 | * |
|
| 75 | * @return {String} base |
|
| 76 | */ |
|
| 77 | AtomCommon.prototype.getBase = function(base){ |
|
| 78 | return this.base; |
|
| 79 | }; |
|
| 80 | ||
| 81 | /** |
|
| 82 | * Set the lang |
|
| 83 | * |
|
| 84 | * @param {String} lang |
|
| 85 | * @return {AtomCommon} this |
|
| 86 | */ |
|
| 87 | AtomCommon.prototype.setLang = function(lang){ |
|
| 88 | this.lang = lang; |
|
| 89 | return this; |
|
| 90 | }; |
|
| 91 | ||
| 92 | /** |
|
| 93 | * Get the lang |
|
| 94 | * |
|
| 95 | * @return {String} lang |
|
| 96 | */ |
|
| 97 | AtomCommon.prototype.getLang = function(lang){ |
|
| 98 | return this.lang; |
|
| 99 | }; |
|
| 100 | ||
| 101 | /** |
|
| 102 | * Export the object as JSON |
|
| 103 | * |
|
| 104 | * @return {Object} JSON object |
|
| 105 | */ |
|
| 106 | AtomCommon.prototype.toJSON = function(){ |
|
| 107 | return this._toJSON(Base, AtomCommon.jsonProps); |
|
| 108 | }; |
|
| 109 | ||
| 110 | module.exports = AtomCommon; |
|
| 111 | ||