Package org.eclipse.epsilon.emc.plainxml
Class PlainXmlModel
- java.lang.Object
-
- org.eclipse.epsilon.eol.models.Model
-
- org.eclipse.epsilon.eol.models.CachedModel<Element>
-
- org.eclipse.epsilon.emc.plainxml.PlainXmlModel
-
- All Implemented Interfaces:
AutoCloseable,IModel
public class PlainXmlModel extends CachedModel<Element>
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<Binding>bindingsprotected ArrayList<Element>createdElementsprotected static StringDEFAULT_NEW_TAG_NAMEprotected Documentdocumentprotected static StringELEMENT_TYPEprotected Filefileprotected StringidAttributeNamestatic StringPROPERTY_FILEstatic StringPROPERTY_URIprotected Stringuriprotected Stringxml-
Fields inherited from class org.eclipse.epsilon.eol.models.CachedModel
allContentsCache, kindCache, PROPERTY_CACHED, PROPERTY_CONCURRENT, typeCache
-
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 Constructor Description PlainXmlModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Collection<Element>allContentsFromModel()voidbind(String sourceTag, String sourceAttribute, String targetTag, String targetAttribute, boolean many)voidcollectAllElements(Node root, Collection<Element> elements)ElementcreateInstance(String type, Collection<Object> parameters)protected ElementcreateInstanceInModel(String type)protected booleandeleteElementInModel(Object instance)Returns true iff the given instance was deleted from the model.protected voiddisposeModel()protected Collection<Element>getAllOfKindFromModel(String type)protected Collection<Element>getAllOfTypeFromModel(String type)protected Collection<String>getAllTypeNamesOf(Object instance)Returns the fully qualified names of every type to which the given object conforms.List<Binding>getBindings()protected ObjectgetCacheKeyForType(String type)Returns an identity for the given type, which will be used byCachedModelas a key for the memoization of model elements by type.DocumentgetDocument()ObjectgetElementById(String id)StringgetElementId(Object instance)ObjectgetEnumerationValue(String enumeration, String label)FilegetFile()StringgetIdAttributeName()NodegetRoot()StringgetTypeNameOf(Object instance)Returns a string representing the type of the instance object.ObjectgetTypeOf(Object instance)StringgetUri()StringgetXml()booleanhasType(String type)booleanisInstantiable(String type)booleanisLoaded()Convenience method for determining when a model has been loaded.booleanisModelElement(Object instance)Used to test whether a Java object can be contained by this model.voidload(StringProperties properties, IRelativePathResolver resolver)protected voidloadModel()booleanowns(Object instance)Used to test whether an object is contained in this model.voidsetElementId(Object instance, String newId)voidsetFile(File file)voidsetIdAttributeName(String idAttributeName)voidsetRoot(Node node)voidsetUri(String uri)voidsetXml(String xml)booleanstore()booleanstore(String location)booleantagMatches(Element element, String name)-
Methods inherited from class org.eclipse.epsilon.eol.models.CachedModel
addToCache, allContents, clearCache, createInstance, deleteElement, dispose, getAllOfKind, getAllOfKindOrType, getAllOfType, initCaches, isCachingEnabled, isConcurrent, load, removeFromCache, setCachingEnabled, setConcurrent, wrap
-
Methods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, getAliases, getFullyQualifiedTypeNameOf, getMetamodel, getName, getPropertyGetter, getPropertySetter, getTransactionSupport, isOfKind, isOfType, isPropertySet, isReadOnLoad, isStoredOnDisposal, knowsAboutProperty, load, load, setName, setReadOnLoad, setStoredOnDisposal
-
-
-
-
Field Detail
-
idAttributeName
protected String idAttributeName
-
document
protected Document document
-
uri
protected String uri
-
file
protected File file
-
xml
protected String xml
-
ELEMENT_TYPE
protected static final String ELEMENT_TYPE
- See Also:
- Constant Field Values
-
DEFAULT_NEW_TAG_NAME
protected static final String DEFAULT_NEW_TAG_NAME
- See Also:
- Constant Field Values
-
PROPERTY_FILE
public static final String PROPERTY_FILE
- See Also:
- Constant Field Values
-
PROPERTY_URI
public static final String PROPERTY_URI
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRoot
public Node getRoot()
-
setRoot
public void setRoot(Node node)
-
allContentsFromModel
protected Collection<Element> allContentsFromModel()
- Specified by:
allContentsFromModelin classCachedModel<Element>
-
getUri
public String getUri()
-
setUri
public void setUri(String uri)
-
getXml
public String getXml()
-
setXml
public void setXml(String xml)
-
getFile
public File getFile()
-
setFile
public void setFile(File file)
-
getDocument
public Document getDocument()
-
bind
public void bind(String sourceTag, String sourceAttribute, String targetTag, String targetAttribute, boolean many)
-
isLoaded
public boolean isLoaded()
Description copied from class:CachedModelConvenience method for determining when a model has been loaded.- Overrides:
isLoadedin classCachedModel<Element>- Returns:
- Whether the cache has been populated.
- Since:
- 1.6
-
createInstanceInModel
protected Element createInstanceInModel(String type) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException
- Specified by:
createInstanceInModelin classCachedModel<Element>- Throws:
EolModelElementTypeNotFoundExceptionEolNotInstantiableModelElementTypeException
-
createInstance
public Element createInstance(String type, Collection<Object> parameters) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException
- Specified by:
createInstancein interfaceIModel- Overrides:
createInstancein classModel- Throws:
EolModelElementTypeNotFoundExceptionEolNotInstantiableModelElementTypeException
-
deleteElementInModel
protected boolean deleteElementInModel(Object instance) throws EolRuntimeException
Description copied from class:CachedModelReturns true iff the given instance was deleted from the model.- Specified by:
deleteElementInModelin classCachedModel<Element>- Throws:
EolRuntimeException
-
collectAllElements
public void collectAllElements(Node root, Collection<Element> elements)
-
getAllOfKindFromModel
protected Collection<Element> getAllOfKindFromModel(String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfKindFromModelin classCachedModel<Element>- Throws:
EolModelElementTypeNotFoundException
-
getAllOfTypeFromModel
protected Collection<Element> getAllOfTypeFromModel(String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfTypeFromModelin classCachedModel<Element>- Throws:
EolModelElementTypeNotFoundException
-
disposeModel
protected void disposeModel()
- Specified by:
disposeModelin classCachedModel<Element>
-
setIdAttributeName
public void setIdAttributeName(String idAttributeName)
-
getIdAttributeName
public String getIdAttributeName()
-
getEnumerationValue
public Object getEnumerationValue(String enumeration, String label) throws EolEnumerationValueNotFoundException
-
getTypeNameOf
public String getTypeNameOf(Object instance)
Description copied from interface:IModelReturns a string representing the type of the instance object. The value returned by this function can be passed to createInstance to instantiate another object of the same type as instance.- Parameters:
instance- The model object whose type is to be determined.- Returns:
- the name of the type of the model object, instance.
-
getCacheKeyForType
protected Object getCacheKeyForType(String type) throws EolModelElementTypeNotFoundException
Description copied from class:CachedModelReturns an identity for the given type, which will be used byCachedModelas a key for the memoization of model elements by type.- Specified by:
getCacheKeyForTypein classCachedModel<Element>- Throws:
EolModelElementTypeNotFoundException
-
getAllTypeNamesOf
protected Collection<String> getAllTypeNamesOf(Object instance)
Description copied from class:CachedModelReturns the fully qualified names of every type to which the given object conforms. The values are used by byCachedModelfor the memoization of model elements by their kind (CachedModel.getAllOfKind(String)).- Specified by:
getAllTypeNamesOfin classCachedModel<Element>
-
hasType
public boolean hasType(String type)
-
isInstantiable
public boolean isInstantiable(String type)
-
isModelElement
public boolean isModelElement(Object instance)
Description copied from interface:IModelUsed to test whether a Java object can be contained by this model. For example, EMF models can contain instances of EObject, but not instances of just Object.- Specified by:
isModelElementin interfaceIModel- Overrides:
isModelElementin classModel- Parameters:
instance- the Java object to test.- Returns:
- true if and only if instance can be contained by this model.
-
loadModel
protected void loadModel() throws EolModelLoadingException- Specified by:
loadModelin classCachedModel<Element>- Throws:
EolModelLoadingException
-
load
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException
- Specified by:
loadin interfaceIModel- Overrides:
loadin classCachedModel<Element>- Throws:
EolModelLoadingException
-
owns
public boolean owns(Object instance)
Description copied from interface:IModelUsed to test whether an object is contained in this model.- Parameters:
instance- the Java object to test.- Returns:
- true if and only if instance is contained by this model.
-
store
public boolean store(String location)
-
store
public boolean store()
-
-