package eu.dnetlib.dlms.jdbc.ast;

/**
 * An XPathComponent is a component of an XPath. It has
 * <ul>
 * <li>an operator ('/' or '//') that divides this component from the preceeding one in an XPath</li>
 * <li>a TagExpression, holding the tag names to use for navigation</li>
 * <li>an optional Predicate which filters the objects to select</li>
 * <li>an optional axis. For more on axis check description of Axis enum.</li>
 * </ul>
 * 
 * @author alessia
 * 
 */
public class XPathComponent extends ASTNode {
	/** Operator. '/' or '//'. */
	private String operator;
	/** Holder of tag names. */
	private TagExpression tag;
	/** Simple or Binary Predicate to filter selected objects. */
	private Predicate pred;
	/** Axis string. */
	private String axis;

	/**
	 * Constructor.
	 * 
	 * @param operator
	 *            "/" or "//".
	 * @param tag
	 *            TagExpression that holds tag names
	 * @param pred
	 *            Predicate
	 * @param axis
	 *            String
	 */
	public XPathComponent(final String operator, final TagExpression tag, final Predicate pred, final String axis) {
		super();
		this.operator = operator;
		this.tag = tag;
		this.pred = pred;
		this.axis = axis;
	}

	public void setPred(final Predicate pred) {
		this.pred = pred;
	}

	public Predicate getPred() {
		return this.pred;
	}

	public void setAxis(final String axis) {
		this.axis = axis;
	}

	public String getAxis() {
		return this.axis;
	}

	@Override
	public String toString() {
		return "XPathComponent [operator=" + this.operator + ", axis=" + this.axis + ", tag=" + this.tag + ", pred=" + this.pred + "]";
	}

	public String getOperator() {
		return this.operator;
	}

	public void setOperator(final String operator) {
		this.operator = operator;
	}

	public TagExpression getTag() {
		return this.tag;
	}

	public void setTag(final TagExpression tag) {
		this.tag = tag;
	}

}
