public class TreeFormatter extends Object
Constructor and Description |
---|
TreeFormatter()
Create an empty formatter with a default buffer size.
|
TreeFormatter(int size)
Create an empty formatter with the specified buffer size.
|
Modifier and Type | Method and Description |
---|---|
void |
append(byte[] name,
FileMode mode,
AnyObjectId id)
Append any entry to the tree.
|
void |
append(byte[] nameBuf,
int namePos,
int nameLen,
FileMode mode,
AnyObjectId id)
Append any entry to the tree.
|
void |
append(byte[] nameBuf,
int namePos,
int nameLen,
FileMode mode,
byte[] idBuf,
int idPos)
Append any entry to the tree.
|
void |
append(String name,
FileMode mode,
AnyObjectId id)
Append any entry to the tree.
|
void |
append(String name,
RevBlob blob)
Add a regular file, mode is
FileMode.REGULAR_FILE . |
void |
append(String name,
RevCommit commit)
Add a link to a submodule commit, mode is
FileMode.GITLINK . |
void |
append(String name,
RevTree tree)
Add a subtree, mode is
FileMode.TREE . |
ObjectId |
computeId(ObjectInserter ins)
Compute the ObjectId for this tree
|
static int |
entrySize(FileMode mode,
int nameLen)
Compute the size of a tree entry record.
|
ObjectId |
insertTo(ObjectInserter ins)
Insert this tree and obtain its ObjectId.
|
byte[] |
toByteArray()
Copy this formatter's buffer into a byte array.
|
String |
toString() |
public TreeFormatter()
public TreeFormatter(int size)
size
- estimated size of the tree, in bytes. Callers can use
entrySize(FileMode, int)
to estimate the size of each
entry in advance of allocating the formatter.public static int entrySize(FileMode mode, int nameLen)
mode
- the mode the entry will have.nameLen
- the length of the name, in bytes.public void append(String name, RevCommit commit)
FileMode.GITLINK
.name
- name of the entry.commit
- the ObjectId to store in this entry.public void append(String name, RevTree tree)
FileMode.TREE
.name
- name of the entry.tree
- the ObjectId to store in this entry.public void append(String name, RevBlob blob)
FileMode.REGULAR_FILE
.name
- name of the entry.blob
- the ObjectId to store in this entry.public void append(String name, FileMode mode, AnyObjectId id)
name
- name of the entry.mode
- mode describing the treatment of id
.id
- the ObjectId to store in this entry.public void append(byte[] name, FileMode mode, AnyObjectId id)
name
- name of the entry. The name should be UTF-8 encoded, but file
name encoding is not a well defined concept in Git.mode
- mode describing the treatment of id
.id
- the ObjectId to store in this entry.public void append(byte[] nameBuf, int namePos, int nameLen, FileMode mode, AnyObjectId id)
nameBuf
- buffer holding the name of the entry. The name should be UTF-8
encoded, but file name encoding is not a well defined concept
in Git.namePos
- first position within nameBuf
of the name data.nameLen
- number of bytes from nameBuf
to use as the name.mode
- mode describing the treatment of id
.id
- the ObjectId to store in this entry.public void append(byte[] nameBuf, int namePos, int nameLen, FileMode mode, byte[] idBuf, int idPos)
nameBuf
- buffer holding the name of the entry. The name should be UTF-8
encoded, but file name encoding is not a well defined concept
in Git.namePos
- first position within nameBuf
of the name data.nameLen
- number of bytes from nameBuf
to use as the name.mode
- mode describing the treatment of id
.idBuf
- buffer holding the raw ObjectId of the entry.idPos
- first position within idBuf
to copy the id from.public ObjectId insertTo(ObjectInserter ins) throws IOException
ins
- the inserter to store the tree.IOException
- the tree could not be stored.public ObjectId computeId(ObjectInserter ins)
ins
- public byte[] toByteArray()
ObjectInserter.insert(TreeFormatter)
instead.Copyright © 2015 Eclipse JGit Project. All rights reserved.