Class SourceFactory


  • public class SourceFactory
    extends Object
    A factory of core Source implementations.
    Since:
    0.1.0
    Author:
    oswaldo.bapvic.jr (Oswaldo Junior)
    • Method Detail

      • fileSource

        public static <T> Source<T> fileSource​(String path)
        Creates a new FileSource for loading a local file from the file system.

        The path may contain system environment variables, which must be placed between "${" and "}". For example: "${TEMP}/file.txt".

        Type Parameters:
        T - the target return type
        Parameters:
        path - the file path
        Returns:
        a FileSource
      • classpathFileSource

        public static <T> Source<T> classpathFileSource​(String path)
        Creates a new ClasspathFileSource for loading a local file resource from the Java classpath.
        Type Parameters:
        T - the target return type
        Parameters:
        path - the relative path to the source file in the Java classpath
        Returns:
        a ClasspathFileSource
      • dynamicSource

        public static <T> Source<T> dynamicSource​(String path)
        Creates a new DynamicSource.
        Type Parameters:
        T - the target return type
        Parameters:
        path - the path to the dynamic resource
        Returns:
        a DynamicSource
      • stringSource

        public static <T> Source<T> stringSource​(String string)
        Creates a new StringSource for loading contents of a String.
        Type Parameters:
        T - the target return type
        Parameters:
        string - the string to be parsed
        Returns:
        a StringSource
      • urlSource

        public static <T> Source<T> urlSource​(String url)
        Creates a new URLSource for loading contents of a URL.
        Type Parameters:
        T - the target return type
        Parameters:
        url - the URL to be parsed
        Returns:
        a URLSource
        Since:
        0.4.0