Enum PathNormalization

  • All Implemented Interfaces:
    com.google.common.base.Function<java.lang.String,​java.lang.String>, java.io.Serializable, java.lang.Comparable<PathNormalization>, java.util.function.Function<java.lang.String,​java.lang.String>

    public enum PathNormalization
    extends java.lang.Enum<PathNormalization>
    implements com.google.common.base.Function<java.lang.String,​java.lang.String>
    Normalizations that can be applied to names in paths. Includes Unicode normalizations and normalizations for case insensitive paths. These normalizations can be set in Configuration.Builder when creating a Jimfs file system instance and are automatically applied to paths in the file system.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      CASE_FOLD_ASCII
      ASCII case folding for simple case insensitive paths.
      CASE_FOLD_UNICODE
      Unicode case folding for case insensitive paths.
      NFC
      Unicode composed normalization (form NFC).
      NFD
      Unicode decomposed normalization (form NFD).
      NONE
      No normalization.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int patternFlags  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PathNormalization​(int patternFlags)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.String apply​(java.lang.String string)
      Applies this normalization to the given string, returning the normalized result.
      static java.util.regex.Pattern compilePattern​(java.lang.String regex, java.lang.Iterable<PathNormalization> normalizations)
      Compiles a regex pattern using flags based on the given normalizations.
      static java.lang.String normalize​(java.lang.String string, java.lang.Iterable<PathNormalization> normalizations)
      Applies the given normalizations to the given string in order, returning the normalized result.
      int patternFlags()
      Returns the flags that should be used when creating a regex Pattern in order to approximate this normalization.
      static PathNormalization valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static PathNormalization[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.google.common.base.Function

        equals
      • Methods inherited from interface java.util.function.Function

        andThen, compose
    • Enum Constant Detail

      • NFC

        public static final PathNormalization NFC
        Unicode composed normalization (form NFC).
      • NFD

        public static final PathNormalization NFD
        Unicode decomposed normalization (form NFD).
      • CASE_FOLD_UNICODE

        public static final PathNormalization CASE_FOLD_UNICODE
        Unicode case folding for case insensitive paths. Requires ICU4J on the classpath.
      • CASE_FOLD_ASCII

        public static final PathNormalization CASE_FOLD_ASCII
        ASCII case folding for simple case insensitive paths.
    • Field Detail

      • patternFlags

        private final int patternFlags
    • Constructor Detail

      • PathNormalization

        private PathNormalization​(int patternFlags)
    • Method Detail

      • values

        public static PathNormalization[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PathNormalization c : PathNormalization.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PathNormalization valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • apply

        public abstract java.lang.String apply​(java.lang.String string)
        Applies this normalization to the given string, returning the normalized result.
        Specified by:
        apply in interface com.google.common.base.Function<java.lang.String,​java.lang.String>
        Specified by:
        apply in interface java.util.function.Function<java.lang.String,​java.lang.String>
      • patternFlags

        public int patternFlags()
        Returns the flags that should be used when creating a regex Pattern in order to approximate this normalization.
      • normalize

        public static java.lang.String normalize​(java.lang.String string,
                                                 java.lang.Iterable<PathNormalization> normalizations)
        Applies the given normalizations to the given string in order, returning the normalized result.
      • compilePattern

        public static java.util.regex.Pattern compilePattern​(java.lang.String regex,
                                                             java.lang.Iterable<PathNormalization> normalizations)
        Compiles a regex pattern using flags based on the given normalizations.