Skip to content

Package: EMFFormsSpreadsheetValueConverter

EMFFormsSpreadsheetValueConverter

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.spreadsheet.core.converter;
15:
16: import org.apache.poi.ss.usermodel.Cell;
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecore.EStructuralFeature;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
20: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
21:
22: /**
23: * A value converter is used to convert a value to its string representation in the spreadsheer and vice versa.
24: *
25: * @author Johannes Faltermeier
26: *
27: */
28: public interface EMFFormsSpreadsheetValueConverter {
29:
30:         /**
31:          * Constant defining that this converter can not be used to convert the value.
32:          */
33:         double NOT_APPLICABLE = Double.NaN;
34:
35:         /**
36:          * Returns whether this converter is applicable to convert the value for the given {@link VDomainModelReference
37:          * domain model reference}. The {@link EMFFormsSpreadsheetValueConverter converter} with the highest priority will
38:          * be used to convert this value. If this converter cannot convert the value this method should indicate this by
39:          * returning {@link #NOT_APPLICABLE}.
40:          *
41:          * @param domainObject the domain object
42:          * @param dmr the domain model reference for which the value is to be converted
43:          * @return the priority or {@link #NOT_APPLICABLE}
44:          */
45:         double isApplicable(EObject domainObject, VDomainModelReference dmr);
46:
47:         /**
48:          * Write the value to the {@link Cell} using the {@link EStructuralFeature} as meta information about the value.
49:          *
50:          * @param cell The Cell to write to
51:          * @param value The value to write
52:          * @param eStructuralFeature The {@link EStructuralFeature} describing the meta information of the value
53:          * @param viewModelContext The {@link ViewModelContext} to use
54:          * @throws EMFFormsConverterException Whenever the eStructuralFeature and the value don't match
55:          */
56:         void setCellValue(Cell cell, Object value, EStructuralFeature eStructuralFeature, ViewModelContext viewModelContext)
57:                 throws EMFFormsConverterException;
58:
59:         /**
60:          * Read the value of the {@link Cell} using the {@link EStructuralFeature} as meta information about the value.
61:          *
62:          * @param cell The Cell to read from
63:          * @param eStructuralFeature The {@link EStructuralFeature} describing the meta information of the value
64:          * @return The Object of de-serialized from the cell
65:          * @throws EMFFormsConverterException Whenever the eStructuralFeature and the cell value don't match
66:          */
67:         Object getCellValue(Cell cell, EStructuralFeature eStructuralFeature) throws EMFFormsConverterException;
68:
69: }