Class FileObjects

java.lang.Object
com.karuslabs.elementary.file.FileObjects

public class FileObjects extends Object
Utilities for creating JavaFileObjects.
  • Field Details

    • DUMMY

      public static final JavaFileObject DUMMY
      A dummy Java source file.
  • Constructor Details

    • FileObjects

      public FileObjects()
  • Method Details

    • scan

      public static List<JavaFileObject> scan(Class<?> annotated)
      Creates JavaFileObjects using the @Classpath, @Inline, @Introspect and @Resource annotations on the given class.
      Parameters:
      annotated - the annotated class
      Returns:
      the JavaFileObjects
    • scan

      public static List<JavaFileObject> scan(AnnotatedElement annotated)
      Creates JavaFileObjects using the @Classpath, @Inline and @Resource annotations on the given element.
      Parameters:
      annotated - the annotated element
      Returns:
      the JavaFileObjects
    • ofLines

      public static JavaFileObject ofLines(String fullyQualifiedName, String... lines)
      Creates a JavaFileObject using the given fully qualified class name and source code. Each line is delimited by the system's line separator.
      Parameters:
      fullyQualifiedName - the fully qualified class name
      lines - the source code
      Returns:
      a JavaFileObject
    • ofLines

      public static JavaFileObject ofLines(String fullyQualifiedName, Iterable<String> lines)
      Creates a JavaFileObject using the given fully qualified class name and source code. Each line is delimited by the system's line separator.
      Parameters:
      fullyQualifiedName - the fully qualified class name
      lines - the source code
      Returns:
      a JavaFileObject
    • ofLines

      public static JavaFileObject ofLines(String fullyQualifiedName, String source)
      Creates a JavaFileObject using the given fully qualified class name and source code.
      Parameters:
      fullyQualifiedName - the fully qualified class name
      source - the source code
      Returns:
      a JavaFileObject
    • ofClass

      public static JavaFileObject ofClass(String fullyQualifiedName)
      Creates a JavaFileObject from a source file that the given fully qualified name represents, i.e. my.package.MyClass.
      Parameters:
      fullyQualifiedName - the fully qualified name of a source file
      Returns:
      a JavaFileObject
      Throws:
      IllegalArgumentException - if the given class does not exist on the current clssspath
      UncheckedIOException - if the file could not be opened
    • ofResource

      public static JavaFileObject ofResource(String resource)
      Creates a JavaFileObject from the given resource. Directory names are separated via /. Resources must contain a valid file extension.
      Parameters:
      resource - the path to a resource, relative to the current ClassLoader
      Returns:
      a JavaFileObject
      Throws:
      IllegalArgumentException - if the given resource does not exist on the current clssspath
      UncheckedIOException - if the resource could not be opened
    • ofResource

      public static JavaFileObject ofResource(URL resource)
      Creates a JavaFileObject from the given resource.
      Parameters:
      resource - the path to a resource, relative to the current ClassLoader
      Returns:
      a JavaFileObject
      Throws:
      IllegalArgumentException - if the given resource does not exist on the current clssspath
      UncheckedIOException - if the resource could not be opened
    • deduce

      public static JavaFileObject.Kind deduce(URI uri)
      Deduces the file extension of the given URI.
      Parameters:
      uri - the URI
      Returns:
      the file kind that the given URI represents