Package com.tnsai.rag
Class KnowledgePaths
java.lang.Object
com.tnsai.rag.KnowledgePaths
Where the FILE path of a knowledge source points, the one rule every reader
of the source follows.
- Since:
- 0.18.6
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathResolves the FILE path of a knowledge source, written inKnowledge.path(), given by a@Configor run file, or built in code.static PathResolves a FILE path asresolve(String)does, against a base the caller read once, so a reader that compares two paths resolves both against the same base.
-
Method Details
-
resolve
Resolves the FILE path of a knowledge source, written inKnowledge.path(), given by a@Configor run file, or built in code. A relative path resolves against the base directoryClassConfig.useBaseDirectory(java.nio.file.Path)set, when one is set, and against the working directory otherwise; an absolute path is kept. It resolves against the base directory current when it is called, so a reader calls it when it reads the source. The base is one per process: two runs in one JVM with different bases are not told apart, and a source read while another thread callsClassConfig.useBaseDirectory(java.nio.file.Path)reads whichever base was current at that moment.The result is lexical. Neither the base nor the path is turned into its real path, so a base reached through a symbolic link keeps that spelling, and the same folder spelt through and around the link gives two different paths. The loader then applies its own symbolic-link rules to the path it reads.
- Parameters:
path- a FILE path; an empty one resolves to the base or working directory itself, so a reader that treats an empty or blank path as unconfigured checks it first- Returns:
- the path, absolute and normalized
- Throws:
NullPointerException- whenpathis nullInvalidPathException- whenpathdoes not parse
-
resolve
Resolves a FILE path asresolve(String)does, against a base the caller read once, so a reader that compares two paths resolves both against the same base.- Parameters:
path- a FILE path, asresolve(String)takes itbase- the base directory, ornullfor the working directory- Returns:
- the path, absolute and normalized
- Throws:
NullPointerException- whenpathis nullInvalidPathException- whenpathdoes not parse
-