Package org.eclipse.epsilon.emc.plainxml
Class PlainXmlModel
- java.lang.Object
-
- org.eclipse.epsilon.eol.models.Model
-
- org.eclipse.epsilon.eol.models.CachedModel<org.w3c.dom.Element>
-
- org.eclipse.epsilon.emc.plainxml.PlainXmlModel
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,IModel
public class PlainXmlModel extends CachedModel<org.w3c.dom.Element>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<Binding>
bindings
protected java.util.ArrayList<org.w3c.dom.Element>
createdElements
protected static java.lang.String
DEFAULT_NEW_TAG_NAME
protected org.w3c.dom.Document
document
protected static java.lang.String
ELEMENT_TYPE
protected java.io.File
file
protected java.lang.String
idAttributeName
static java.lang.String
PROPERTY_FILE
static java.lang.String
PROPERTY_URI
protected java.lang.String
uri
protected java.lang.String
xml
-
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 java.util.Collection<org.w3c.dom.Element>
allContentsFromModel()
void
bind(java.lang.String sourceTag, java.lang.String sourceAttribute, java.lang.String targetTag, java.lang.String targetAttribute, boolean many)
void
collectAllElements(org.w3c.dom.Node root, java.util.Collection<org.w3c.dom.Element> elements)
org.w3c.dom.Element
createInstance(java.lang.String type, java.util.Collection<java.lang.Object> parameters)
protected org.w3c.dom.Element
createInstanceInModel(java.lang.String type)
protected boolean
deleteElementInModel(java.lang.Object instance)
Returns true iff the given instance was deleted from the model.protected void
disposeModel()
protected java.util.Collection<org.w3c.dom.Element>
getAllOfKindFromModel(java.lang.String type)
protected java.util.Collection<org.w3c.dom.Element>
getAllOfTypeFromModel(java.lang.String type)
protected java.util.Collection<java.lang.String>
getAllTypeNamesOf(java.lang.Object instance)
Returns the fully qualified names of every type to which the given object conforms.java.util.List<Binding>
getBindings()
protected java.lang.Object
getCacheKeyForType(java.lang.String type)
Returns an identity for the given type, which will be used byCachedModel
as a key for the memoization of model elements by type.org.w3c.dom.Document
getDocument()
java.lang.Object
getElementById(java.lang.String id)
java.lang.String
getElementId(java.lang.Object instance)
java.lang.Object
getEnumerationValue(java.lang.String enumeration, java.lang.String label)
java.io.File
getFile()
java.lang.String
getIdAttributeName()
org.w3c.dom.Node
getRoot()
java.lang.String
getTypeNameOf(java.lang.Object instance)
Returns a string representing the type of the instance object.java.lang.Object
getTypeOf(java.lang.Object instance)
java.lang.String
getUri()
java.lang.String
getXml()
boolean
hasType(java.lang.String type)
boolean
isInstantiable(java.lang.String type)
boolean
isLoaded()
Convenience method for determining when a model has been loaded.boolean
isModelElement(java.lang.Object instance)
Used to test whether a Java object can be contained by this model.void
load(StringProperties properties, IRelativePathResolver resolver)
protected void
loadModel()
boolean
owns(java.lang.Object instance)
Used to test whether an object is contained in this model.void
setElementId(java.lang.Object instance, java.lang.String newId)
void
setFile(java.io.File file)
void
setIdAttributeName(java.lang.String idAttributeName)
void
setRoot(org.w3c.dom.Node node)
void
setUri(java.lang.String uri)
void
setXml(java.lang.String xml)
boolean
store()
boolean
store(java.lang.String location)
boolean
tagMatches(org.w3c.dom.Element element, java.lang.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 java.lang.String idAttributeName
-
document
protected org.w3c.dom.Document document
-
uri
protected java.lang.String uri
-
file
protected java.io.File file
-
xml
protected java.lang.String xml
-
createdElements
protected java.util.ArrayList<org.w3c.dom.Element> createdElements
-
bindings
protected java.util.ArrayList<Binding> bindings
-
ELEMENT_TYPE
protected static final java.lang.String ELEMENT_TYPE
- See Also:
- Constant Field Values
-
DEFAULT_NEW_TAG_NAME
protected static final java.lang.String DEFAULT_NEW_TAG_NAME
- See Also:
- Constant Field Values
-
PROPERTY_FILE
public static final java.lang.String PROPERTY_FILE
- See Also:
- Constant Field Values
-
PROPERTY_URI
public static final java.lang.String PROPERTY_URI
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRoot
public org.w3c.dom.Node getRoot()
-
setRoot
public void setRoot(org.w3c.dom.Node node)
-
allContentsFromModel
protected java.util.Collection<org.w3c.dom.Element> allContentsFromModel()
- Specified by:
allContentsFromModel
in classCachedModel<org.w3c.dom.Element>
-
getBindings
public java.util.List<Binding> getBindings()
-
getUri
public java.lang.String getUri()
-
setUri
public void setUri(java.lang.String uri)
-
getXml
public java.lang.String getXml()
-
setXml
public void setXml(java.lang.String xml)
-
getFile
public java.io.File getFile()
-
setFile
public void setFile(java.io.File file)
-
getDocument
public org.w3c.dom.Document getDocument()
-
bind
public void bind(java.lang.String sourceTag, java.lang.String sourceAttribute, java.lang.String targetTag, java.lang.String targetAttribute, boolean many)
-
isLoaded
public boolean isLoaded()
Description copied from class:CachedModel
Convenience method for determining when a model has been loaded.- Overrides:
isLoaded
in classCachedModel<org.w3c.dom.Element>
- Returns:
- Whether the cache has been populated.
- Since:
- 1.6
-
createInstanceInModel
protected org.w3c.dom.Element createInstanceInModel(java.lang.String type) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException
- Specified by:
createInstanceInModel
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolModelElementTypeNotFoundException
EolNotInstantiableModelElementTypeException
-
createInstance
public org.w3c.dom.Element createInstance(java.lang.String type, java.util.Collection<java.lang.Object> parameters) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException
- Specified by:
createInstance
in interfaceIModel
- Overrides:
createInstance
in classModel
- Throws:
EolModelElementTypeNotFoundException
EolNotInstantiableModelElementTypeException
-
deleteElementInModel
protected boolean deleteElementInModel(java.lang.Object instance) throws EolRuntimeException
Description copied from class:CachedModel
Returns true iff the given instance was deleted from the model.- Specified by:
deleteElementInModel
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolRuntimeException
-
collectAllElements
public void collectAllElements(org.w3c.dom.Node root, java.util.Collection<org.w3c.dom.Element> elements)
-
getAllOfKindFromModel
protected java.util.Collection<org.w3c.dom.Element> getAllOfKindFromModel(java.lang.String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfKindFromModel
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolModelElementTypeNotFoundException
-
getAllOfTypeFromModel
protected java.util.Collection<org.w3c.dom.Element> getAllOfTypeFromModel(java.lang.String type) throws EolModelElementTypeNotFoundException
- Specified by:
getAllOfTypeFromModel
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolModelElementTypeNotFoundException
-
tagMatches
public boolean tagMatches(org.w3c.dom.Element element, java.lang.String name)
-
disposeModel
protected void disposeModel()
- Specified by:
disposeModel
in classCachedModel<org.w3c.dom.Element>
-
getElementById
public java.lang.Object getElementById(java.lang.String id)
-
getElementId
public java.lang.String getElementId(java.lang.Object instance)
-
setElementId
public void setElementId(java.lang.Object instance, java.lang.String newId)
-
setIdAttributeName
public void setIdAttributeName(java.lang.String idAttributeName)
-
getIdAttributeName
public java.lang.String getIdAttributeName()
-
getEnumerationValue
public java.lang.Object getEnumerationValue(java.lang.String enumeration, java.lang.String label) throws EolEnumerationValueNotFoundException
-
getTypeNameOf
public java.lang.String getTypeNameOf(java.lang.Object instance)
Description copied from interface:IModel
Returns 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 java.lang.Object getCacheKeyForType(java.lang.String type) throws EolModelElementTypeNotFoundException
Description copied from class:CachedModel
Returns an identity for the given type, which will be used byCachedModel
as a key for the memoization of model elements by type.- Specified by:
getCacheKeyForType
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolModelElementTypeNotFoundException
-
getAllTypeNamesOf
protected java.util.Collection<java.lang.String> getAllTypeNamesOf(java.lang.Object instance)
Description copied from class:CachedModel
Returns the fully qualified names of every type to which the given object conforms. The values are used by byCachedModel
for the memoization of model elements by their kind (CachedModel.getAllOfKind(String)
).- Specified by:
getAllTypeNamesOf
in classCachedModel<org.w3c.dom.Element>
-
getTypeOf
public java.lang.Object getTypeOf(java.lang.Object instance)
-
hasType
public boolean hasType(java.lang.String type)
-
isInstantiable
public boolean isInstantiable(java.lang.String type)
-
isModelElement
public boolean isModelElement(java.lang.Object instance)
Description copied from interface:IModel
Used 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:
isModelElement
in interfaceIModel
- Overrides:
isModelElement
in 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:
loadModel
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolModelLoadingException
-
load
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException
- Specified by:
load
in interfaceIModel
- Overrides:
load
in classCachedModel<org.w3c.dom.Element>
- Throws:
EolModelLoadingException
-
owns
public boolean owns(java.lang.Object instance)
Description copied from interface:IModel
Used 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(java.lang.String location)
-
store
public boolean store()
-
-