Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2012, Deutsche Forschungszentrum für Künstliche Intelligenz GmbH
* Copyright (c) 2012-2017, JSONLD-Java contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.github.jsonldjava.core;
import com.github.jsonldjava.utils.Obj;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* JsonLdUtils.
*
* @author @tristan
* @author Peter Ansell [email protected]
*/
class JsonLdUtils {
private JsonLdUtils() {
}
private static final int MAX_CONTEXT_URLS = 10;
/**
* Returns whether or not the given value is a keyword (or a keyword alias).
*
* @param key the value to check.
* @return true if the value is a keyword, false if not.
*/
static boolean isKeyword(Object key) {
return isString(key) && ("@base".equals(key) || "@context".equals(key) || "@container"
.equals(key)
|| "@default".equals(key) || "@embed".equals(key) || "@explicit".equals(key)
|| "@graph".equals(key)
|| "@id".equals(key) || "@index".equals(key) || "@language".equals(key) || "@list"
.equals(key)
|| "@omitDefault".equals(key) || "@reverse".equals(key) || "@preserve".equals(key)
|| "@set".equals(key)
|| "@type".equals(key) || "@value".equals(key) || "@vocab".equals(key));
}
@SuppressWarnings("unchecked")
private static Boolean deepCompare(Object v1, Object v2, Boolean listOrderMatters) {
if (v1 == null) {
return v2 == null;
} else if (v2 == null) {
return v1 == null;
} else if (v1 instanceof Map && v2 instanceof Map) {
final Map m1 = (Map) v1;
final Map m2 = (Map) v2;
if (m1.size() != m2.size()) {
return false;
}
for (final String key : m1.keySet()) {
if (!m2.containsKey(key)
|| !deepCompare(m1.get(key), m2.get(key), listOrderMatters)) {
return false;
}
}
return true;
} else if (v1 instanceof List && v2 instanceof List) {
final List