<commit_before>/*******************************************************************************
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
/*
 * Created on Dec 29, 2004
 */
package org.eclipse.mylar.internal.context.core;

import java.util.*;

import org.eclipse.mylar.context.core.IDegreeOfInterest;
import org.eclipse.mylar.context.core.IMylarContext;
import org.eclipse.mylar.context.core.IMylarElement;
import org.eclipse.mylar.core.MylarStatusHandler;

/**
 * @author <NAME>
 */
public class CompositeContextElement implements IMylarElement {

	private Set<MylarContextElement> nodes = null;

	private String handle = "<no handle>";

	public CompositeContextElement(String handle, Set<MylarContextElement> nodes) {
		this.nodes = nodes;
		this.handle = handle;
	}

	/**
	 * @return the taskscape with the hightest value TODO: is this always best?
	 */
	public IMylarContext getContext() {
		IMylarElement highestValueNode = null;
		for (IMylarElement node : nodes) {
			if (highestValueNode == null || node.getInterest().getValue() < highestValueNode.getInterest().getValue())
				highestValueNode = node;
		}
		if (highestValueNode != null) {
			return highestValueNode.getContext();
		} else {
			return null;
		}
	}

	public IDegreeOfInterest getInterest() {
		CompositeDegreeOfInterest degreeOfInterest = new CompositeDegreeOfInterest();
		for (IMylarElement node : nodes) {
			degreeOfInterest.getComposedDegreesOfInterest().add(node.getInterest());
		}
		return degreeOfInterest;
	}
<commit_msg>RESOLVED - bug 130452: [performance] refactor CompositeContextElement to cache CompositeDegreeOfInterest https://bugs.eclipse.org/bugs/show_bug.cgi?id=130452<commit_after>/*******************************************************************************
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
/*
 * Created on Dec 29, 2004
 */
package org.eclipse.mylar.internal.context.core;

import java.util.*;

import org.eclipse.mylar.context.core.IDegreeOfInterest;
import org.eclipse.mylar.context.core.IMylarContext;
import org.eclipse.mylar.context.core.IMylarElement;
import org.eclipse.mylar.core.MylarStatusHandler;

/**
 * @author <NAME>
 */
public class CompositeContextElement implements IMylarElement {

	private Set<MylarContextElement> nodes = null;

	private String handle = "<no handle>";

	public CompositeContextElement(String handle, Set<MylarContextElement> nodes) {
		this.nodes = nodes;
		this.handle = handle;
	}

	/**
	 * @return the taskscape with the hightest value TODO: is this always best?
	 */
	public IMylarContext getContext() {
		IMylarElement highestValueNode = null;
		for (IMylarElement node : nodes) {
			if (highestValueNode == null || node.getInterest().getValue() < highestValueNode.getInterest().getValue())
				highestValueNode = node;
		}
		if (highestValueNode != null) {
			return highestValueNode.getContext();
		} else {
			return null;
		}
	}

	public IDegreeOfInterest getInterest() {
		if (nodes.size() == 1) {
			return nodes.iterator().next().getInterest();
		} else {
			CompositeDegreeOfInterest degreeOfInterest = new CompositeDegreeOfInterest();
			for (IMylarElement node : nodes) {
				degreeOfInterest.getComposedDegreesOfInterest().add(node.getInterest());
			}
			return degreeOfInterest;
		}
	}

{'fraction_non_alphanumeric': 0.1718900675024108, 'fraction_numerical': 0.011812921890067503, 'mean_word_length': 4.927142857142857, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '146048', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1135, 'n_words': 301}