<commit_before>package aQute.bnd.component;

import java.util.*;

import org.osgi.service.component.annotations.*;

import aQute.lib.collections.*;
import aQute.lib.osgi.*;
import aQute.lib.osgi.Descriptors.TypeRef;
import aQute.lib.tag.*;
import aQute.libg.version.*;

/**
 * This class just holds the information for the component, implementation, and
 * service/provide elements. The {@link #prepare(Analyzer)} method will check if
 * things are ok and the {@link #getTag()} method returns a tag if the prepare
 * method returns without any errors. The class uses {@link ReferenceDef} to
 * hold the references.
 */
class ComponentDef {
	final static String				NAMESPACE_STEM	= "http://www.osgi.org/xmlns/scr";
	final List<String>				properties		= new ArrayList<String>();
	final MultiMap<String, String>	property		= new MultiMap<String, String>();
	final Map<String, ReferenceDef>	references		= new TreeMap<String, ReferenceDef>();

	Version							version			= AnnotationReader.V1_1;
	String							name;
	String							factory;
	Boolean							immediate;
	Boolean							servicefactory;
	ConfigurationPolicy				configurationPolicy;
	TypeRef							implementation;
	TypeRef							service[];
	String							activate;
	String							deactivate;
	String							modified;
	Boolean							enabled;
	String							xmlns;
	String							configurationPid;

	/**
	 * Called to prepare. If will look for any errors or inconsistencies in the
	 * setup.
	 * 
	 * @param analyzer
	 *            the analyzer to report errors and create references
	 * @throws Exception 
	 */
	void prepare(Analyzer analyzer) throws Exception {

		for (ReferenceDef ref : references.values()) {
			ref.prepare(analyzer);
			if (ref.version.compareTo(version) > 0)
				version = ref.version;
		}

		if (implementation == null) {
			analyzer.error("No Implementation defined for component " + name);
			return;
		} 

		analyzer.referTo(implementation);

		if (name == null)
			name = implementation.getFQN();

		if (service != null && service.length > 0) {
			for (TypeRef interfaceName : service)
				analyzer.referTo(interfaceName);
		} else if (servicefactory != null && servicefactory)
			analyzer.warning("The servicefactory:=true directive is set but no service is provided, ignoring it");
		
		if ( configurationPid != null)
			version = ReferenceDef.max(version,AnnotationReader.V1_2);
	}

	/**
	 * Returns a tag describing the component element.
	 * 
	 * @return a component element
	 */
	Tag getTag() {
		Tag component = new Tag("scr:component");
		if (xmlns != null)
			component.addAttribute("xmlns:scr", xmlns);
		else
			component.addAttribute("xmlns:scr", NAMESPACE_STEM + "/" + version);

		component.addAttribute("name", name);

		if (servicefactory != null)
			component.addAttribute("servicefactory", servicefactory);

		if (configurationPolicy != null)
			component.addAttribute("configuration-policy", configurationPolicy.toString()
					.toLowerCase());

		if (enabled != null)
			component.addAttribute("enabled", enabled);
<commit_msg>Big bug, missed v in namespace url<commit_after>package aQute.bnd.component;

import java.util.*;

import org.osgi.service.component.annotations.*;

import aQute.lib.collections.*;
import aQute.lib.osgi.*;
import aQute.lib.osgi.Descriptors.TypeRef;
import aQute.lib.tag.*;
import aQute.libg.version.*;

/**
 * This class just holds the information for the component, implementation, and
 * service/provide elements. The {@link #prepare(Analyzer)} method will check if
 * things are ok and the {@link #getTag()} method returns a tag if the prepare
 * method returns without any errors. The class uses {@link ReferenceDef} to
 * hold the references.
 */
class ComponentDef {
	final static String				NAMESPACE_STEM	= "http://www.osgi.org/xmlns/scr";
	final List<String>				properties		= new ArrayList<String>();
	final MultiMap<String, String>	property		= new MultiMap<String, String>();
	final Map<String, ReferenceDef>	references		= new TreeMap<String, ReferenceDef>();

	Version							version			= AnnotationReader.V1_1;
	String							name;
	String							factory;
	Boolean							immediate;
	Boolean							servicefactory;
	ConfigurationPolicy				configurationPolicy;
	TypeRef							implementation;
	TypeRef							service[];
	String							activate;
	String							deactivate;
	String							modified;
	Boolean							enabled;
	String							xmlns;
	String							configurationPid;

	/**
	 * Called to prepare. If will look for any errors or inconsistencies in the
	 * setup.
	 * 
	 * @param analyzer
	 *            the analyzer to report errors and create references
	 * @throws Exception 
	 */
	void prepare(Analyzer analyzer) throws Exception {

		for (ReferenceDef ref : references.values()) {
			ref.prepare(analyzer);
			if (ref.version.compareTo(version) > 0)
				version = ref.version;
		}

		if (implementation == null) {
			analyzer.error("No Implementation defined for component " + name);
			return;
		} 

		analyzer.referTo(implementation);

		if (name == null)
			name = implementation.getFQN();

		if (service != null && service.length > 0) {
			for (TypeRef interfaceName : service)
				analyzer.referTo(interfaceName);
		} else if (servicefactory != null && servicefactory)
			analyzer.warning("The servicefactory:=true directive is set but no service is provided, ignoring it");
		
		if ( configurationPid != null)
			version = ReferenceDef.max(version,AnnotationReader.V1_2);
	}

	/**
	 * Returns a tag describing the component element.
	 * 
	 * @return a component element
	 */
	Tag getTag() {
		Tag component = new Tag("scr:component");
		if (xmlns != null)
			component.addAttribute("xmlns:scr", xmlns);
		else
			component.addAttribute("xmlns:scr", NAMESPACE_STEM + "/v" + version);

		component.addAttribute("name", name);

		if (servicefactory != null)
			component.addAttribute("servicefactory", servicefactory);

		if (configurationPolicy != null)
			component.addAttribute("configuration-policy", configurationPolicy.toString()
					.toLowerCase());

		if (enabled != null)
			component.addAttribute("enabled", enabled);

{'fraction_non_alphanumeric': 0.11043248596896665, 'fraction_numerical': 0.0019808517662594917, 'mean_word_length': 3.700543056633049, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 12}, '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': '6984761', 'n_tokens_mistral': 2055, 'n_tokens_neox': 1734, 'n_words': 511}