/*
 * @(#)ObjectOperationPair.java  2.5.0  30 July 2006
 *
 * Copyright 2006
 * College of Computer and Information Science
 * Northeastern University
 * Boston, MA  02115
 *
 * The Java Power Tools software may be used for educational
 * purposes as long as this copyright notice is retained intact
 * at the top of all source files.
 *
 * To discuss possible commercial use of this software, 
 * contact Richard Rasala at Northeastern University, 
 * College of Computer and Information Science,
 * 617-373-2462 or rasala@ccs.neu.edu.
 *
 * The Java Power Tools software has been designed and built
 * in collaboration with Viera Proulx and Jeff Raab.
 *
 * Should this software be modified, the words "Modified from 
 * Original" must be included as a comment below this notice.
 *
 * All publication rights are retained.  This software or its 
 * documentation may not be published in any media either
 * in whole or in part without explicit permission.
 *
 * This software was created with support from Northeastern 
 * University and from NSF grant DUE-9950829.
 */

package edu.neu.ccs.parser;

/**
 * <p>Pair class used by <code>AbstractParser</code>
 * to store a value and an associated operation.
 * The value is viewed as the left operand of the
 * operation and the operation is viewed as pending
 * the acquisition of its right operand.<p>
 * 
 * <p>The operation may be <code>null</code> to
 * signal that no more operations have been found
 * to process in the current parsing phase.</p>
 * 
 * <p>If the operation is non-<code>null</code> and
 * can accept <code>null</code> as a left operand
 * then the value may be <code>null</code>.</p>
 * 
 * <p>As of 2.5.0, this class was extracted from the class
 * <code>AbstractParser</code> and made standalone.</p>
 *
 * @author  Richard Rasala
 * @author  Jeff Raab
 */
public class ObjectOperationPair {
    
    /** The object component of the pair. */
    private Object value = null;
    
    
    /** The operation component of the pair. */
    private Operation operation = Operation.IDENTITY;
    
    
    /**
     * <p>Constructs a default initial
     * <code>ObjectOperationPair</code>
     * whose value is <code>null</code>
     * and whose <code>Operation</code>
     * is <code>Operation.IDENTITY</code>.</p>
     * 
     * <p>Such a pair is used to start the
     * <code>parse</code> method in
     * <code>BaseParser</code>.</p>
     */
    public ObjectOperationPair() {}
    
    
    /** 
     * <p>Constructs a pair 
     * with the given value and operation.</p>
     *
     * @param v the value component
     * @param o the operation component
     */
    public ObjectOperationPair(Object v, Operation o) {
        value = v;
        operation = o;
    }
    
    
    /** Returns the value component of this pair. */
    public Object value() { return value; }
    
    
    /** Returns the operation component of this pair. */
    public Operation operation() { return operation; }
    
}

