artdaq_node_server  v1_00_09
 All Classes Namespaces Files Variables Pages
XMLDTDAttList.js
1 // Generated by CoffeeScript 1.9.1
2 (function() {
3  var XMLDTDAttList, create;
4 
5  create = require('lodash/create');
6 
7  module.exports = XMLDTDAttList = (function() {
8  function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
9  this.stringify = parent.stringify;
10  if (elementName == null) {
11  throw new Error("Missing DTD element name");
12  }
13  if (attributeName == null) {
14  throw new Error("Missing DTD attribute name");
15  }
16  if (!attributeType) {
17  throw new Error("Missing DTD attribute type");
18  }
19  if (!defaultValueType) {
20  throw new Error("Missing DTD attribute default");
21  }
22  if (defaultValueType.indexOf('#') !== 0) {
23  defaultValueType = '#' + defaultValueType;
24  }
25  if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
26  throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
27  }
28  if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
29  throw new Error("Default value only applies to #FIXED or #DEFAULT");
30  }
31  this.elementName = this.stringify.eleName(elementName);
32  this.attributeName = this.stringify.attName(attributeName);
33  this.attributeType = this.stringify.dtdAttType(attributeType);
34  this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
35  this.defaultValueType = defaultValueType;
36  }
37 
38  XMLDTDAttList.prototype.toString = function(options, level) {
39  var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
40  pretty = (options != null ? options.pretty : void 0) || false;
41  indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
42  offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
43  newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
44  level || (level = 0);
45  space = new Array(level + offset + 1).join(indent);
46  r = '';
47  if (pretty) {
48  r += space;
49  }
50  r += '<!ATTLIST ' + this.elementName + ' ' + this.attributeName + ' ' + this.attributeType;
51  if (this.defaultValueType !== '#DEFAULT') {
52  r += ' ' + this.defaultValueType;
53  }
54  if (this.defaultValue) {
55  r += ' "' + this.defaultValue + '"';
56  }
57  r += '>';
58  if (pretty) {
59  r += newline;
60  }
61  return r;
62  };
63 
64  return XMLDTDAttList;
65 
66  })();
67 
68 }).call(this);