Class Template

    • Constructor Detail

      • Template

        Template()
        Constructor for serialization.
      • Template

        public Template​(java.lang.String name,
                        ModelImport<Template> extension,
                        TemplateDescriptor descriptor,
                        TypeRegistry registry)
                 throws VilException
        Creates a VIL template instance.
        Parameters:
        name - the name
        extension - the extended template (may be null)
        descriptor - information to create the template from
        registry - the registry responsible for this template
        Throws:
        VilException - in case of erroneous input
    • Method Detail

      • adjustParents

        protected void adjustParents()
        Adjusts the parents.
      • getJavaExtensionCount

        public int getJavaExtensionCount()
        Get the number of extensions of this template.
        Returns:
        The number of extensions of this template.
      • getJavaExtension

        public JavaExtension getJavaExtension​(int index)
        Get the extension of this template at the specified index.
        Parameters:
        index - The 0-based index of the extension to be returned.
        Returns:
        The extension at the given index.
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >=getJavaExtensionCount()
      • getName

        public java.lang.String getName()
        Description copied from interface: IModel
        Returns the name of the model element.
        Specified by:
        getName in interface IMetaType
        Specified by:
        getName in interface IModel
        Specified by:
        getName in interface IModelData
        Returns:
        the name of this model element.
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Description copied from interface: IMetaType
        Returns the qualified name of this type.
        Specified by:
        getQualifiedName in interface IMetaType
        Returns:
        the qualified name
      • getDefCount

        public int getDefCount()
        Get the number of sub-templates of this template.
        Returns:
        The number of sub-templates of this template.
      • addDef

        public void addDef​(Def def)
        Adds a sub-template.
        Parameters:
        def - the sub-template to be added
      • removeDef

        public void removeDef​(Def def)
        Adds a sub-template. (not nice)
        Parameters:
        def - the sub-template to be removed
      • getDef

        public Def getDef​(int index)
        Get the sub-templates of this template at the specified index.
        Parameters:
        index - The 0-based index of the defs to be returned.
        Returns:
        The defs at the given index.
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >=getDefCount()
      • accept

        public java.lang.Object accept​(IVisitor visitor)
                                throws VilException
        Description copied from interface: ITemplateLangElement
        Accepts the visitor for visiting.
        Specified by:
        accept in interface ITemplateLangElement
        Parameters:
        visitor - the visitor to be used
        Returns:
        the result of visiting this instance (may be null)
        Throws:
        VilException - in case that visiting fails (e.g., execution)
      • setVersion

        public void setVersion​(Version version)
        Description copied from interface: IModel
        Changes the version of this model.
        Specified by:
        setVersion in interface IModel
        Parameters:
        version - Version to set
      • getVersion

        public Version getVersion()
        Description copied from interface: IModel
        Returns the version of this model.
        Specified by:
        getVersion in interface IModel
        Specified by:
        getVersion in interface IModelData
        Returns:
        the version or null if no version is specified for this model.
      • getSuper

        public ModelImport<Template> getSuper()
        Description copied from interface: IModel
        Returns the reference to the super model (if it exists).
        Specified by:
        getSuper in interface IModel
        Returns:
        the super model (in terms of a model import/reference, may be null)
      • getOperationsCount

        public int getOperationsCount()
        Description copied from interface: IMetaType
        Returns the number of operations provided by this type.
        Specified by:
        getOperationsCount in interface IMetaType
        Returns:
        the number of operations
      • getOperation

        public IMetaOperation getOperation​(int index)
        Description copied from interface: IMetaType
        Returns the specified operation.
        Specified by:
        getOperation in interface IMetaType
        Parameters:
        index - the 0-based index of the operation to be returned
        Returns:
        the specified operation
      • isAssignableFrom

        public boolean isAssignableFrom​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type is the same or a super class of type.
        Specified by:
        isAssignableFrom in interface IMetaType
        Parameters:
        type - the descriptor to be tested
        Returns:
        true if both types are assignment compatible, false else
      • findConversion

        public IMetaOperation findConversion​(IMetaType sourceType,
                                             IMetaType targetType)
        Description copied from interface: IMetaType
        Returns the conversion operation from this type to target type (if there is any).
        Specified by:
        findConversion in interface IMetaType
        Parameters:
        sourceType - the source type to convert from
        targetType - the target type to convert to
        Returns:
        the conversion operation as defined in the underlying implementation class, null if no matching can be found
      • getIndentationConfiguration

        public IndentationConfiguration getIndentationConfiguration()
        Description copied from interface: IModel
        Returns the indentation configuration for this model. The indentation configuration is considered to be immutable.
        Specified by:
        getIndentationConfiguration in interface IModel
        Returns:
        the indentation configuration (disabled if null)
      • getFormattingConfiguration

        public FormattingConfiguration getFormattingConfiguration()
        Returns the formatting configuration of this script.
        Returns:
        the formatting configuration (may be null of there is none)
      • isBasicType

        public boolean isBasicType()
        Description copied from interface: IMetaType
        Returns whether this instance represents a basic type.
        Specified by:
        isBasicType in interface IMetaType
        Returns:
        true if this instance represents a basic type, false else
      • enableDynamicDispatch

        public boolean enableDynamicDispatch()
        Description copied from interface: IMetaType
        Returns whether this type enables dynamic dispatch of operations.
        Specified by:
        enableDynamicDispatch in interface IMetaType
        Returns:
        true if it enables dynamic dispatch, false else
      • isPlaceholder

        public boolean isPlaceholder()
        Description copied from interface: IMetaType
        Returns whether this type is valid or whether it is a placeholder type in case that the original type cannot be resolved but the script shall remain executable.
        Specified by:
        isPlaceholder in interface IMetaType
        Returns:
        true if this type is a placeholder, false else
      • addPlaceholderOperation

        public IMetaOperation addPlaceholderOperation​(java.lang.String name,
                                                      int parameterCount,
                                                      boolean acceptsNamedParameters)
        Description copied from interface: IMetaType
        Adds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.
        Specified by:
        addPlaceholderOperation in interface IMetaType
        Parameters:
        name - the name of the operation
        parameterCount - the number of parameters of the operation
        acceptsNamedParameters - whether the operation shall accept named parameters
        Returns:
        the added operation, null if this type is not a placeholder
      • isActualTypeOf

        public boolean isActualTypeOf​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type can act as an actual type of type.
        Specified by:
        isActualTypeOf in interface IMetaType
        Parameters:
        type - the type to be checked
        Returns:
        true if this type can act as an actual type of type, false else
        See Also:
        IActualTypeProvider
      • getRestrictionEvaluationContext

        public IRestrictionEvaluationContext getRestrictionEvaluationContext()
        Description copied from interface: IModel
        Returns the context for evaluating import / conflict restrictions. This context shall only contain the information that is necessary to evaluate restriction information.
        Specified by:
        getRestrictionEvaluationContext in interface IModel
        Returns:
        the evaluation context
      • getBaseType

        public IMetaType getBaseType()
        Description copied from interface: IMetaType
        Returns the base type (in case of IVML derived types).
        Specified by:
        getBaseType in interface IMetaType
        Returns:
        the base type or null
      • getFieldCount

        public int getFieldCount()
        Description copied from interface: IMetaType
        Returns the number of fields provided by this type.
        Specified by:
        getFieldCount in interface IMetaType
        Returns:
        the number of fields
      • getField

        public IMetaField getField​(int index)
        Description copied from interface: IMetaType
        Returns the specified field.
        Specified by:
        getField in interface IMetaType
        Parameters:
        index - the 0-based index of the field to be returned
        Returns:
        the specified field
      • isInternal

        public boolean isInternal()
        Description copied from interface: IMetaType
        Returns whether this type is internal and shall not be visible to the user.
        Specified by:
        isInternal in interface IMetaType
        Returns:
        true if this type is internal, false else
      • getSuperType

        public IMetaType getSuperType()
        Description copied from interface: IMetaType
        Returns the type this type is refined from.
        Specified by:
        getSuperType in interface IMetaType
        Returns:
        the super type or null if there is none
      • getGenericParameterCount

        public int getGenericParameterCount()
        Description copied from interface: IMetaType
        Returns the number of generic type parameters.
        Specified by:
        getGenericParameterCount in interface IMetaType
        Returns:
        the number of generic type parameters
      • getGenericParameterType

        public TypeDescriptor<?> getGenericParameterType​(int index)
        Description copied from interface: IMetaType
        Returns the specified generic parameter type.
        Specified by:
        getGenericParameterType in interface IMetaType
        Parameters:
        index - the index of the parameter type to return
        Returns:
        the specified parameter type
      • checkConversion

        public boolean checkConversion​(IMetaType param,
                                       IMetaOperation conversion)
        Description copied from interface: IMetaType
        Checks a conversion from this type to param via the given conversion.
        Specified by:
        checkConversion in interface IMetaType
        Parameters:
        param - the original parameter value
        conversion - the conversion function
        Returns:
        true if ok, false else
      • getCandidates

        public java.util.List<IMetaOperation> getCandidates​(java.lang.String name,
                                                            int unnamedArgsCount)
        Description copied from interface: IMetaType
        Returns operation candidates matching the given name and number of unnamed (required) arguments.
        Specified by:
        getCandidates in interface IMetaType
        Parameters:
        name - the name of the operation
        unnamedArgsCount - the number of unnamed arguments
        Returns:
        the operation candidates