Class Name

java.lang.Object
com.google.common.jimfs.Name

final class Name extends Object
Immutable representation of a file name. Used both for the name components of paths and as the keys for directory entries.

A name has both a display string (used in the toString() form of a Path as well as for Path equality and sort ordering) and a canonical string, which is used for determining equality of the name during file lookup.

Note: all factory methods return a constant name instance when given the original string "." or "..", ensuring that those names can be accessed statically elsewhere in the code while still being equal to any names created for those values, regardless of normalization settings.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
     
    private static final com.google.common.collect.Ordering<Name>
     
    private final String
     
    private static final com.google.common.collect.Ordering<Name>
     
    (package private) static final Name
    The empty name.
    static final Name
    The name to use for a link from a directory to its parent directory.
    static final Name
    The name to use for a link from a directory to itself.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Name(String display, String canonical)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.google.common.collect.Ordering<Name>
    Returns an ordering that orders names by their canonical representation.
    static Name
    create(String display, String canonical)
    Creates a name with the given display representation and the given canonical representation.
    static com.google.common.collect.Ordering<Name>
    Returns an ordering that orders names by their display representation.
    boolean
    equals(@Nullable Object obj)
     
    int
     
    (package private) static Name
    simple(String name)
    Creates a new name with no normalization done on the given string.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY

      static final Name EMPTY
      The empty name.
    • SELF

      public static final Name SELF
      The name to use for a link from a directory to itself.
    • PARENT

      public static final Name PARENT
      The name to use for a link from a directory to its parent directory.
    • display

      private final String display
    • canonical

      private final String canonical
    • DISPLAY_ORDERING

      private static final com.google.common.collect.Ordering<Name> DISPLAY_ORDERING
    • CANONICAL_ORDERING

      private static final com.google.common.collect.Ordering<Name> CANONICAL_ORDERING
  • Constructor Details

  • Method Details

    • simple

      static Name simple(String name)
      Creates a new name with no normalization done on the given string.
    • create

      public static Name create(String display, String canonical)
      Creates a name with the given display representation and the given canonical representation.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • displayOrdering

      public static com.google.common.collect.Ordering<Name> displayOrdering()
      Returns an ordering that orders names by their display representation.
    • canonicalOrdering

      public static com.google.common.collect.Ordering<Name> canonicalOrdering()
      Returns an ordering that orders names by their canonical representation.