Package com.google.common.jimfs
Class Name
- java.lang.Object
-
- com.google.common.jimfs.Name
-
final class Name extends java.lang.ObjectImmutable 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 aPathas well as forPathequality 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 java.lang.Stringcanonicalprivate static java.util.Comparator<Name>CANONICAL_COMPARATORprivate java.lang.Stringdisplayprivate static java.util.Comparator<Name>DISPLAY_COMPARATOR(package private) static NameEMPTYThe empty name.static NamePARENTThe name to use for a link from a directory to its parent directory.static NameSELFThe name to use for a link from a directory to itself.
-
Constructor Summary
Constructors Modifier Constructor Description privateName(java.lang.String display, java.lang.String canonical)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.util.Comparator<Name>canonicalComparator()Returns a comparator that orders names by their canonical representation.static Namecreate(java.lang.String display, java.lang.String canonical)Creates a name with the given display representation and the given canonical representation.(package private) static java.util.Comparator<Name>displayComparator()Returns a comparator that orders names by their display representation.booleanequals(@Nullable java.lang.Object obj)inthashCode()(package private) static Namesimple(java.lang.String name)Creates a new name with no normalization done on the given string.java.lang.StringtoString()
-
-
-
Field Detail
-
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 java.lang.String display
-
canonical
private final java.lang.String canonical
-
DISPLAY_COMPARATOR
private static final java.util.Comparator<Name> DISPLAY_COMPARATOR
-
CANONICAL_COMPARATOR
private static final java.util.Comparator<Name> CANONICAL_COMPARATOR
-
-
Method Detail
-
simple
static Name simple(java.lang.String name)
Creates a new name with no normalization done on the given string.
-
create
public static Name create(java.lang.String display, java.lang.String canonical)
Creates a name with the given display representation and the given canonical representation.
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
displayComparator
static java.util.Comparator<Name> displayComparator()
Returns a comparator that orders names by their display representation.
-
canonicalComparator
static java.util.Comparator<Name> canonicalComparator()
Returns a comparator that orders names by their canonical representation.
-
-