Class WindowsApiRun

java.lang.Object
net.codecrete.windowsapi.WindowsApiRun

public class WindowsApiRun extends Object
A single run to generate Java source code for accessing the Windows API.

To generate code, create an instance of this class, set the configuration arguments and call generateCode().

The generated source code uses the Java Foreign Function and Memory API (FFM) and requires Java 23 or higher.

See Also:
  • Constructor Details

    • WindowsApiRun

      public WindowsApiRun()
      Creates a new instance.
  • Method Details

    • getOutputDirectory

      public Path getOutputDirectory()
      Gets the directory for generating the source code.

      The specified directory is the root directory for packages and subpackages.

      Returns:
      the directory
    • setOutputDirectory

      public void setOutputDirectory(Path outputDirectory)
      Sets the directory for generating the source code.

      The specified directory is the root directory for packages and subpackages.

      Parameters:
      outputDirectory - the directory
    • getBasePackage

      public String getBasePackage()
      Gets the base package for the generated code.

      The generated code will have package names starting with this base package. The Windows API data structures and functions are assigned to packages such as windows.win32.ui.windowsandmessaging. The base package is prepended. The default is an empty string, i.e., no additional package name.

      Returns:
      the base package name
    • setBasePackage

      public void setBasePackage(String basePackage)
      Sets the base package for the generated code.

      The generated code will have package names starting with this base package. The Windows API data structures and functions are assigned to packages such as windows.win32.ui.windowsandmessaging. The base package is prepended. A valid package name looks like com.company.product. The default is an empty string, i.e., no additional package name.

      Parameters:
      basePackage - base package name
    • getStructs

      public Set<String> getStructs()
      Gets the names of the C struct and union types to generate.
      Returns:
      struct/union names
    • setStructs

      public void setStructs(Set<String> structs)
      Sets the names of the C struct and union types to generate.
      Parameters:
      structs - the struct/union names
    • getFunctions

      public Set<String> getFunctions()
      Gets the names of the Windows API functions to generate.
      Returns:
      the function names
    • setFunctions

      public void setFunctions(Set<String> functions)
      Sets the names of the Windows API functions to generate.

      Note that if an ANSI and Unicode version of a function exists, the exact version must be specified. ANSI versions usually end with the uppercase A while Unicode versions end in the uppercase W.

      Parameters:
      functions - the function names
    • getEnumerations

      public Set<String> getEnumerations()
      Gets the names of the enumerations to generate.
      Returns:
      the enumeration names
    • setEnumerations

      public void setEnumerations(Set<String> enumerations)
      Sets the names of the enumerations to generate.
      Parameters:
      enumerations - the enumeration names
    • getCallbackFunctions

      public Set<String> getCallbackFunctions()
      Gets the names of the callback functions (function pointers) to generate.
      Returns:
      the callback function names
    • setCallbackFunctions

      public void setCallbackFunctions(Set<String> callbackFunctions)
      Sets the names of the callback functions (function pointers) to generate.
      Parameters:
      callbackFunctions - the callback function names
    • getComInterfaces

      public Set<String> getComInterfaces()
      Gets the names of the COM interfaces to generate.
      Returns:
      the COM interface names
    • setComInterfaces

      public void setComInterfaces(Set<String> comInterfaces)
      Sets the names of the COM interfaces to generate.
      Parameters:
      comInterfaces - the COM interface names
    • getConstants

      public Set<String> getConstants()
      Gets the names of the constants to generate.
      Returns:
      the constant names
    • setConstants

      public void setConstants(Set<String> constants)
      Sets the names of the constants to generate.
      Parameters:
      constants - the constant names
    • getEventListener

      public EventListener getEventListener()
      Gets the event listener.

      The event listener is notified about events such as code generation progress or validation errors.

      Returns:
      the event listener
    • setEventListener

      public void setEventListener(EventListener eventListener)
      Sets the event listener.

      The event listener is notified about events such as code generation progress or validation errors.

      Parameters:
      eventListener - the event listener
    • generateCode

      public void generateCode()
      Generates the code.
    • dryRun

      public void dryRun()
      Executes a dry run.

      A dry run does not write or delete any files or directories.

    • createDirectory

      public void createDirectory(Path path)
      Creates the specified directory.
      Parameters:
      path - path of directory