<commit_before>/*
 * Copyright (c) 2012 <NAME>, <NAME>
 * 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:
 * <NAME> - initial API and implementation
 */
package prm4j.indexing.realtime;

import java.util.ArrayList;
import java.util.List;

import prm4j.Util;
import prm4j.Util.Tuple;
import prm4j.api.MatchHandler0;
import prm4j.api.MatchHandler1;
import prm4j.api.MatchHandler2;
import prm4j.api.Parameter;

public class AwareMatchHandler<P1> {

    public static <P1> AwareMatchHandler0 create() {
	return new AwareMatchHandler0();
    }

    public static <P1> AwareMatchHandler1<P1> create(Parameter<P1> param1) {
	return new AwareMatchHandler1<P1>(param1);
    }

    public static <P1, P2> AwareMatchHandler2<P1, P2> create(Parameter<P1> param1, Parameter<P2> param2) {
	return new AwareMatchHandler2<P1, P2>(param1, param2);
    }

    public static class AwareMatchHandler0 extends MatchHandler0 {

	private int handledMatches = 0;

	/**
	 * Returns a count of handled matches
	 *
	 * @return
	 */
	public int getHandledMatches() {
	    return handledMatches;
	}

	@Override
	public void handleMatch(Object auxiliaryData) {
	    handledMatches++;
	}

    }

    public static class AwareMatchHandler1<P1> extends MatchHandler1<P1> {

	private final List<P1> handledMatches;

	public AwareMatchHandler1(Parameter<P1> param1) {
	    super(param1);
	    handledMatches = new ArrayList<P1>();
	}

	@Override
	public void handleMatch(P1 obj1, Object auxiliaryData) {
	    handledMatches.add(obj1);
	}

	/**
	 * Returns a list of object which participated in a detected match.
	 *
	 * @return
	 */
	public List<P1> getHandledMatches() {
	    return handledMatches;
	}

    }

    public static class AwareMatchHandler2<P1, P2> extends MatchHandler2<P1, P2> {

	private final List<Tuple<P1, P2>> handledMatches;

	public AwareMatchHandler2(Parameter<P1> param1, Parameter<P2> param2) {
	    super(param1, param2);
	    handledMatches = new ArrayList<Tuple<P1, P2>>();
	}

	@Override
	public void handleMatch(P1 obj1, P2 obj2, Object auxiliaryData) {
	    handledMatches.add(Util.tuple(obj1, obj2));
	}

	/**
	 * Returns a list of object tuples which participated in a detected match.
	 *
	 * @return
	 */
	public List<Tuple<P1, P2>> getHandledMatches() {
	    return handledMatches;
	}

    }
}<commit_msg>Let AwareMatchHandler use auxiliary data<commit_after>/*
 * Copyright (c) 2012 <NAME>, <NAME>
 * 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:
 * <NAME> - initial API and implementation
 */
package prm4j.indexing.realtime;

import java.util.ArrayList;
import java.util.List;

import prm4j.Util;
import prm4j.api.MatchHandler0;
import prm4j.api.MatchHandler1;
import prm4j.api.MatchHandler2;
import prm4j.api.Parameter;

public class AwareMatchHandler<P1> {

    public static <P1> AwareMatchHandler0 create() {
	return new AwareMatchHandler0();
    }

    public static <P1> AwareMatchHandler1<P1> create(Parameter<P1> param1) {
	return new AwareMatchHandler1<P1>(param1);
    }

    public static <P1, P2> AwareMatchHandler2<P1, P2> create(Parameter<P1> param1, Parameter<P2> param2) {
	return new AwareMatchHandler2<P1, P2>(param1, param2);
    }

    public static class AwareMatchHandler0 extends MatchHandler0 {

	private final List<Object> handledMatches;

	public AwareMatchHandler0() {
	    super();
	    handledMatches = new ArrayList<Object>();
	}

	@Override
	public void handleMatch(Object auxiliaryData) {
	    handledMatches.add(auxiliaryData);
	}

	/**
	 * Returns the list of auxiliary data (can be null) if a match was handled. The length of the list represents
	 * the number of matches.
	 *
	 * @return a list of auxiliary data
	 */
	public List<Object> getHandledMatches() {
	    return handledMatches;
	}

    }

    public static class AwareMatchHandler1<P1> extends MatchHandler1<P1> {

	private final List<Object> handledMatches;

	public AwareMatchHandler1(Parameter<P1> param1) {
	    super(param1);
	    handledMatches = new ArrayList<Object>();
	}

	@Override
	public void handleMatch(P1 obj1, Object auxiliaryData) {
	    handledMatches.add(auxiliaryData);
	}

	/**
	 * Returns the list of auxiliary data (can be null) if a match was handled. The length of the list represents
	 * the number of matches.
	 *
	 * @return a list of auxiliary data
	 */
	public List<Object> getHandledMatches() {
	    return handledMatches;
	}

    }

    public static class AwareMatchHandler2<P1, P2> extends MatchHandler2<P1, P2> {

	private final List<Object> handledMatches;

	public AwareMatchHandler2(Parameter<P1> param1, Parameter<P2> param2) {
	    super(param1, param2);
	    handledMatches = new ArrayList<Object>();
	}

	@Override
	public void handleMatch(P1 obj1, P2 obj2, Object auxiliaryData) {
	    handledMatches.add(Util.tuple(obj1, obj2));
	}

	/**
	 * Returns the list of auxiliary data (can be null) if a match was handled. The length of the list represents
	 * the number of matches.
	 *
	 * @return a list of auxiliary data
	 */
	public List<Object> getHandledMatches() {
	    return handledMatches;
	}

    }
}
{'fraction_non_alphanumeric': 0.09886902590295513, 'fraction_numerical': 0.029368843487778185, 'mean_word_length': 4.034894398530763, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, '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': '5525620', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1751, 'n_words': 501}