Code Duplication    Length = 110-110 lines in 3 locations

src/core/Qualifier.js 1 location

@@ 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
 * @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#qualifier|GEDCOM X JSON Spec}
8
 * 
9
 * @class
10
 * @extends Base
11
 * @param {Object} [json]
12
 */
13
var Qualifier = function(json){
14
  
15
  // Protect against forgetting the new keyword when calling the constructor
16
  if(!(this instanceof Qualifier)){
17
    return new Qualifier(json);
18
  }
19
  
20
  // If the given object is already an instance then just return it. DON'T copy it.
21
  if(Qualifier.isInstance(json)){
22
    return json;
23
  }
24
  
25
  this.init(json);
26
};
27
28
Qualifier.prototype = Object.create(Base.prototype);
29
30
Qualifier._gedxClass = Qualifier.prototype._gedxClass = 'GedcomX.Qualifier';
31
32
Qualifier.jsonProps = [
33
  'name',
34
  'value'
35
];
36
37
/**
38
 * Check whether the given object is an instance of this class.
39
 * 
40
 * @param {Object} obj
41
 * @returns {Boolean}
42
 */
43
Qualifier.isInstance = function(obj){
44
  return utils.isInstance(obj, this._gedxClass);
45
};
46
47
/**
48
 * Initialize from JSON
49
 * 
50
 * @param {Object}
51
 * @return {Qualifier} this
52
 */
53
Qualifier.prototype.init = function(json){
54
  
55
  Base.prototype.init.call(this, json);
56
  
57
  if(json){
58
    this.setName(json.name);
59
    this.setValue(json.value);
60
  }
61
  return this;
62
};
63
64
/**
65
 * Get the name
66
 * 
67
 * @returns {String} name
68
 */
69
Qualifier.prototype.getName = function(){
70
  return this.name;
71
};
72
73
/**
74
 * Set the name
75
 * 
76
 * @param {String} name
77
 * @returns {Qualifier} This instance.
78
 */
79
Qualifier.prototype.setName = function(name){
80
  this.name = name;
81
  return this;
82
};
83
84
/**
85
 * Get the value
86
 * 
87
 * @returns {String}
88
 */
89
Qualifier.prototype.getValue = function(){
90
  return this.value;
91
};
92
93
/**
94
 * Set the value
95
 * 
96
 * @param {String} value
97
 * @returns {Qualifier} This instance.
98
 */
99
Qualifier.prototype.setValue = function(value){
100
  this.value = value;
101
  return this;
102
};
103
104
/**
105
 * Export the object as JSON
106
 * 
107
 * @return {Object} JSON object
108
 */
109
Qualifier.prototype.toJSON = function(){
110
  return this._toJSON(Base, Qualifier.jsonProps);
111
};
112
113
module.exports = Qualifier;

src/core/TextValue.js 1 location

@@ 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
 * @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#text-value|GEDCOM X JSON Spec}
8
 * 
9
 * @class
10
 * @extends Base
11
 * @apram {Object} [json]
12
 */
13
var TextValue = function(json){
14
  
15
  // Protect against forgetting the new keyword when calling the constructor
16
  if(!(this instanceof TextValue)){
17
    return new TextValue(json);
18
  }
19
  
20
  // If the given object is already an instance then just return it. DON'T copy it.
21
  if(TextValue.isInstance(json)){
22
    return json;
23
  }
24
  
25
  this.init(json);
26
};
27
28
TextValue.prototype = Object.create(Base.prototype);
29
30
TextValue._gedxClass = TextValue.prototype._gedxClass = 'GedcomX.TextValue';
31
32
TextValue.jsonProps = [
33
  'lang',
34
  'value'
35
];
36
37
/**
38
 * Check whether the given object is an instance of this class.
39
 * 
40
 * @param {Object} obj
41
 * @returns {Boolean}
42
 */
43
TextValue.isInstance = function(obj){
44
  return utils.isInstance(obj, this._gedxClass);
45
};
46
47
/**
48
 * Initialize from JSON
49
 * 
50
 * @param {Object}
51
 * @return {Conclusion} this
52
 */
53
TextValue.prototype.init = function(json){
54
  
55
  Base.prototype.init.call(this, json);
56
  
57
  if(json){
58
    this.setLang(json.lang);
59
    this.setValue(json.value);
60
  }
61
  return this;
62
};
63
64
/**
65
 * Get the lang
66
 * 
67
 * @returns {String} lang
68
 */
69
TextValue.prototype.getLang = function(){
70
  return this.lang;
71
};
72
73
/**
74
 * Set the lang
75
 * 
76
 * @param {String} lang
77
 * @returns {TextValue} This instance
78
 */
79
TextValue.prototype.setLang = function(lang){
80
  this.lang = lang;
81
  return this;
82
};
83
84
/**
85
 * Get the value
86
 * 
87
 * @returns {String} value
88
 */
89
TextValue.prototype.getValue = function(){
90
  return this.value;
91
};
92
93
/**
94
 * Set the value
95
 * 
96
 * @param {String} value
97
 * @returns {TextValue} This instance
98
 */
99
TextValue.prototype.setValue = function(value){
100
  this.value = value;
101
  return this;
102
};
103
104
/**
105
 * Export the object as JSON
106
 * 
107
 * @return {Object} JSON object
108
 */
109
TextValue.prototype.toJSON = function(){
110
  return this._toJSON(Base, TextValue.jsonProps);
111
};
112
113
module.exports = TextValue;

src/atom/AtomCommon.js 1 location

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