Class Engine

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Engine
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Represents the iink runtime environment.
    • Method Detail

      • create

        @NotNull
        public static @NotNull Engine create​(byte[] certificate)
                                      throws java.lang.IllegalArgumentException
        Creates a new engine.

        Note: make sure to close the returned object.

        Parameters:
        certificate - the certificate that identifies you as a valid MyScript technology integrator.
        Returns:
        the newly created engine.
        Throws:
        java.lang.IllegalArgumentException - when the certificate is invalid.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • close

        public final void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • isClosed

        public final boolean isClosed()
        Tells whether the close() method has been called. Once an object is closed any method will throw IllegalStateException.
        Returns:
        true if this object is closed.
      • getConfiguration

        @NotNull
        public final @NotNull Configuration getConfiguration()
        Returns the configuration associated with this engine.

        Note: do not close the returned object as it is owned by the engine.

        Returns:
        the engine configuration.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
      • createPackage

        @NotNull
        public final @NotNull ContentPackage createPackage​(@NotNull
                                                           @NotNull java.io.File file)
                                                    throws java.io.IOException
        Creates a new package.

        Note: make sure to close the returned object.

        Parameters:
        file - the package file.
        Returns:
        the package.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - if a package with associated filename already exists.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalArgumentException - if a package associated with the same filename is already opened, it can be accessed via a call to openPackage().
      • createPackage

        @NotNull
        public final @NotNull ContentPackage createPackage​(@NotNull
                                                           @NotNull java.lang.String path)
                                                    throws java.io.IOException
        Creates a new package.

        Note: make sure to close the returned object.

        Parameters:
        path - the package file path.
        Returns:
        the package.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - if a package with associated filename already exists.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalArgumentException - if a package associated with the same filename is already opened, it can be accessed via a call to openPackage().
      • openPackage

        @NotNull
        public final @NotNull ContentPackage openPackage​(@NotNull
                                                         @NotNull java.io.File file)
                                                  throws java.io.IOException
        Opens the specified package using the EXISTING package open option.

        Note: make sure to close the returned object.

        Parameters:
        file - the package file.
        Returns:
        the package.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - if a package with associated filename does not exist.
        java.io.IOException - if an I/O operation fails.
      • openPackage

        @NotNull
        public final @NotNull ContentPackage openPackage​(@NotNull
                                                         @NotNull java.io.File file,
                                                         @NotNull
                                                         @NotNull PackageOpenOption openOption)
                                                  throws java.io.IOException
        Opens the specified package.

        Note: make sure to close the returned object.

        Parameters:
        file - the package file.
        openOption - the open option used to open the package file.
        Returns:
        the package.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - when openOption is EXISTING, if a package with associated filename does not exist.
        java.io.IOException - when openOption is CREATE_NEW, if a package with associated filename already exists.
        java.lang.IllegalArgumentException - when openOption is CREATE_NEW, if a package associated with the same filename is already opened.
        java.io.IOException - if an I/O operation fails.
        Since:
        1.2
      • openPackage

        @NotNull
        public final @NotNull ContentPackage openPackage​(@NotNull
                                                         @NotNull java.lang.String path)
                                                  throws java.io.IOException
        Opens the specified package using the EXISTING package open option.

        Note: make sure to close the returned object.

        Parameters:
        path - the package file path.
        Returns:
        the package.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - if a package with associated filename does not exist.
        java.io.IOException - if an I/O operation fails.
      • openPackage

        @NotNull
        public final @NotNull ContentPackage openPackage​(@NotNull
                                                         @NotNull java.lang.String path,
                                                         @NotNull
                                                         @NotNull PackageOpenOption openOption)
                                                  throws java.io.IOException
        Opens the specified package.

        Note: make sure to close the returned object.

        Parameters:
        path - the package file path.
        openOption - the open option used to open the package file.
        Returns:
        the package.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - when openOption is EXISTING, if a package with associated filename does not exist.
        java.io.IOException - when openOption is CREATE_NEW, if a package with associated filename already exists.
        java.lang.IllegalArgumentException - when openOption is CREATE_NEW, if a package associated with the same filename is already opened.
        java.io.IOException - if an I/O operation fails.
        Since:
        1.2
      • deletePackage

        public final void deletePackage​(@NotNull
                                        @NotNull java.io.File file)
                                 throws java.io.IOException,
                                        java.lang.IllegalArgumentException
        Deletes the specified package.
        Parameters:
        file - the package file.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalArgumentException - when a package associated with the same fileName is already opened.
        Since:
        1.2
      • deletePackage

        public final void deletePackage​(@NotNull
                                        @NotNull java.lang.String path)
                                 throws java.io.IOException,
                                        java.lang.IllegalArgumentException
        Deletes the specified package.
        Parameters:
        path - the package file path.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalArgumentException - when a package associated with the same fileName is already opened.
        Since:
        1.2
      • createRenderer

        @NotNull
        public final @NotNull Renderer createRenderer​(float dpiX,
                                                      float dpiY,
                                                      @Nullable
                                                      @Nullable IRenderTarget renderTarget)
        Creates a new renderer.

        Note: make sure to close the returned object.

        Parameters:
        dpiX - the physical horizontal resolution of the display in dots per inch.
        dpiY - the physical vertical resolution of the display in dots per inch.
        renderTarget - the render target.
        Returns:
        the newly created renderer.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        java.lang.IllegalArgumentException - when dpiX is not a number.
        java.lang.IllegalArgumentException - when dpiX is negative.
        java.lang.IllegalArgumentException - when dpiY is not a number.
        java.lang.IllegalArgumentException - when dpiY is negative.
      • createToolController

        @NotNull
        public final @NotNull ToolController createToolController()
        Creates a new tool controller.
        Returns:
        the newly created tool controller.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        Since:
        2.0
      • createEditor

        @NotNull
        public final @NotNull Editor createEditor​(@NotNull
                                                  @NotNull Renderer renderer)
        Creates a new editor.
        Parameters:
        renderer - the renderer to be used to display editor's content.
        Returns:
        the newly created editor, with default tool controller.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
      • createEditor

        @NotNull
        public final @NotNull Editor createEditor​(@NotNull
                                                  @NotNull Renderer renderer,
                                                  @NotNull
                                                  @NotNull ToolController toolController)
        Creates a new editor.
        Parameters:
        renderer - the renderer to be used to display editor's content.
        toolController - the tool controller to be used to manage tools.
        Returns:
        the newly created editor.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        Since:
        2.0
      • getSupportedPartTypes

        @Nullable
        public final @Nullable java.lang.String[] getSupportedPartTypes()
        Returns the set of content part types that this engine can handle.
        Returns:
        an unmodifiable set of the handled content type names.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
      • createParameterSet

        @NotNull
        public final @NotNull ParameterSet createParameterSet()
        Creates a new empty parameter set.
        Returns:
        the newly created parameter set.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
      • createRecognitionAssetsBuilder

        @NotNull
        public final @NotNull RecognitionAssetsBuilder createRecognitionAssetsBuilder()
        Creates a new RecognitionAssetsBuilder.
        Returns:
        the newly created recognition assets builder.
        Throws:
        java.lang.IllegalStateException - when this engine is closed.
        Since:
        1.2.4