Class SpreadsheetModel
java.lang.Object
org.eclipse.epsilon.eol.models.Model
org.eclipse.epsilon.emc.spreadsheets.SpreadsheetModel
- All Implemented Interfaces:
AutoCloseable
,IModel
,ISearchableModel
- Direct Known Subclasses:
ExcelModel
This class enables spreadsheets to be viewed as models in Epsilon.
- Author:
- Martins Francis
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.epsilon.eol.models.IModel
IModel.AmbiguityCheckResult
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected List<SpreadsheetReference>
protected List<SpreadsheetWorksheet>
Fields inherited from class org.eclipse.epsilon.eol.models.Model
aliases, ENV_PREFIX, name, PROPERTY_ALIASES, PROPERTY_NAME, PROPERTY_READONLOAD, PROPERTY_READONLY, PROPERTY_STOREONDISPOSAL, propertyGetter, propertySetter, readOnLoad, storeOnDisposal
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addReference
(SpreadsheetReference reference) Associate the given reference with this spreadsheet.void
addWorksheet
(SpreadsheetWorksheet worksheet) The purpose of this method is to associate the given worksheet with this spreadsheet.This method returns all rows of all worksheets.createInstance
(String type) This method creates a blank row in the worksheet identifiable by type.createInstance
(String type, Collection<Object> parameters) This method creates a new row in the worksheet identifiable by type.createInstance
(String type, Map<String, Object> parameters) This method creates a new row in the worksheet identifiable by type.protected abstract SpreadsheetWorksheet
createWorksheet
(ISpreadsheetMetadata.SpreadsheetWorksheetMetadata worksheetMetadata) The purpose of this method is to create a worksheet.void
deleteElement
(Object instance) This method deletes the given instance (row) from the worksheet it belongs to.protected abstract void
deleteWorksheet
(SpreadsheetWorksheet worksheet) The purpose of this method is to delete the given worksheet from this spreadsheetvoid
dispose()
abstract Collection<SpreadsheetRow>
find
(Variable iterator, ModuleElement ast, IEolContext context) findOne
(Variable iterator, ModuleElement ast, IEolContext context) getAllOfKind
(String type) getAllOfType
(String type) Returns every row contained by the worksheet identifiable by the given type.getElementById
(String id) getElementId
(Object instance) getEnumerationValue
(String enumeration, String label) getReferencesBySource
(SpreadsheetWorksheet worksheet) The purpose of this method is to find all references where the given worksheet is a source i.e.getReferencesBySource
(SpreadsheetWorksheet worksheet, SpreadsheetColumn column) The purpose of this method is to find all references where the given worksheet and column is a source i.e.getReferencesByTarget
(SpreadsheetWorksheet worksheet) The purpose of this method is to find all references where the given worksheet is a target i.e.getReferencesByTarget
(SpreadsheetWorksheet worksheet, SpreadsheetColumn column) The purpose of this method is to find all references where the given worksheet and column is a target i.e.protected abstract ISpreadsheetMetadata
The purpose of this method is to return an instance of the ISpreadsheetMetadata implementation for retrieving metadata for this spreadsheet modelgetTypeNameOf
(Object instance) This method returns the name of the worksheet that the instance (row) belongs to.This method returns the worksheet that the given instance (row) belongs to.getWorksheetByType
(String type) This method returns the first worksheet of the given type as determined bySpreadsheetWorksheet.isIdentifiablyBy(String)
method.boolean
boolean
isInstantiable
(String type) boolean
isLoaded()
protected abstract boolean
void
load()
protected void
loadColumnsFromMetadata
(ISpreadsheetMetadata metadata, SpreadsheetWorksheet worksheet) protected void
The purpose of this method is to load the configuration fileprotected void
loadReferenceFromConfigurationFile
(ISpreadsheetMetadata.SpreadsheetReferenceMetadata referenceMetadata) protected abstract void
The purpose of this method is to load the spreadsheet.protected void
loadWorksheetFromConfigurationFile
(ISpreadsheetMetadata metadata, ISpreadsheetMetadata.SpreadsheetWorksheetMetadata worksheetMetadata) boolean
Used to test whether an object is contained in this model.void
setElementId
(Object instance, String newId) boolean
store()
boolean
Methods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, getAliases, getFullyQualifiedTypeNameOf, getMetamodel, getName, getPropertyGetter, getTransactionSupport, isModelElement, isOfKind, isOfType, isPropertySet, isReadOnLoad, isStoredOnDisposal, knowsAboutProperty, load, load, load, setName, setReadOnLoad, setStoredOnDisposal
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.epsilon.eol.models.IModel
checkAmbiguity, close
-
Field Details
-
worksheets
-
references
-
isLoaded
protected boolean isLoaded
-
-
Constructor Details
-
SpreadsheetModel
public SpreadsheetModel()
-
-
Method Details
-
getPropertySetter
- Specified by:
getPropertySetter
in interfaceIModel
- Overrides:
getPropertySetter
in classModel
-
getWorksheets
-
addWorksheet
The purpose of this method is to associate the given worksheet with this spreadsheet. Any worksheet that starts with SpreadsheetConstants.WSH_IGNORE_CHARS is ignored.- Parameters:
worksheet
-
-
getReferences
-
addReference
Associate the given reference with this spreadsheet.- Parameters:
reference
-
-
load
- Specified by:
load
in interfaceIModel
- Throws:
EolModelLoadingException
-
isLoaded
public boolean isLoaded()- Since:
- 1.6
-
dispose
public void dispose() -
loadSpreadsheet
The purpose of this method is to load the spreadsheet.- Throws:
Exception
-
getSpreadsheetMetadata
The purpose of this method is to return an instance of the ISpreadsheetMetadata implementation for retrieving metadata for this spreadsheet model -
loadConfigurationFile
The purpose of this method is to load the configuration file- Throws:
Exception
-
isMetadataConfigurationDefined
protected abstract boolean isMetadataConfigurationDefined()- Returns:
- true if metadata has been provided, false otherwise
-
loadWorksheetFromConfigurationFile
protected void loadWorksheetFromConfigurationFile(ISpreadsheetMetadata metadata, ISpreadsheetMetadata.SpreadsheetWorksheetMetadata worksheetMetadata) throws Exception - Throws:
Exception
-
createWorksheet
protected abstract SpreadsheetWorksheet createWorksheet(ISpreadsheetMetadata.SpreadsheetWorksheetMetadata worksheetMetadata) throws Exception The purpose of this method is to create a worksheet.- Parameters:
worksheetMetadata
-- Returns:
- newly created worksheet
- Throws:
Exception
-
loadColumnsFromMetadata
protected void loadColumnsFromMetadata(ISpreadsheetMetadata metadata, SpreadsheetWorksheet worksheet) -
loadReferenceFromConfigurationFile
protected void loadReferenceFromConfigurationFile(ISpreadsheetMetadata.SpreadsheetReferenceMetadata referenceMetadata) -
getEnumerationValue
- Specified by:
getEnumerationValue
in interfaceIModel
-
allContents
This method returns all rows of all worksheets.- Specified by:
allContents
in interfaceIModel
- Returns:
- all of the objects contained in this model.
-
getAllOfType
Returns every row contained by the worksheet identifiable by the given type.- Specified by:
getAllOfType
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
getAllOfKind
public Collection<SpreadsheetRow> getAllOfKind(String type) throws EolModelElementTypeNotFoundException - Specified by:
getAllOfKind
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
getTypeOf
This method returns the worksheet that the given instance (row) belongs to. If the instance is not a SpreadsheetRow object then null is returned. -
getTypeNameOf
This method returns the name of the worksheet that the instance (row) belongs to.- Specified by:
getTypeNameOf
in interfaceIModel
- Parameters:
instance
- The model object whose type is to be determined.- Returns:
- the name of the type of the model object, instance.
-
createInstance
This method creates a blank row in the worksheet identifiable by type. The newly created SpreadsheetRow is returned.- Specified by:
createInstance
in interfaceIModel
- Throws:
EolModelElementTypeNotFoundException
-
createInstance
public Object createInstance(String type, Collection<Object> parameters) throws EolModelElementTypeNotFoundException This method creates a new row in the worksheet identifiable by type. The given collection is expected to contain one instance of map. Every cell is assigned a value from the map in the order in which the values are returned by the collections framework. If the worksheet does not exist in the spreadsheet then an attempt is made to create it.- Specified by:
createInstance
in interfaceIModel
- Overrides:
createInstance
in classModel
- Throws:
EolModelElementTypeNotFoundException
-
createInstance
public Object createInstance(String type, Map<String, Object> parameters) throws EolModelElementTypeNotFoundExceptionThis method creates a new row in the worksheet identifiable by type. Every cell is assigned a value from the map in the order in which the values are returned by the collections framework. If the worksheet does not exist in the spreadsheet then an attempt is made to create it.- Parameters:
type
-parameters
-- Returns:
- newly created SpreadsheetRow
- Throws:
EolModelElementTypeNotFoundException
- if worksheet cannot be found
-
getElementById
- Specified by:
getElementById
in interfaceIModel
-
getElementId
- Specified by:
getElementId
in interfaceIModel
-
setElementId
- Specified by:
setElementId
in interfaceIModel
-
deleteElement
This method deletes the given instance (row) from the worksheet it belongs to.- Specified by:
deleteElement
in interfaceIModel
- Throws:
EolRuntimeException
-
owns
Description copied from interface:IModel
Used to test whether an object is contained in this model. -
hasType
-
isInstantiable
- Specified by:
isInstantiable
in interfaceIModel
-
store
-
store
public boolean store() -
getWorksheetByType
This method returns the first worksheet of the given type as determined bySpreadsheetWorksheet.isIdentifiablyBy(String)
method.- Parameters:
type
-- Returns:
- worksheet identifiable by type or null if none found
-
getReferencesBySource
The purpose of this method is to find all references where the given worksheet is a source i.e. is referencing.- Parameters:
worksheet
-- Returns:
- Set
-
getReferencesBySource
public Set<SpreadsheetReference> getReferencesBySource(SpreadsheetWorksheet worksheet, SpreadsheetColumn column) The purpose of this method is to find all references where the given worksheet and column is a source i.e. are referencing.- Parameters:
worksheet
-column
-- Returns:
- Set
-
getReferencesByTarget
The purpose of this method is to find all references where the given worksheet is a target i.e. being referenced.- Parameters:
worksheet
-- Returns:
- Set
-
getReferencesByTarget
public Set<SpreadsheetReference> getReferencesByTarget(SpreadsheetWorksheet worksheet, SpreadsheetColumn column) The purpose of this method is to find all references where the given worksheet and column is a target i.e. being referenced.- Parameters:
worksheet
-column
-- Returns:
- Set
-
findOne
public Object findOne(Variable iterator, ModuleElement ast, IEolContext context) throws EolRuntimeException - Specified by:
findOne
in interfaceISearchableModel
- Throws:
EolRuntimeException
-
find
public abstract Collection<SpreadsheetRow> find(Variable iterator, ModuleElement ast, IEolContext context) throws EolRuntimeException - Specified by:
find
in interfaceISearchableModel
- Throws:
EolRuntimeException
-
deleteWorksheet
The purpose of this method is to delete the given worksheet from this spreadsheet- Parameters:
worksheet
-
-