Class ClassPathSource
java.lang.Object
dev.langchain4j.data.document.source.ClassPathSource
- All Implemented Interfaces:
dev.langchain4j.data.document.DocumentSource
Specialization of a
DocumentSource that knows how to read from the classpath.
Use ClassPathDocumentLoader to load
Documents using this.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTheClassLoaderthat was used to load thisClassPathSourcestatic ClassPathSourceCreates a new instance ofClassPathSourcefrom the given classpath resource string, usingThread.currentThread().getContextClassLoader()as the class loader.static ClassPathSourcefrom(String classPathResource, ClassLoader classLoader) Creates a new instance ofClassPathSourcefrom the given classpath resource and classloader.booleanDetermines if the resource represented by thisClassPathSourceis inside an archive.dev.langchain4j.data.document.Metadatametadata()url()Retrieves the URL associated with thisClassPathSource.
-
Constructor Details
-
ClassPathSource
-
-
Method Details
-
from
Creates a new instance ofClassPathSourcefrom the given classpath resource string, usingThread.currentThread().getContextClassLoader()as the class loader.- Parameters:
classPathResource- The path of the classpath resource to be loaded.- Returns:
- A
ClassPathSourceinstance representing the classpath resource. - Throws:
IllegalArgumentException- if the classpath resource is blank or cannot be found.- See Also:
-
from
Creates a new instance ofClassPathSourcefrom the given classpath resource and classloader.- Parameters:
classPathResource- The path of the classpath resource to be loaded. Must not be blank.classLoader- The class loader to use for loading the resource. Ifnullthen usesThread.currentThread().getContextClassLoader()as the class loader.- Returns:
- A
ClassPathSourceinstance representing the classpath resource. - Throws:
IllegalArgumentException- If the classpath resource is blank or cannot be found, or if the class loader is null.
-
url
Retrieves the URL associated with thisClassPathSource.- Returns:
- The
URLinstance representing the classpath resource.
-
classLoader
TheClassLoaderthat was used to load thisClassPathSource- Returns:
- The
ClassLoaderthat was used to load thisClassPathSource
-
isInsideArchive
public boolean isInsideArchive()Determines if the resource represented by thisClassPathSourceis inside an archive.- Returns:
trueif the resource is packaged inside an archive, otherwisefalse.
-
inputStream
- Specified by:
inputStreamin interfacedev.langchain4j.data.document.DocumentSource- Throws:
IOException
-
metadata
public dev.langchain4j.data.document.Metadata metadata()- Specified by:
metadatain interfacedev.langchain4j.data.document.DocumentSource
-