/*

 * Delivered to the U.S. Government in Accordance with Contract FA8650-10-C-7080.

 *

 * EXPORT CONTROLLED

 * ECCN#   EAR99

 * Warning: This document contains technical data which is controlled under the

 * Bureau of Industry & Security's Export Administration Regulations and may not be

 * exported or re-exported without authorization by the Bureau of Industry & Security.

 * Diversion contrary to US law is prohibited.

 *

 * (c) 2011 United Technologies Corp.

 * Developed with the sponsorship of the Defense Advanced Research Projects Agency (DARPA).

 *

 * Permission is hereby granted, free of charge, to any person obtaining a copy of this data,

 * including any software or models in source or binary form, as well as any drawings, 

 * specifications, and documentation (collectively "the Data"), to deal in the Data without 

 * restriction, including without limitation the rights to use, copy, modify, merge, publish,

 * distribute, sublicense, and/or sell copies of the Data, and to permit persons to whom the Data

 * is furnished to do so, subject to the following conditions:

 * 

 * The above copyright notice and this permission notice shall be included in all copies or

 * substantial portions of the Data.

 *

 * THE DATA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING

 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND

 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, SPONSORS, DEVELOPERS, CONTRIBUTORS, OR

 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION

 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE

 * USE OR OTHER DEALINGS IN THE DATA.

*/



package aee.excel;



import org.eclipse.swt.ole.win32.OleAutomation;

import org.eclipse.swt.ole.win32.Variant;



import aee.exception.AeeException;



/**

 * Wraps a sheet's cell

 */

public class Cell extends ComAutomation {



	/**

	 * Constructor

	 * @param cell The cell automation object

	 */

	public Cell(OleAutomation cell) {

		super(cell);

	}

	

	/**

	 * Get the value of a cell

	 * @return The cell's value as a string

	 * @throws AeeException if any SWT/COM error

	 */

	public String getValue() throws AeeException {

		Variant value = null;

		try {

			value = getVariantProperty("Value");

			if (value == null)

				throw new AeeException("Unable to get a Cell value");

			String  result = value.getString();

			return result;

			

		} finally {

			if (value != null) value.dispose();

		}

	}

	

	/**

	 * Set a cell's value

	 * @param value  The value to set

	 * @throws AeeException if any SWT/COM error

	 */

	public void setValue(String value) throws AeeException {

		Variant var = null;

		try {

			var = new Variant(value);

			setProperty("Value", var);

			

		} finally {

			if (var != null) var.dispose();

		}

	}

}

