Class PathCodec
Encoding: UTF-8 percent-encoding. Only [A-Za-z0-9_-] pass through unchanged; every
other byte (including / \ . % and control characters) becomes %XX. The result is
a single printable path segment that round-trips losslessly via decode(java.lang.String). Names whose
encoding exceeds 250 characters are shortened deterministically to
<prefix>~<sha256 hex of the full name>, which keeps two long names differing only at the
tail on different files (such shortened names no longer decode, but they stay stable).
Uniqueness. encode never emits ~ raw (it becomes %7E), so
a shortened name always contains exactly one character no plain encoding contains and can never
equal the encoding of another, shorter name. Unreleased builds joined the shortened form with
-, which a plain encoding does emit; files in that form are neither read nor migrated
(D-43): such a file can only be another item's plain encoding.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDecodes an encoded file-name segment back to the original job full name.static StringEncodes a job full name into a safe, deterministic, collision-free file-name segment.static booleanWhetheridhas the shape of a store identifier: ASCII letters, digits and-only, at most 128 characters.static PathThe file<id><suffix>underbaseDirof the entityid(S-39-01).static PathresolveUnder(Path baseDir, String fileName) ResolvesfileNameunderbaseDir, guaranteeing the result cannot escape.
-
Method Details
-
encode
Encodes a job full name into a safe, deterministic, collision-free file-name segment. -
decode
Decodes an encoded file-name segment back to the original job full name.- Throws:
IllegalArgumentException- if the input contains any character outside the encoding alphabet (in particular/ \ ., so traversal strings are rejected) or a malformed%XXescape.
-
isId
Whetheridhas the shape of a store identifier: ASCII letters, digits and-only, at most 128 characters. New requests and windows get UUIDs (D-68) and history recordsyyyyMMdd-HHmmss-<6 random>ids (Ids), and both forms qualify.S-39-01: an identifier is turned into a file name only after this check, so it can name only its own file: without
.it can never reach another file of the same directory under another suffix (a run request's<id>.values.xml, also in another letter case on a case-insensitive file system), and without~never a Windows 8.3 short name. -
resolveId
The file<id><suffix>underbaseDirof the entityid(S-39-01).- Throws:
IllegalArgumentException- ifidis not a store identifier (isId(java.lang.String)) or the file name is unsafe (resolveUnder(java.nio.file.Path, java.lang.String))
-
resolveUnder
ResolvesfileNameunderbaseDir, guaranteeing the result cannot escape.- Throws:
IllegalArgumentException- if the file name contains a path separator, is.or.., or the resolved path leavesbaseDir.
-