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

org.evosuite.symbolic.expr.StringConstraint Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2010-2018 Gordon Fraser, Andrea Arcuri and EvoSuite
 * contributors
 *
 * This file is part of EvoSuite.
 *
 * EvoSuite is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3.0 of the License, or
 * (at your option) any later version.
 *
 * EvoSuite is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with EvoSuite. If not, see .
 */
package org.evosuite.symbolic.expr;

import org.evosuite.Properties;
import org.evosuite.symbolic.ConstraintTooLongException;
import org.evosuite.symbolic.DSEStats;
import org.evosuite.symbolic.expr.bv.IntegerConstant;
import org.evosuite.symbolic.expr.bv.StringComparison;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class StringConstraint extends Constraint {

	static Logger log = LoggerFactory.getLogger(StringConstraint.class);

	public StringConstraint(StringComparison left, Comparator comp,
			IntegerConstant right) {
		super();
		this.left = left;
		this.cmp = comp;
		this.right = right;
		if (getSize() > Properties.DSE_CONSTRAINT_LENGTH) {
			DSEStats.getInstance().reportConstraintTooLong(getSize());
			throw new ConstraintTooLongException(getSize());
		}
	}

	private final StringComparison left;
	private final Comparator cmp;
	private final IntegerConstant right;

	/**
	 * 
	 */
	private static final long serialVersionUID = -3187023627540040535L;

	@Override
	public Comparator getComparator() {
		return cmp;
	}

	@Override
	public Expression getLeftOperand() {
		return left;
	}

	@Override
	public Expression getRightOperand() {
		return right;
	}

	@Override
	public String toString() {
		return left + cmp.toString() + right;
	}

	@Override
	public Constraint negate() {
		return new StringConstraint(left, cmp.not(), right);
	}

	@Override
	public  K accept(ConstraintVisitor v, V arg) {
		return v.visit(this, arg);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy