Package org.pkl.core.util
Class IoUtils
java.lang.Object
org.pkl.core.util.IoUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcapitalize(String str) Capitalizes the first Unicode character of the given string (rather than the first character of each word).static <T> ServiceLoader<T> createServiceLoader(Class<T> serviceClass) static URILiketoUri(String), except without checked exceptions.static StringdropLastSegment(String name, char separator) static StringencodePath(String path) Windows reserves characters<>:"\|?*in filenames.static URIstatic URIfixTripleSlashUri(URI baseUri, URI newUri) Fix an issue where triple-slash URI's turn into single-slash URI's when usingURI.resolve(URI)static Pathstatic Pathstatic Stringstatic intgetMaxLineLength(String str) static Stringstatic Stringstatic Stringstatic Pathstatic StringinferModuleName(ModuleKey moduleKey) static booleanisBinaryDigitOrUnderscore(char ch) static booleanisDecimalDigit(char ch) static booleanisDecimalDigitOrUnderscore(char ch) static booleanisHexDigit(char ch) static booleanisHexDigitOrUnderscore(char ch) static booleanisNonZeroDecimalDigit(char ch) static booleanisOctalDigit(char ch) static booleanisOctalDigitOrUnderscore(char ch) static booleanisReservedFilenameChar(char character) static booleanisReservedWindowsFilenameChar(char character) Tells if this character cannot be used for filenames on Windows.static booleanstatic booleanChecks whether the given string is "URI-like", i.e.static booleanisWhitespace(String str) static Booleanstatic booleanparseDependencyNotation(String importPath) parseTripleDotPath(URI importUri) static PathConverts a URI to a Path, normalizing any non-ASCII characters.static byte[]static StringreadClassPathResourceAsString(Class<?> clazz, String path) static StringreadString(InputStream inputStream) static StringreadString(Reader reader) static StringreadString(URL url) static URIrelativize(URI uri, URI base) static Pathrelativize(Path path, Path base) static URIstatic URIstatic URIresolve(ReaderBase reader, URI baseUri, String importUri) static URIresolve(ReaderBase reader, URI baseUri, URI importUri) static URIresolve(SecurityManager securityManager, ModuleKey moduleKey, URI importUri) ResolvesimportUriagainst the module key.static voidsetSystemProxy(URI proxyAddress) static voidstatic URIstripFragment(URI uri) static StringtakeLastSegment(String name, char separator) static StringtoHexEscape(int ch) static StringtoNormalizedPathString(Path path) Returns a path string that uses unix-like path separators.static StringtoUnicodeEscape(int ch) static URIConverts the given string to aURI.static URLstatic voidvalidateFileUri(URI uri) static voidvalidateRewriteRule(URI rewrite) static voidzipDirectory(Path sourceDir, Path targetFile)
-
Method Details
-
toUrl
- Throws:
IOException
-
isUriLike
Checks whether the given string is "URI-like", i.e. matches a pattern likefoo:bar. -
isWindowsAbsolutePath
-
toUri
Converts the given string to aURI. This method MUST be used for constructing module and resource URIs. Unlikenew URI(str), it correctly escapes paths of relative URIs.- Throws:
URISyntaxException
-
pathOf
Converts a URI to a Path, normalizing any non-ASCII characters. -
createUri
LiketoUri(String), except without checked exceptions. -
stripFragment
-
readString
- Throws:
IOException
-
readString
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
readString
- Throws:
IOException
-
readClassPathResourceAsString
- Throws:
IOException
-
zipDirectory
- Throws:
IOException
-
getCurrentWorkingDir
-
getPklHomeDir
-
getDefaultModuleCacheDir
-
getLineSeparator
-
isWindows
-
getName
-
getName
-
getNameWithoutExtension
-
takeLastSegment
-
dropLastSegment
-
toPath
-
inferModuleName
-
ensurePathEndsWithSlash
-
resolve
-
resolve
-
parseDependencyNotation
-
resolve
public static URI resolve(SecurityManager securityManager, ModuleKey moduleKey, URI importUri) throws URISyntaxException, IOException, SecurityManagerException, ExternalReaderProcessException ResolvesimportUriagainst the module key.When
importUricontains a triple-dot, it is resolved if the module key returns true for bothModuleKey.isLocal()andReaderBase.hasHierarchicalUris(). Otherwise, an error is thrown.When
importUristarts with a@, it is resolved if the module key supports dependency notation () -
resolve
-
resolve
-
relativize
-
relativize
-
isWhitespace
-
capitalize
Capitalizes the first Unicode character of the given string (rather than the first character of each word). -
getMaxLineLength
-
createServiceLoader
-
isTestMode
public static boolean isTestMode() -
setTestMode
public static void setTestMode() -
setSystemProxy
-
parseTripleDotPath
@Nullable public static @Nullable String parseTripleDotPath(URI importUri) throws URISyntaxException - Throws:
URISyntaxException
-
toUnicodeEscape
-
toHexEscape
-
isHexDigit
public static boolean isHexDigit(char ch) -
isHexDigitOrUnderscore
public static boolean isHexDigitOrUnderscore(char ch) -
isDecimalDigit
public static boolean isDecimalDigit(char ch) -
isDecimalDigitOrUnderscore
public static boolean isDecimalDigitOrUnderscore(char ch) -
isNonZeroDecimalDigit
public static boolean isNonZeroDecimalDigit(char ch) -
isOctalDigit
public static boolean isOctalDigit(char ch) -
isOctalDigitOrUnderscore
public static boolean isOctalDigitOrUnderscore(char ch) -
isBinaryDigitOrUnderscore
public static boolean isBinaryDigitOrUnderscore(char ch) -
fixTripleSlashUri
Fix an issue where triple-slash URI's turn into single-slash URI's when usingURI.resolve(URI) -
isReservedFilenameChar
public static boolean isReservedFilenameChar(char character) -
isReservedWindowsFilenameChar
public static boolean isReservedWindowsFilenameChar(char character) Tells if this character cannot be used for filenames on Windows. -
encodePath
Windows reserves characters<>:"\|?*in filenames.For any such characters, enclose their decimal character code with parentheses. Verbatim
(is encoded as((. -
toNormalizedPathString
Returns a path string that uses unix-like path separators. -
validateFileUri
- Throws:
URISyntaxException
-
validateRewriteRule
-