Package org.apache.commons.codec.digest
Class GitIdentifiers.DirectoryEntry
java.lang.Object
org.apache.commons.codec.digest.GitIdentifiers.DirectoryEntry
- All Implemented Interfaces:
Comparable<GitIdentifiers.DirectoryEntry>
- Enclosing class:
- GitIdentifiers
static class GitIdentifiers.DirectoryEntry
extends Object
implements Comparable<GitIdentifiers.DirectoryEntry>
Represents a single entry in a Git tree object.
A Git tree object encodes a directory snapshot. Each entry holds:
- a
GitIdentifiers.FileModethat determines the Unix file mode (e.g.100644for a regular file), - the entry name (file or directory name, without a path separator),
- the raw object id of the referenced blob or sub-tree.
Entries are ordered by compareTo(org.apache.commons.codec.digest.GitIdentifiers.DirectoryEntry) using Git's tree-sort rule: names are compared as unsigned UTF-8 bytes, and directory names are compared as if
they ended with '/', so that foo/ sorts after foobar. Comparing the UTF-8 bytes rather than the Java String matches Git's
order for names outside the Basic Multilingual Plane, whose UTF-16 code units do not sort in code point order.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe entry name (file or directory name, no path separator).private final byte[]The raw object id of the referenced blob or sub-tree.private final byte[]The key used for ordering entries within a tree object, as the UTF-8 bytes Git itself compares.private final GitIdentifiers.FileModeThe Git object type, which determines the Unix file-mode prefix. -
Constructor Summary
ConstructorsConstructorDescriptionDirectoryEntry(String name, GitIdentifiers.FileMode type, byte[] rawObjectId) Constructs a new entry. -
Method Summary
Modifier and TypeMethodDescriptionintbooleaninthashCode()private static StringrequireValidName(String name)
-
Field Details
-
name
The entry name (file or directory name, no path separator). -
rawObjectId
private final byte[] rawObjectIdThe raw object id of the referenced blob or sub-tree. -
sortKey
private final byte[] sortKeyThe key used for ordering entries within a tree object, as the UTF-8 bytes Git itself compares.Git appends
'/'to directory names before comparing. -
type
The Git object type, which determines the Unix file-mode prefix.
-
-
Constructor Details
-
DirectoryEntry
DirectoryEntry(String name, GitIdentifiers.FileMode type, byte[] rawObjectId) Constructs a new entry.- Parameters:
name- The nonempty entry name, not.or.., without'/', NUL or unpaired surrogates.type- The type of the entry, not null.rawObjectId- The id of the entry, not null.
-
-
Method Details
-
requireValidName
-
compareTo
- Specified by:
compareToin interfaceComparable<GitIdentifiers.DirectoryEntry>
-
equals
-
hashCode
public int hashCode()
-