A description of a source.

@see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#source-description|GEDCOM X JSON Spec}

@class
@extends ExtensibleData
@apram {Object} [json]
767495
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof SourceDescription)){
    return new SourceDescription(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(SourceDescription.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
973843
function get_data() {
        $data = parent::get_data();

        if ($data !== null and isset($data->description)) {
            $data->descriptionformat = $data->description['format'];
            $data->description = $data->description['text'];
        }

        return $data;
    }
1142114
private Map<String, Object> parseIncluded(JsonNode parent)
			throws IOException, IllegalAccessException, InstantiationException {
		Map<String, Object> result = new HashMap<>();

		if (parent.has(INCLUDED)) {
			// Get resources
			Map<String, Object> includedResources = getIncludedResources(parent);

			if (!includedResources.isEmpty()) {
				// Add to result
				for (String identifier : includedResources.keySet()) {
					result.put(identifier, includedResources.get(identifier));
				}

				ArrayNode includedArray = (ArrayNode) parent.get(INCLUDED);
				for (int i = 0; i < includedArray.size(); i++) {
					// Handle relationships
					JsonNode node = includedArray.get(i);
					Object resourceObject = includedResources.get(createIdentifier(node));
						if (resourceObject != null){
							handleRelationships(node, resourceObject);
						}
				}
			}
		}

		return result;
	}
749183
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof EvidenceReference)){
    return new EvidenceReference(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(GedcomX.ResourceReference.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
769980
function Description (msg, f, options) {
  this.id = ++id;
  // Static fields:
  this.message = msg;
  this.behavior = f;
  this.verbose = false;
  this.specificationIntended = undefined;
  Object.assign(this, options || {});
  // Internal (dynamic) fields:
  this.specifications = [];
  this.result = undefined;
  this.raisedException = false;
  this.exception = null;
  this.specificationAttempted = 0;
  this.specificationSuccessful = 0;
  this.expectationAttempted = 0;
  this.expectationSuccessful = 0;
  this.pass = false;
  this.log = [];
}
1150373
@Override
	public Map<String, String> toMap() {
		synchronized (this.confData){
			Map<String, String> ret = new HashMap<>(this.confData.size());
			for (Map.Entry<String, Object> entry : confData.entrySet()) {
				ret.put(entry.getKey(), entry.getValue().toString());
			}
			return ret;
		}
	}
1127022
static StructrTypeDefinition deserialize(final StructrSchemaDefinition root, final String name, final Map<String, Object> source) {

		final Map<String, StructrPropertyDefinition> deserializedProperties = new TreeMap<>();
		final Map<String, StructrMethodDefinition> deserializedMethods      = new TreeMap<>();
		final StructrTypeDefinition typeDefinition                          = StructrTypeDefinition.determineType(root, name, source);
		final Map<String, Object> properties                                = (Map)source.get(JsonSchema.KEY_PROPERTIES);
		final List<String> requiredPropertyNames                            = (List)source.get(JsonSchema.KEY_REQUIRED);
		final Map<String, Object> views                                     = (Map)source.get(JsonSchema.KEY_VIEWS);
		final Map<String, String> viewOrder                                 = (Map)source.get(JsonSchema.KEY_VIEW_ORDER);
		final Map<String, Object> methods                                   = (Map)source.get(JsonSchema.KEY_METHODS);

		if (properties != null) {

			for (final Entry<String, Object> entry : properties.entrySet()) {

				final String propertyName = entry.getKey();
				final Object value        = entry.getValue();

				if (value instanceof Map) {

					final StructrPropertyDefinition property = StructrPropertyDefinition.deserialize(typeDefinition, propertyName, (Map)value);
					if (property != null) {

						deserializedProperties.put(property.getName(), property);
						typeDefinition.getProperties().add(property);
					}

				} else {

					throw new IllegalStateException("Invalid JSON property definition for property " + propertyName + ", expected object.");
				}
			}
		}

		if (requiredPropertyNames != null) {

			for (final String requiredPropertyName : requiredPropertyNames) {

				// set required properties
				final StructrPropertyDefinition property = deserializedProperties.get(requiredPropertyName);
				if (property != null) {

					property.setRequired(true);

				} else {

					throw new IllegalStateException("Required property " + requiredPropertyName + " not defined for type " + typeDefinition.getName() + ".");
				}
			}
		}

		if (views != null) {

			for (final Entry<String, Object> entry : views.entrySet()) {

				final String viewName = entry.getKey();
				final Object value    = entry.getValue();

				if (value instanceof List) {

					final Set<String> viewProperties = new TreeSet<>((List)value);
					typeDefinition.getViews().put(viewName, viewProperties);

				} else {

					throw new IllegalStateException("View definition " + viewName + " must be of type array.");
				}
			}
		}

		if (viewOrder != null) {

			typeDefinition.getViewOrder().putAll(viewOrder);
		}

		if (methods != null) {

			for (final Entry<String, Object> entry : methods.entrySet()) {

				final String methodName = entry.getKey();
				final Object value      = entry.getValue();

				if (value instanceof Map) {

					final StructrMethodDefinition method = StructrMethodDefinition.deserialize(typeDefinition, methodName, (Map)value);
					if (method != null) {

						deserializedMethods.put(method.getName(), method);
						typeDefinition.getMethods().add(method);
					}

				} else if (value instanceof Collection) {

					// more than on method with the same name exists..
					final Collection<Map<String, Object>> methodList = (Collection)value;

					for (final Map<String, Object> map : methodList) {

						final StructrMethodDefinition method = StructrMethodDefinition.deserialize(typeDefinition, methodName, map);
						if (method != null) {

							deserializedMethods.put(method.getName(), method);
							typeDefinition.getMethods().add(method);
						}
					}

				} else {

					throw new IllegalStateException("Method definition " + methodName + " must be of type string or map.");
				}
			}
		}

		final Object isAbstractValue = source.get(JsonSchema.KEY_IS_ABSTRACT);
		if (isAbstractValue != null && Boolean.TRUE.equals(isAbstractValue)) {

			typeDefinition.setIsAbstract();
		}

		final Object isInterfaceValue = source.get(JsonSchema.KEY_IS_INTERFACE);
		if (isInterfaceValue != null && Boolean.TRUE.equals(isInterfaceValue)) {

			typeDefinition.setIsInterface();
		}

		final Object isBuiltinType = source.get(JsonSchema.KEY_IS_BUILTIN_TYPE);
		if (isBuiltinType != null && Boolean.TRUE.equals(isBuiltinType)) {

			typeDefinition.setIsBuiltinType();
		}

		final Object categoryValue = source.get(JsonSchema.KEY_CATEGORY);
		if (categoryValue != null) {

			typeDefinition.setCategory(categoryValue.toString());
		}

		return typeDefinition;
	}
318137
function() {
		let obj = {}, 
			key = null, 		// property key
			extended = false, 	// whether the is extended Mark object or legacy JSON object
			index = 0;
		
		let putText = function(text) {
			// check preceding node
			if (index > 0 && typeof obj[index-1] === 'string') {
				// merge with previous text
				obj[index-1] += text;
			} else {
				Object.defineProperty(obj, index, {value:text, writable:true, configurable:true}); // make content non-enumerable
				index++;
			}
		},
		parseContent = function() {
			while (ch) {
				if (ch === '{' || ch === '(' || ch === '[' && text[at] === '#') { // child object
					let child = (ch === '(') ? pragma(obj) : (ch === '[' ? binary(obj):object(obj));  
					Object.defineProperty(obj, index, {value:child, writable:true, configurable:true}); // make content non-enumerable
					// all 4 types: Mark object, JSON object, Mark pragma, Mark binary store reference to parent 
					child[$parent] = obj;  index++;  
				}
				else if (ch === '"' || ch === "'") { // text node
					let str = string();
					// only output non empty text
					if (str) putText(str);
				}
				else if (ch === '}') { 
					next();  obj[$length] = index;
					return;
				}
				else {
					error(UNEXPECT_CHAR + renderChar(ch));
				}
				white();
			}
			error(UNEXPECT_END);		
		};
		
		next();  white();  // skip the starting '{'
		while (ch) {
			if (ch === '}') { // end of the object
				next();  
				if (extended) { obj[$length] = index; }
				return obj;   // could be empty object
			}
			// scan the key
			if (ch === '{' || ch === '(' || ch === '[') { // child object, pragma or binary
				if (extended) {
					parseContent();  return obj;
				}
				error(UNEXPECT_CHAR + "'"+ ch +"'");
			}
			if (ch === '"' || ch === "'") { // quoted key
				var str = string();  white();
				if (ch === ':') { // property or JSON object
					key = str;
				} else {
					if (extended) { // already got type name
						// only output non-empty text
						if (str) putText(str);
						parseContent();  return obj;
					}
					else if (!key) { // at the starting of the object
						// create the object
						obj = MARK(str, null, null);
						extended = true;  // key = str;
						continue;							
					}
					else { 
						error(UNEXPECT_CHAR + renderChar(ch));
					}
				}
			}
			else { // if (ch==='_' || ch==='$' || 'a'<=ch && ch<='z' || 'A'<=ch && ch<='Z')
				// Mark unquoted key, which needs to be valid JS identifier.
				var ident = identifier();  white();
				if (ch == ':') { // property value
					key = ident;
				} else {
					if (!extended) { // start of Mark object
						obj = MARK(ident, null, null);
						extended = true;  // key = ident;
						continue;
					}
					error(UNEXPECT_CHAR + renderChar(ch));
				}
			}
			
			// key-value pair
			next(); // skip ':'
			var val = value();
			if (extended && !isNaN(key*1)) { // any numeric key is rejected for Mark object
				error("Numeric key not allowed as Mark property name");
			}
			if (obj[key] && typeof obj[key] !== 'function') {
				error("Duplicate key not allowed: " + key);
			}
			obj[key] = val;  white();
			// ',' is optional in Mark
			if (ch === ',') {
				next();  white();
			} 
		}
		error(UNEXPECT_END);
	}
577274
@JsonValue(value = false)
  @Override
  public Map<String, Object> toMap()
  {
    return ImmutableMap.of();
  }
1206993
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof SourceCitation)){
    return new SourceCitation(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(SourceCitation.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
587089
public function convertTypeDefinition(array $data = null)
    {
        if (empty($data)) {
            return null;
        }

        if (empty($data[JSONConstants::JSON_TYPE_ID])) {
            throw new CmisInvalidArgumentException('Id of type definition is empty but must not be empty!');
        }
        $typeDefinition = $this->getBindingsObjectFactory()->getTypeDefinitionByBaseTypeId(
            $data[JSONConstants::JSON_TYPE_BASE_ID] ?? '',
            $data[JSONConstants::JSON_TYPE_ID] ?? ''
        );

        $data = $this->convertTypeDefinitionSpecificData($data, $typeDefinition);

        $data[JSONConstants::JSON_TYPE_TYPE_MUTABILITY] = $this->convertTypeMutability(
            $data[JSONConstants::JSON_TYPE_TYPE_MUTABILITY] ?? null
        );

        foreach ($data[JSONConstants::JSON_TYPE_PROPERTY_DEFINITIONS] ?? [] as $propertyDefinitionData) {
            if (is_array($propertyDefinitionData)) {
                $propertyDefinition = $this->convertPropertyDefinition($propertyDefinitionData);
                if ($propertyDefinition !== null) {
                    $typeDefinition->addPropertyDefinition($propertyDefinition);
                }
            }
        }

        unset(
            $data[JSONConstants::JSON_TYPE_BASE_ID],
            $data[JSONConstants::JSON_TYPE_ID],
            $data[JSONConstants::JSON_TYPE_PROPERTY_DEFINITIONS]
        );

        $typeDefinition->populate(
            array_filter($data, function ($item) { return !empty($item); }),
            array_merge(
                array_combine(JSONConstants::getTypeKeys(), JSONConstants::getTypeKeys()),
                [
                    JSONConstants::JSON_TYPE_PARENT_ID => 'parentTypeId',
                    JSONConstants::JSON_TYPE_ALLOWED_TARGET_TYPES => 'allowedTargetTypeIds',
                    JSONConstants::JSON_TYPE_ALLOWED_SOURCE_TYPES => 'allowedSourceTypeIds',
                ]
            ),
            true
        );

        $typeDefinition->setExtensions($this->convertExtension($data, JSONConstants::getTypeKeys()));

        return $typeDefinition;
    }
637972
public function compileJson()
    {
        $report = $this->internalCompile();
        if ($report->getType() == common_report_Report::TYPE_SUCCESS) {
            // replace instances with strign identifiers
            list($item, $publicDirectory, $privateDirectory) = $report->getData();
            $report->setData([$item->getUri(), $publicDirectory->getId(), $privateDirectory->getId()]);
        }
        return $report;
    }
1366629
function() {
        var term = this.term,
            options = this.options,
            sourceType = $.type(options.source);

        // Check the cache first
        if (this.cache[term.toLowerCase()]) {
            this.source(this.cache[term.toLowerCase()]);

        // Use the response of an AJAX request
        } else if (sourceType === 'string') {
            var url = options.source,
                cache = this.cache[url];

            if (cache) {
                this.source(cache);
            } else {
                var query = options.query;
                query.term = term;

                $.getJSON(url, query, this.source.bind(this));
            }

        // Use a literal array list
        } else if (sourceType === 'array') {
            this.source(options.source);

        // Use the return of a function
        } else if (sourceType === 'function') {
            var response = options.source.call(this);

            if (response) {
                this.source(response);
            }
        } else {
            throw new Error('Invalid TypeAhead source type');
        }
    }
1315386
public function getDataForJSON($data = null)
    {
        if (is_null($data)) {
            $data = $this->getData();
        }
        $dataForJSON = parent::getDataForJSON($data);
        if (!is_null($this->atomic)) {
            $dataForJSON['@atomic'] = $this->atomic;
        }
        if (isset($this->sourceId)) {
            $dataForJSON['@sourceId'] = $this->sourceId;
            $this->sourceId = null;
        }
        return $dataForJSON;
    }
126810
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof PlaceReference)){
    return new PlaceReference(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(GedcomX.ExtensibleData.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
452141
function (source) {
            if (!Array.isArray(source)) {
                source = [source];
            }
            if (!source || !source.length) {
                throw new QueryError("No source specified for the query");
            }
            return " " + source.map(
                    function (s) {
                        return this.__tableRef(s);
                    }, this).join(this._static.COMMA_SEPARATOR);
        }
592999
@Override
	public Object parse(String source) throws Exception {
		DocumentBuilder builder = builderFactory.newDocumentBuilder();
		InputSource is = new InputSource(new StringReader(source));
		Node node = builder.parse(is).getFirstChild();
		LinkedHashMap<String, Object> map = new LinkedHashMap<>();
		return copyChildren("xml", node, map);
	}