CommandLineUtil (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.util, class: CommandLineUtil

Package org.apache.lucene.util

# Class CommandLineUtil

java.lang.Object
org.apache.lucene.util.CommandLineUtil

public final class CommandLineUtil extends Object
Class containing some useful methods used by command line tools

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Class<? extends Directory>`
  `loadDirectoryClass(String clazzName)`
  Loads a specific Directory implementation
  `static Class<? extends FSDirectory>`
  `loadFSDirectoryClass(String clazzName)`
  Loads a specific FSDirectory implementation
  `static FSDirectory`
  `newFSDirectory(Class<? extends FSDirectory> clazz, Path path)`
  Creates a new specific FSDirectory instance
  `static FSDirectory`
  `newFSDirectory(Class<? extends FSDirectory> clazz, Path path, LockFactory lf)`
  Creates a new specific FSDirectory instance
  `static FSDirectory`
  `newFSDirectory(String clazzName, Path path)`
  Creates a specific FSDirectory instance starting from its class name, using the default lock factory
  `static FSDirectory`
  `newFSDirectory(String clazzName, Path path, LockFactory lf)`
  Creates a specific FSDirectory instance starting from its class name

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### newFSDirectory

    public static FSDirectory newFSDirectory(String clazzName, Path path)
    Creates a specific FSDirectory instance starting from its class name, using the default lock factory
    Parameters:
      `clazzName` - The name of the FSDirectory class to load
      `path` - The path to be used as parameter constructor
    Returns:
      the new FSDirectory instance

  - ### newFSDirectory

    public static FSDirectory newFSDirectory(String clazzName, Path path, LockFactory lf)
    Creates a specific FSDirectory instance starting from its class name
    Parameters:
      `clazzName` - The name of the FSDirectory class to load
      `path` - The path to be used as parameter constructor
      `lf` - The lock factory to be used
    Returns:
      the new FSDirectory instance

  - ### loadDirectoryClass

    public static Class<? extends Directory> loadDirectoryClass(String clazzName) throws ClassNotFoundException
    Loads a specific Directory implementation
    Parameters:
      `clazzName` - The name of the Directory class to load
    Returns:
      The Directory class loaded
    Throws:
      `ClassNotFoundException` - If the specified class cannot be found.

  - ### loadFSDirectoryClass

    public static Class<? extends FSDirectory> loadFSDirectoryClass(String clazzName) throws ClassNotFoundException
    Loads a specific FSDirectory implementation
    Parameters:
      `clazzName` - The name of the FSDirectory class to load
    Returns:
      The FSDirectory class loaded
    Throws:
      `ClassNotFoundException` - If the specified class cannot be found.

  - ### newFSDirectory

    public static FSDirectory newFSDirectory(Class<? extends FSDirectory> clazz, Path path) throws ReflectiveOperationException
    Creates a new specific FSDirectory instance
    Parameters:
      `clazz` - The class of the object to be created
      `path` - The file to be used as parameter constructor
    Returns:
      The new FSDirectory instance
    Throws:
      `NoSuchMethodException` - If the Directory does not have a constructor that takes `Path`.
      `InstantiationException` - If the class is abstract or an interface.
      `IllegalAccessException` - If the constructor does not have public visibility.
      `InvocationTargetException` - If the constructor throws an exception
      `ReflectiveOperationException`

  - ### newFSDirectory

    public static FSDirectory newFSDirectory(Class<? extends FSDirectory> clazz, Path path, LockFactory lf) throws ReflectiveOperationException
    Creates a new specific FSDirectory instance
    Parameters:
      `clazz` - The class of the object to be created
      `path` - The file to be used as parameter constructor
      `lf` - The lock factory to be used
    Returns:
      The new FSDirectory instance
    Throws:
      `NoSuchMethodException` - If the Directory does not have a constructor that takes `Path`.
      `InstantiationException` - If the class is abstract or an interface.
      `IllegalAccessException` - If the constructor does not have public visibility.
      `InvocationTargetException` - If the constructor throws an exception
      `ReflectiveOperationException`