Class FilePathRestrictions


  • public class FilePathRestrictions
    extends java.lang.Object
    Capture a set of rules by which local files may not be named on the file-system.
    Since:
    5.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      char safeCharacter  
      com.google.common.collect.ImmutableSet<java.lang.Character> safeCharacters  
      com.google.common.collect.ImmutableMap<java.lang.Integer,​java.lang.Integer> transformationMap  
      com.google.common.collect.ImmutableSetMultimap<java.lang.Integer,​java.lang.Integer> transformationMatrix  
      com.google.common.collect.ImmutableSet<java.lang.String> unsafeNames  
      com.google.common.collect.ImmutableSet<java.lang.String> unsafePrefixes  
      com.google.common.collect.ImmutableSet<java.lang.String> unsafeSuffixes  
    • Constructor Summary

      Constructors 
      Constructor Description
      FilePathRestrictions​(com.google.common.collect.SetMultimap<java.lang.Integer,​java.lang.Integer> transformationMatrix, java.util.Set<java.lang.String> unsafePrefixes, java.util.Set<java.lang.String> unsafeSuffixes, java.util.Set<java.lang.String> unsafeNames, java.util.Set<java.lang.Character> safeCharacters)
      Construct a set of rules by which local files may not be named on the file-system.
    • Field Detail

      • transformationMatrix

        public final com.google.common.collect.ImmutableSetMultimap<java.lang.Integer,​java.lang.Integer> transformationMatrix
      • unsafePrefixes

        public final com.google.common.collect.ImmutableSet<java.lang.String> unsafePrefixes
      • unsafeSuffixes

        public final com.google.common.collect.ImmutableSet<java.lang.String> unsafeSuffixes
      • unsafeNames

        public final com.google.common.collect.ImmutableSet<java.lang.String> unsafeNames
      • safeCharacters

        public final com.google.common.collect.ImmutableSet<java.lang.Character> safeCharacters
      • safeCharacter

        public final char safeCharacter
      • transformationMap

        public final com.google.common.collect.ImmutableMap<java.lang.Integer,​java.lang.Integer> transformationMap
    • Constructor Detail

      • FilePathRestrictions

        public FilePathRestrictions​(com.google.common.collect.SetMultimap<java.lang.Integer,​java.lang.Integer> transformationMatrix,
                                    java.util.Set<java.lang.String> unsafePrefixes,
                                    java.util.Set<java.lang.String> unsafeSuffixes,
                                    java.util.Set<java.lang.String> unsafeNames,
                                    java.util.Set<java.lang.Character> safeCharacters)
        Construct a set of rules by which local files may not be named on the file-system.
        Parameters:
        transformationMatrix - how to make specific characters safe, may be null
        unsafePrefixes - which name prefixes are proscribed, may be null
        unsafeSuffixes - which name suffixes are proscribed, may be null
        unsafeNames - which names are proscribed, may be null
        safeCharacters - safe characters that may be used in making file names safe, may not be null
    • Method Detail

      • combineFilePathRestrictions

        public static FilePathRestrictions combineFilePathRestrictions​(FilePathRestrictions... rules)
        Combine sets of rules to form a set that satisfies them all and that include transformations away from Unicode control characters.
        Parameters:
        rules - at least one set of rules
        Returns:
        the intersection of the given rules, with full coverage for preventing control characters