Package org.eclipse.epsilon.egl
Class EglTemplateFactory
- java.lang.Object
-
- org.eclipse.epsilon.egl.EglTemplateFactory
-
- Direct Known Subclasses:
EglFileGeneratingTemplateFactory
public class EglTemplateFactory extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected IEglContext
context
protected URI
root
-
Constructor Summary
Constructors Constructor Description EglTemplateFactory()
EglTemplateFactory(IEglContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyState(IEolContext delegate)
protected EglTemplate
createTemplate(EglTemplateSpecification spec)
Creates a template from the given specification.IEglContext
getContext()
protected IEglContext
getContextForNewTemplate()
This method should be called when creating a new template fromcreateTemplate(EglTemplateSpecification)
.IncrementalitySettings
getDefaultIncrementalitySettings()
Collection<ITemplateExecutionListener>
getTemplateExecutionListeners()
String
getTemplateRoot()
protected EglTemplate
handleFailedLoad(String name, Exception e)
boolean
initialiseRoot(URI root)
Sets the root of this template factory, unless it has already been set.EglTemplate
load(File file)
Loads an EglTemplate for the EGL code stored in the indicated file.EglTemplate
load(String path)
Loads an EglTemplate for the EGL code stored in the file at path.protected EglTemplate
load(String code, File file)
Loads an EglTemplate for the given EGL code as though it were contained in the given File.protected EglTemplate
load(String code, URI resource)
Loads an EglTemplate for the given EGL code as though it were contained in the given URI.EglTemplate
load(URI resource)
Loads an EglTemplate for the EGL code stored in the given resource.protected EglTemplate
load(EglTemplateSpecification spec)
Loads an EglTemplate from the given EglTemplateSpecification.protected String
name(String path)
EglTemplate
prepare(String code)
Prepares an EGL template that will execute the given EGL source code.protected URI
resolveRoot(String path)
URI
resolveTemplate(String path)
void
setContext(IEglContext context)
void
setDefaultFormatter(Formatter defaultFormatter)
void
setDefaultFormatters(Collection<Formatter> defaultFormatters)
void
setDefaultFormatters(Formatter... defaultFormatters)
void
setRoot(URI root)
void
setTemplateRoot(String path)
String
toString()
-
-
-
Field Detail
-
context
protected IEglContext context
-
root
protected URI root
-
-
Constructor Detail
-
EglTemplateFactory
public EglTemplateFactory()
-
EglTemplateFactory
public EglTemplateFactory(IEglContext context)
-
-
Method Detail
-
getTemplateExecutionListeners
public Collection<ITemplateExecutionListener> getTemplateExecutionListeners()
-
getDefaultIncrementalitySettings
public IncrementalitySettings getDefaultIncrementalitySettings()
-
setDefaultFormatter
public void setDefaultFormatter(Formatter defaultFormatter)
-
setDefaultFormatters
public void setDefaultFormatters(Formatter... defaultFormatters)
-
setDefaultFormatters
public void setDefaultFormatters(Collection<Formatter> defaultFormatters)
-
getContext
public IEglContext getContext()
-
setContext
public void setContext(IEglContext context)
-
initialiseRoot
public boolean initialiseRoot(URI root)
Sets the root of this template factory, unless it has already been set.- Parameters:
root
- The new root.- Returns:
true
if the root was set as a result of this call,false
if the root had already been initialized.
-
setRoot
public void setRoot(URI root)
-
getTemplateRoot
public String getTemplateRoot()
-
setTemplateRoot
public void setTemplateRoot(String path) throws EglRuntimeException
- Throws:
EglRuntimeException
-
resolveRoot
protected URI resolveRoot(String path) throws EglRuntimeException
- Throws:
EglRuntimeException
-
resolveTemplate
public URI resolveTemplate(String path) throws EglRuntimeException
- Throws:
EglRuntimeException
-
load
public EglTemplate load(File file) throws EglRuntimeException
Loads an EglTemplate for the EGL code stored in the indicated file. Subclasses should override#createTemplate(String, URI)
, rather than this method, unless they wish to alter the way in which a file is transformed into an EglTemplateSpecification- Throws:
EglRuntimeException
-
load
protected EglTemplate load(String code, File file) throws EglRuntimeException
Loads an EglTemplate for the given EGL code as though it were contained in the given File. Used for parsing "dirty" code (which has not yet been saved to disk). Subclasses should override#createTemplate(String, URI)
, rather than this method, unless they wish to alter the way in which a dirty resource is transformed into an EglTemplateSpecification- Throws:
EglRuntimeException
-
load
public EglTemplate load(String path) throws EglRuntimeException
Loads an EglTemplate for the EGL code stored in the file at path. Subclasses should override#createTemplate(String, URI)
, rather than this method, unless they wish to alter the way in which a path is transformed into an EglTemplateSpecification- Throws:
EglRuntimeException
-
load
public EglTemplate load(URI resource) throws EglRuntimeException
Loads an EglTemplate for the EGL code stored in the given resource. Subclasses should override#createTemplate(String, URI)
, rather than this method, unless they wish to alter the way in which a resource is transformed into an EglTemplateSpecification- Throws:
EglRuntimeException
-
load
protected EglTemplate load(String code, URI resource) throws EglRuntimeException
Loads an EglTemplate for the given EGL code as though it were contained in the given URI. Used for parsing "dirty" code (which has not yet been saved to disk). Subclasses should override#createTemplate(String, URI)
, rather than this method, unless they wish to alter the way in which a dirty resource is transformed into an EglTemplateSpecification- Throws:
EglRuntimeException
-
load
protected final EglTemplate load(EglTemplateSpecification spec) throws EglRuntimeException
Loads an EglTemplate from the given EglTemplateSpecification. Subclasses should override#createTemplate(String, URI)
, rather than this method, unless they wish to alter the way in which IOExceptions are handled, in which case they should overridehandleFailedLoad(String, Exception)
.- Throws:
EglRuntimeException
-
handleFailedLoad
protected EglTemplate handleFailedLoad(String name, Exception e) throws EglRuntimeException
- Throws:
EglRuntimeException
-
prepare
public final EglTemplate prepare(String code) throws Exception
Prepares an EGL template that will execute the given EGL source code. Subclasses should override#createTemplate(String)
, rather than this method, as this method may, in the future, acquire additional responsibilities, such as exception handling.- Throws:
Exception
-
createTemplate
protected EglTemplate createTemplate(EglTemplateSpecification spec) throws Exception
Creates a template from the given specification. Subclasses may override to create different types of template.- Throws:
Exception
-
copyState
public void copyState(IEolContext delegate)
-
getContextForNewTemplate
protected IEglContext getContextForNewTemplate()
This method should be called when creating a new template fromcreateTemplate(EglTemplateSpecification)
. The rationale is that in some cases this factory's context is not safe to be used directly, so a proxy or modifications may be needed instead.- Returns:
- An appropriate context to be used for a new EglTemplate instance.
- Since:
- 1.6
-
-