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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReference(SpreadsheetReference reference) Associate the given reference with this spreadsheet.voidaddWorksheet(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 SpreadsheetWorksheetcreateWorksheet(ISpreadsheetMetadata.SpreadsheetWorksheetMetadata worksheetMetadata) The purpose of this method is to create a worksheet.voiddeleteElement(Object instance) This method deletes the given instance (row) from the worksheet it belongs to.protected abstract voiddeleteWorksheet(SpreadsheetWorksheet worksheet) The purpose of this method is to delete the given worksheet from this spreadsheetvoiddispose()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 ISpreadsheetMetadataThe 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.booleanbooleanisInstantiable(String type) booleanisLoaded()protected abstract booleanvoidload()protected voidloadColumnsFromMetadata(ISpreadsheetMetadata metadata, SpreadsheetWorksheet worksheet) protected voidThe purpose of this method is to load the configuration fileprotected voidloadReferenceFromConfigurationFile(ISpreadsheetMetadata.SpreadsheetReferenceMetadata referenceMetadata) protected abstract voidThe purpose of this method is to load the spreadsheet.protected voidloadWorksheetFromConfigurationFile(ISpreadsheetMetadata metadata, ISpreadsheetMetadata.SpreadsheetWorksheetMetadata worksheetMetadata) booleanUsed to test whether an object is contained in this model.voidsetElementId(Object instance, String newId) booleanstore()booleanMethods 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, setStoredOnDisposalMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getPropertySetterin interfaceIModel- Overrides:
getPropertySetterin 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:
loadin 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:
getEnumerationValuein interfaceIModel
-
allContents
This method returns all rows of all worksheets.- Specified by:
allContentsin 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:
getAllOfTypein interfaceIModel- Throws:
EolModelElementTypeNotFoundException
-
getAllOfKind
public Collection<SpreadsheetRow> getAllOfKind(String type) throws EolModelElementTypeNotFoundException - Specified by:
getAllOfKindin 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:
getTypeNameOfin 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:
createInstancein 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:
createInstancein interfaceIModel- Overrides:
createInstancein 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:
getElementByIdin interfaceIModel
-
getElementId
- Specified by:
getElementIdin interfaceIModel
-
setElementId
- Specified by:
setElementIdin interfaceIModel
-
deleteElement
This method deletes the given instance (row) from the worksheet it belongs to.- Specified by:
deleteElementin interfaceIModel- Throws:
EolRuntimeException
-
owns
Description copied from interface:IModelUsed to test whether an object is contained in this model. -
hasType
-
isInstantiable
- Specified by:
isInstantiablein 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:
findOnein interfaceISearchableModel- Throws:
EolRuntimeException
-
find
public abstract Collection<SpreadsheetRow> find(Variable iterator, ModuleElement ast, IEolContext context) throws EolRuntimeException - Specified by:
findin interfaceISearchableModel- Throws:
EolRuntimeException
-
deleteWorksheet
The purpose of this method is to delete the given worksheet from this spreadsheet- Parameters:
worksheet-
-