Package ch.tocco.nice2.dms.api.tree
Class PathNormalizer
java.lang.Object
ch.tocco.nice2.dms.api.tree.PathNormalizer
Util to normalize and validate paths and file names.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringmakeFilenameUnique(FolderNode folder, ResourceNode resource) Checks if a file with the given name already exists and adds a corresponding counter suffix to it's name if so.static StringnormalizeAliases(String aliases) static StringnormalizeFilename(String filename) Removes illegal characters from a string to be used as name for a file or folder.static StringnormalizeName(String name) Removes illegal characters from a string to be used as name for aContentTreeNodeand therefore also as part of an URI.static @Nullable StringnormalizePath(String path) static StringnormalizePathParts(String path)
-
Field Details
-
PATH_PART_PATTERN
- See Also:
-
-
Method Details
-
normalizeName
Removes illegal characters from a string to be used as name for aContentTreeNodeand therefore also as part of an URI. Please note: The name of aContentTreeNodewill be used as itsPathin anURI, pointing to a file or folder for example. Therefore, that name has to be a valid filename as well, callingnormalizeFilename(String).- Parameters:
name- the string to be normalized- Returns:
- normalized
-
normalizeFilename
Removes illegal characters from a string to be used as name for a file or folder. See applied conventions at https://msdn.microsoft.com/en-us/library/aa365247- Parameters:
filename- the string to be normalized- Returns:
- normalized
-
normalizeAliases
-
normalizePath
-
normalizePathParts
-
makeFilenameUnique
Checks if a file with the given name already exists and adds a corresponding counter suffix to it's name if so. Example: If there is one document with the same name, it will lead to a document with suffix "-1", counting up for each other document having the same name.- Parameters:
folder- theFolderNodewhere the document shall be savedresource- theResourceNodeof which the name has to be checked for already existing resources with the same name- Returns:
- a unique filename to use
-