E - the top-level ECore classR - the top-level result model classpublic abstract class ModelUtility<E extends org.eclipse.emf.ecore.EObject,R extends IModel> extends java.lang.Object implements IModelLoader<R>
setResourceInitializer(IResourceInitializer) before using this
class.IModelLoader.IModelInfoHolder<M extends IModel>, IModelLoader.LoadResult<M extends IModel>| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.Thread,java.util.Set<java.lang.String>> |
beingLoaded
Stores information about files currently being loaded in order to prevent
infinite recursions in case of errors in dependent projects.
|
private org.eclipse.xtext.Grammar |
grammar
Stores the XText grammar.
|
private com.google.inject.Injector |
injector |
private static IResourceInitializer |
resourceInitializer |
private org.eclipse.xtext.resource.XtextResourceSet |
resourceSet
Stores the XText resource set.
|
private static java.util.List<ModelUtility<?,?>> |
SCHEDULED |
| Modifier | Constructor and Description |
|---|---|
protected |
ModelUtility()
Creates an instance and causes the creation of the injector or
schedules the creation.
|
| Modifier and Type | Method and Description |
|---|---|
protected static java.lang.StringBuilder |
append(java.lang.StringBuilder builder,
java.lang.String text,
java.lang.String separator)
Appends a
text to builder and inserts separator
before if text is not empty. |
protected static java.lang.StringBuilder |
appendWithNewLine(java.lang.StringBuilder builder,
java.lang.String text)
Appends a
text to builder and inserts a new line
before if text is not empty. |
abstract java.lang.String |
getExtension()
Returns the file extension / identifier to react on.
|
protected org.eclipse.xtext.Grammar |
getGrammar()
Returns the object representation of the actual grammar (and performs a lazy
initialization of
grammar or resourceSet if required). |
protected com.google.inject.Injector |
getInjector()
Returns the injector for this language / environment.
|
protected abstract java.lang.ClassLoader |
getLanguageClassLoader()
Returns the actual class loader of the language.
|
protected abstract java.lang.String |
getLanguageName()
Returns the language name as specified in the xText configuration.
|
static IResourceInitializer |
getResourceInitializer()
Returns the actual resource initializer.
|
protected org.eclipse.xtext.resource.XtextResourceSet |
getResourceSet()
Returns the XText resource set (and performs a lazy initialization of
resourceSet if required). |
protected boolean |
handles(java.io.File location)
Returns whether this model utility class handles this type of file.
|
protected abstract void |
initializeAfterResourceInitializer()
Initializes instances which depend on
resourceInitializer. |
IModelLoader.LoadResult<R> |
load(ModelInfo<R> info,
ImportResolver<R> resolver)
Loads the related model.
|
java.util.List<ModelInfo<R>> |
obtainInfo(java.io.File file)
Obtains project info.
|
abstract java.util.List<ModelInfo<R>> |
obtainInfo(org.eclipse.emf.common.util.URI uri)
Obtains model information.
|
TranslationResult<R> |
parse(java.io.File file)
Parse an IVML model file for standalone application (without editor) with a new default import resolver.
|
TranslationResult<R> |
parse(org.eclipse.emf.common.util.URI uri)
Parse an IVML model file for standalone application (without editor) with a new default import resolver.
|
protected E |
parse(org.eclipse.emf.common.util.URI uri,
boolean unload,
MessageReceiver receiver,
java.lang.Class<E> cls)
Parses an
uri to obtain the top-level element. |
abstract TranslationResult<R> |
parse(org.eclipse.emf.common.util.URI uri,
ImportResolver<R> resolver)
Parse an IVML model file for standalone application (without editor) with a given import resolver.
|
protected org.eclipse.xtext.parser.IParseResult |
parseFragment(java.lang.String ruleName,
java.lang.String input)
Parses a grammar fragment.
|
void |
scan(java.io.File location,
IModelLoader.IModelInfoHolder<R> holder)
Scans a file for model information.
|
protected void |
setInjector(com.google.inject.Injector injector)
Defines the injector for this language / environment.
|
static void |
setResourceInitializer(IResourceInitializer initializer)
Defines the resource initializer.
|
static java.net.URI |
toNetUri(org.eclipse.emf.common.util.URI uri)
Converts an Eclipse URI to a java.net.URI.
|
private static IResourceInitializer resourceInitializer
private static final java.util.List<ModelUtility<?,?>> SCHEDULED
private java.util.Map<java.lang.Thread,java.util.Set<java.lang.String>> beingLoaded
private org.eclipse.xtext.resource.XtextResourceSet resourceSet
getResourceSet(). Therefore, do not use this attribute
directly but only through getResourceSet().private com.google.inject.Injector injector
private org.eclipse.xtext.Grammar grammar
getGrammar(). Therefore, do not use this attribute
directly but only through getGrammar().protected ModelUtility()
public static void setResourceInitializer(IResourceInitializer initializer)
initializer - the initializerprotected abstract void initializeAfterResourceInitializer()
resourceInitializer.public static IResourceInitializer getResourceInitializer()
public static final java.net.URI toNetUri(org.eclipse.emf.common.util.URI uri)
throws java.net.URISyntaxException
uri - the URI to convertjava.net.URISyntaxException - in case of URI syntax errorsprotected org.eclipse.xtext.resource.XtextResourceSet getResourceSet()
resourceSet if required).protected com.google.inject.Injector getInjector()
protected void setInjector(com.google.inject.Injector injector)
injector - the injector instancepublic TranslationResult<R> parse(java.io.File file) throws java.io.IOException
de.uni_hildesheim.sse.model.management.VarModel
so if you intend to use the management facilities in
de.uni_hildesheim.sse.model.management.VarModel let the
de.uni_hildesheim.sse.model.management.VarModel
do this job for you and do not call this method directly!file - the location of the modeljava.io.IOException - in case of IO problemspublic TranslationResult<R> parse(org.eclipse.emf.common.util.URI uri) throws java.io.IOException
de.uni_hildesheim.sse.model.management.VarModel
so if you intend to use the management facilities in
de.uni_hildesheim.sse.model.management.VarModel let the
de.uni_hildesheim.sse.model.management.VarModel
do this job for you and do not call this method directly!uri - the location of the model, e.g. via
URI.createURI("dummy:/example.ex1")java.io.IOException - in case of any I/O or URI problempublic abstract TranslationResult<R> parse(org.eclipse.emf.common.util.URI uri, ImportResolver<R> resolver) throws java.io.IOException
de.uni_hildesheim.sse.model.management.VarModel
so if you intend to use the management facilities in
de.uni_hildesheim.sse.model.management.VarModel let the
de.uni_hildesheim.sse.model.management.VarModel
do this job for you and do not call this method directly!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)java.io.IOException - in case of any I/O or URI problemprotected org.eclipse.xtext.Grammar getGrammar()
grammar or resourceSet if required).protected abstract java.lang.String getLanguageName()
protected abstract java.lang.ClassLoader getLanguageClassLoader()
protected org.eclipse.xtext.parser.IParseResult parseFragment(java.lang.String ruleName,
java.lang.String input)
ruleName - the name of the grammar ruleinput - the text to be parsedprotected static java.lang.StringBuilder append(java.lang.StringBuilder builder,
java.lang.String text,
java.lang.String separator)
text to builder and inserts separator
before if text is not empty.builder - the builder to append totext - the text to appendseparator - the separator to be consideredbuilderprotected static java.lang.StringBuilder appendWithNewLine(java.lang.StringBuilder builder,
java.lang.String text)
text to builder and inserts a new line
before if text is not empty.builder - the builder to append totext - the text to appendbuilderprotected E parse(org.eclipse.emf.common.util.URI uri, boolean unload, MessageReceiver receiver, java.lang.Class<E> cls) throws java.io.IOException
uri to obtain the top-level element.uri - the URI to readunload - unload the parsed XText resourcereceiver - the message receiver used for storing messages (may be
null)cls - the class of the resultjava.io.IOException - in case of any I/O and parsing problemsprotected boolean handles(java.io.File location)
location - the location to be consideredtrue if it handles the specified location, false elsegetExtension()public void scan(java.io.File location,
IModelLoader.IModelInfoHolder<R> holder)
IModelLoaderscan in interface IModelLoader<R extends IModel>location - the file to be scannedholder - an instance providing limited access to the model information storagepublic java.util.List<ModelInfo<R>> obtainInfo(java.io.File file) throws java.io.IOException
file - the file to read the info fromfilejava.io.IOException - in case that an I/O error happens during parsingpublic abstract java.util.List<ModelInfo<R>> obtainInfo(org.eclipse.emf.common.util.URI uri) throws java.io.IOException
uri - the URI to read the info fromurijava.io.IOException - in case that an I/O error happens during parsingpublic IModelLoader.LoadResult<R> load(ModelInfo<R> info, ImportResolver<R> resolver)
IModelLoaderload in interface IModelLoader<R extends IModel>info - the model to be loaded (as information object)resolver - the import resolver to use (or null for a new default import resolver)public abstract java.lang.String getExtension()
Copyright © 2009 - 2018 SSE. All Rights Reserved.