Package de.uni_hildesheim.sse
Class ModelUtility
- java.lang.Object
-
- net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>
-
- de.uni_hildesheim.sse.ModelUtility
-
- All Implemented Interfaces:
IModelLoader<Project>
public class ModelUtility extends ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project> implements IModelLoader<Project>
(Entry points for) Utilities for working with the EMF model.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.basics.modelManagement.IModelLoader
IModelLoader.IModelInfoHolder<M extends IModel>, IModelLoader.LoadResult<M extends IModel>
-
-
Field Summary
Fields Modifier and Type Field Description static ModelUtilityINSTANCEprivate LogMessageReceiverlogReceiver
-
Constructor Summary
Constructors Modifier Constructor Description privateModelUtility()Prevents external creation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstraintcreateConstraint(java.lang.String text, Project project, boolean asStatement)Parses a text into a constraint in the context ofproject.ConstraintSyntaxTreecreateExpression(java.lang.String text, IModelElement parent)Parses a text into an expression in the context ofproject.TranslationResult<Project>createVarModel(de.uni_hildesheim.sse.ivml.VariabilityUnit root, java.net.URI uri, boolean registerSuccessful)Create the variability model from an EMF variability unit.java.lang.StringgetExtension()Returns the file extension / identifier to react on.protected java.lang.ClassLoadergetLanguageClassLoader()Returns the actual class loader of the language.protected java.lang.StringgetLanguageName()Returns the language name as specified in the xText configuration.protected voidinitializeAfterResourceInitializer()Initializes instances which depend onModelUtility.resourceInitializer.java.util.List<ModelInfo<Project>>obtainInfo(org.eclipse.emf.common.util.URI uri)Obtains project info.TranslationResult<Project>parse(org.eclipse.emf.common.util.URI uri, ImportResolver<Project> resolver)Parse an IVML model file for standalone application (without editor) with a given import resolver.
Note: This method is called byde.uni_hildesheim.sse.model.management.VarModelso if you intend to use the management facilities inde.uni_hildesheim.sse.model.management.VarModellet thede.uni_hildesheim.sse.model.management.VarModeldo this job for you and do not call this method directly!voidprint(TranslationResult<Project> result, java.io.Writer out, boolean emitComments, boolean emitImports)Prints the var model stored in the result to the console output stream (for debugging).static java.lang.StringstringValue(de.uni_hildesheim.sse.ivml.DerivedType type, boolean forSearch)Returns the string representation oftype.static java.lang.StringstringValue(de.uni_hildesheim.sse.ivml.Type type)Returns the string representation oftype(no search).static java.lang.StringstringValue(de.uni_hildesheim.sse.ivml.Type type, boolean forSearch)Returns the string representation oftype.-
Methods inherited from class net.ssehub.easy.dslCore.ModelUtility
append, appendWithNewLine, getGrammar, getInjector, getResourceInitializer, getResourceSet, handles, load, obtainInfo, parse, parse, parse, parseFragment, scan, setInjector, setResourceInitializer, toNetUri
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.basics.modelManagement.IModelLoader
load, scan
-
-
-
-
Field Detail
-
INSTANCE
public static final ModelUtility INSTANCE
-
logReceiver
private final LogMessageReceiver logReceiver
-
-
Method Detail
-
initializeAfterResourceInitializer
protected void initializeAfterResourceInitializer()
Description copied from class:ModelUtilityInitializes instances which depend onModelUtility.resourceInitializer.- Specified by:
initializeAfterResourceInitializerin classModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>
-
getLanguageName
protected java.lang.String getLanguageName()
Description copied from class:ModelUtilityReturns the language name as specified in the xText configuration. This name can be found as URL in the grammar file or corresponds to the Java path of the grammar-XMI file in src-gen.- Specified by:
getLanguageNamein classModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>- Returns:
- the language name in Java package notation
-
getLanguageClassLoader
protected java.lang.ClassLoader getLanguageClassLoader()
Description copied from class:ModelUtilityReturns the actual class loader of the language. This loader may be different due to different bundles.- Specified by:
getLanguageClassLoaderin classModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>- Returns:
- the class loader
-
createVarModel
public TranslationResult<Project> createVarModel(de.uni_hildesheim.sse.ivml.VariabilityUnit root, java.net.URI uri, boolean registerSuccessful)
Create the variability model from an EMF variability unit.- Parameters:
root- the root-level variability unituri- the URI of the project to resolve (in order to find the closest project, may be null)registerSuccessful- successfully created models shall be registered- Returns:
- the created variability model including messages
-
print
public void print(TranslationResult<Project> result, java.io.Writer out, boolean emitComments, boolean emitImports)
Prints the var model stored in the result to the console output stream (for debugging).- Parameters:
result- the result instanceout- the output writeremitComments- whether comments shall be emittedemitImports- whether imports shall be emitted
-
parse
public TranslationResult<Project> parse(org.eclipse.emf.common.util.URI uri, ImportResolver<Project> resolver) throws java.io.IOException
Description copied from class:ModelUtilityParse an IVML model file for standalone application (without editor) with a given import resolver.
Note: This method is called byde.uni_hildesheim.sse.model.management.VarModelso if you intend to use the management facilities inde.uni_hildesheim.sse.model.management.VarModellet thede.uni_hildesheim.sse.model.management.VarModeldo this job for you and do not call this method directly!- Specified by:
parsein classModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>- Parameters:
uri- the location of the model, e.g. via URI.createURI("dummy:/example.ex1")resolver- the import resolver (may be null for a new default import resolver)- Returns:
- the created variability model including messages
- Throws:
java.io.IOException- in case of any I/O or URI problem
-
obtainInfo
public java.util.List<ModelInfo<Project>> obtainInfo(org.eclipse.emf.common.util.URI uri) throws java.io.IOException
Obtains project info.- Specified by:
obtainInfoin classModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>- Parameters:
uri- the URI to read the info from- Returns:
- the project info instances related to
uri - Throws:
java.io.IOException- in case that an I/O error happens during parsing
-
stringValue
public static final java.lang.String stringValue(de.uni_hildesheim.sse.ivml.Type type)
Returns the string representation oftype(no search).- Parameters:
type- the type to be converted into a string- Returns:
- the type representation
-
stringValue
public static final java.lang.String stringValue(de.uni_hildesheim.sse.ivml.Type type, boolean forSearch)Returns the string representation oftype.- Parameters:
type- the type to be converted into a stringforSearch- is the result intended for type searching- Returns:
- the type representation
-
stringValue
public static final java.lang.String stringValue(de.uni_hildesheim.sse.ivml.DerivedType type, boolean forSearch)Returns the string representation oftype.- Parameters:
type- the type to be converted into a stringforSearch- is the result intended for type searching- Returns:
- the type representation
-
createConstraint
public Constraint createConstraint(java.lang.String text, Project project, boolean asStatement) throws CSTSemanticException, ConstraintSyntaxException
Parses a text into a constraint in the context ofproject. Project is not modified!- Parameters:
text- the text to be parsed containing the constraintproject- the projectasStatement-truethen parsetextas a statement, else as an expression- Returns:
- the constraint, null in case of internal instantiation errors
- Throws:
CSTSemanticException- in case of semantic problems intextConstraintSyntaxException- in case of syntax problems intext
-
createExpression
public ConstraintSyntaxTree createExpression(java.lang.String text, IModelElement parent) throws CSTSemanticException, ConstraintSyntaxException
Parses a text into an expression in the context ofproject. Project is not modified!- Parameters:
text- the text to be parsed containing the constraintparent- the intended parent model element (turned intoCompoundorProjectdepending on nesting- Returns:
- the expression, null in case of internal instantiation errors
- Throws:
CSTSemanticException- in case of semantic problems intextConstraintSyntaxException- in case of syntax problems intext
-
getExtension
public java.lang.String getExtension()
Description copied from class:ModelUtilityReturns the file extension / identifier to react on.- Specified by:
getExtensionin classModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,Project>- Returns:
- the extension
-
-