<commit_before>/**
 * Copyright (c) 2014 <NAME>.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
*/
package org.spdx.merge;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

import org.spdx.rdfparser.InvalidSPDXAnalysisException;
import org.spdx.rdfparser.SPDXConjunctiveLicenseSet;
import org.spdx.rdfparser.SPDXDisjunctiveLicenseSet;
import org.spdx.rdfparser.SPDXDocument;
import org.spdx.rdfparser.SPDXFile;
import org.spdx.rdfparser.SPDXLicenseInfo;
import org.spdx.rdfparser.SPDXNonStandardLicense;

/**
 * Application to build HashMaps to help SPDX documents merging. Currently, it helps mapping any SPDX licenses.
 * @author <NAME>
 *
 */
/**
 * @author Gary
 *
 */
public class SpdxLicenseMapper {

	private HashMap<SPDXDocument, HashMap<SPDXLicenseInfo, SPDXLicenseInfo>> nonStdLicIdMap = 
			new HashMap<SPDXDocument, HashMap< SPDXLicenseInfo, SPDXLicenseInfo>>();
	
	/**
	 * 
	 * @param masterDoc
	 */
	public SpdxLicenseMapper(){
	}
	
	/**
	 * Creates a new non-standard license in the outputDoc and creates a mapping
	 * between the output document non-standard license and the subDoc non standard license
	 * This particular non-standard license is unique to the outputDoc document.
	 * The return variable subNonStdLicInfo is cloned from input non-standard license, but replace the license id.
	 * @param outputDoc
	 * @param subDoc
	 * @param subNonStdLicInfo
	 * @return
	 */
	public SPDXNonStandardLicense mappingNewNonStdLic(SPDXDocument outputDoc, SPDXDocument subDoc, SPDXNonStandardLicense subNonStdLicInfo){
		
		HashMap<SPDXLicenseInfo,SPDXLicenseInfo> interMap = new HashMap<SPDXLicenseInfo,SPDXLicenseInfo>();
		if(docInNonStdLicIdMap(subDoc)){
			interMap = nonStdLicIdMap.get(subDoc);
		}    
		String NewNonStdLicId = outputDoc.getNextLicenseRef();
		SPDXNonStandardLicense subCopy = (SPDXNonStandardLicense) subNonStdLicInfo.clone();
		subNonStdLicInfo.setId(NewNonStdLicId);
		interMap.put(subCopy, subNonStdLicInfo);

		nonStdLicIdMap.put(subDoc, interMap);

		return subNonStdLicInfo;
	}<commit_msg>correct the pass parameter in the constructor description <commit_after>/**
 * Copyright (c) 2014 <NAME>.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
*/
package org.spdx.merge;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

import org.spdx.rdfparser.InvalidSPDXAnalysisException;
import org.spdx.rdfparser.SPDXConjunctiveLicenseSet;
import org.spdx.rdfparser.SPDXDisjunctiveLicenseSet;
import org.spdx.rdfparser.SPDXDocument;
import org.spdx.rdfparser.SPDXFile;
import org.spdx.rdfparser.SPDXLicenseInfo;
import org.spdx.rdfparser.SPDXNonStandardLicense;

/**
 * Application to build HashMaps to help SPDX documents merging. Currently, it helps mapping any SPDX licenses.
 * @author <NAME>
 *
 */
/**
 * @author Gary
 *
 */
public class SpdxLicenseMapper {

	private HashMap<SPDXDocument, HashMap<SPDXLicenseInfo, SPDXLicenseInfo>> nonStdLicIdMap = 
			new HashMap<SPDXDocument, HashMap< SPDXLicenseInfo, SPDXLicenseInfo>>();
	
	/**
	 * 
	 */
	public SpdxLicenseMapper(){
	}
	
	/**
	 * Creates a new non-standard license in the outputDoc and creates a mapping
	 * between the output document non-standard license and the subDoc non standard license
	 * This particular non-standard license is unique to the outputDoc document.
	 * The return variable subNonStdLicInfo is cloned from input non-standard license, but replace the license id.
	 * @param outputDoc
	 * @param subDoc
	 * @param subNonStdLicInfo
	 * @return
	 */
	public SPDXNonStandardLicense mappingNewNonStdLic(SPDXDocument outputDoc, SPDXDocument subDoc, SPDXNonStandardLicense subNonStdLicInfo){
		
		HashMap<SPDXLicenseInfo,SPDXLicenseInfo> interMap = new HashMap<SPDXLicenseInfo,SPDXLicenseInfo>();
		if(docInNonStdLicIdMap(subDoc)){
			interMap = nonStdLicIdMap.get(subDoc);
		}    
		String NewNonStdLicId = outputDoc.getNextLicenseRef();
		SPDXNonStandardLicense subCopy = (SPDXNonStandardLicense) subNonStdLicInfo.clone();
		subNonStdLicInfo.setId(NewNonStdLicId);
		interMap.put(subCopy, subNonStdLicInfo);

		nonStdLicIdMap.put(subDoc, interMap);

		return subNonStdLicInfo;
	}
{'fraction_non_alphanumeric': 0.08410138248847926, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 4.686681222707423, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1548583', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1552, 'n_words': 460}