All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.semanticweb.elk.reasoner.saturation.rules.RuleVisitors Maven / Gradle / Ivy

package org.semanticweb.elk.reasoner.saturation.rules;

/*
 * #%L
 * ELK Reasoner
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2015 Department of Computer Science, University of Oxford
 * %%
 * 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.
 * #L%
 */

import org.semanticweb.elk.reasoner.saturation.rules.subsumers.SubsumerDecompositionVisitor;

/**
 * A collection of static methods for {@link RuleVisitor}s.
 * 
 * @author "Yevgeny Kazakov"
 *
 */
public class RuleVisitors {

	private static RuleVisitor LOCALITY_CHECKER_ = new RuleTracingCheckingVisitor();

	/**
	 * @param visitor
	 *            {@link RuleVisitor} to which the calls should be delegated
	 * @param 
	 *            the type of output parameter with which this visitor works
	 * @return A {@link RuleVisitor} that delegates the calls to the provided
	 *         {@link RuleVisitor} when for the {@link Rule} which accepts this
	 *         visitor, {@link Rule#isTracingRule()} returns {@code true}.
	 *         Otherwise the {@link RuleVisitor} returns {@code null}.
	 * 
	 * @see Rule#isTracingRule()
	 */
	public static  RuleVisitor getTracingVisitor(RuleVisitor visitor) {
		return new ConditionalRuleVisitor(visitor, LOCALITY_CHECKER_);
	}

	/**
	 * @param visitor
	 *            the {@link SubsumerDecompositionVisitor} to which the calls
	 *            should be delegated
	 * @param 
	 *            the type of output parameter with which this visitor works
	 * @param counter
	 *            the {@link RuleCounter} used to count the number of method
	 *            invocations
	 * @return a new {@link RuleVisitor} that delegates all methods to the given
	 *         {@link RuleVisitor} and counts the number of invocations of the
	 *         corresponding methods using the given {@link RuleCounter}.
	 */
	public static  RuleVisitor getCountingVisitor(RuleVisitor visitor,
			RuleCounter counter) {
		return new RuleCounterVisitor(visitor, counter);
	}

	/**
	 * @param visitor
	 *            the {@link SubsumerDecompositionVisitor} to which the calls
	 *            should be delegated
	 * @param 
	 *            the type of output parameter with which this visitor works
	 * @param timer
	 *            the {@link RuleApplicationTimer} used to measure the time
	 *            spent within the methods
	 * 
	 * @return a new {@link SubsumerDecompositionVisitor} that executes the
	 *         corresponding methods of the given
	 *         {@link SubsumerDecompositionVisitor} and measures the time spent
	 *         within the corresponding methods using the given
	 *         {@link RuleApplicationTimer}.
	 */
	public static  RuleVisitor getTimedVisitor(RuleVisitor visitor,
			RuleApplicationTimer timer) {
		return new RuleApplicationTimerVisitor(visitor, timer);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy