org.eclipse.jgit.internal.storage.pack

## Class ObjectToPack

- java.lang.Object
- - org.eclipse.jgit.lib.AnyObjectId
  - - org.eclipse.jgit.lib.ObjectId
    - - org.eclipse.jgit.lib.ObjectIdOwnerMap.Entry
      - - org.eclipse.jgit.transport.PackedObjectInfo
        - - org.eclipse.jgit.internal.storage.pack.ObjectToPack

All Implemented Interfaces:
  Serializable, Comparable<AnyObjectId>

    public class ObjectToPack
    extends PackedObjectInfo

Per-object state used by `PackWriter`.

`PackWriter` uses this class to track the things it needs to include in the newly generated pack file, and how to efficiently obtain the raw data for each object as they are written to the output stream.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`ObjectToPack(AnyObjectId src, int type)` Construct for the specified object id.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `clearExtendedFlag(int flag)` Clear an extended flag bit.
`protected void` `clearReuseAsIs()` Forget the reuse information previously stored.
`ObjectToPack` `getDeltaBase()`
`ObjectId` `getDeltaBaseId()`
`protected int` `getExtendedFlags()`
`int` `getType()`
`boolean` `isDeltaRepresentation()`
`protected boolean` `isExtendedFlag(int flag)` Determine if a particular extended flag bit has been set.
`boolean` `isReuseAsIs()`
`boolean` `isWritten()` Check if object is already written in a pack.
`void` `select(StoredObjectRepresentation ref)` Remember a specific representation for reuse at a later time.
`protected void` `setExtendedFlag(int flag)` Set an extended flag bit.
`protected void` `setExtendedFlags(int extFlags)` Set the extended flags used by the subclass.
`String` `toString()`

### Methods inherited from class org.eclipse.jgit.transport.PackedObjectInfo

`getCRC, getOffset, setCRC, setOffset`

### Methods inherited from class org.eclipse.jgit.lib.ObjectId

`equals, fromRaw, fromRaw, fromRaw, fromRaw, fromString, fromString, isId, toObjectId, toString, zeroId`

### Methods inherited from class org.eclipse.jgit.lib.AnyObjectId

`abbreviate, compareTo, compareTo, compareTo, copy, copyRawTo, copyRawTo, copyRawTo, copyRawTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, equals, equals, equals, getByte, getFirstByte, getName, hashCode, name, startsWith`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ObjectToPack

    public ObjectToPack(AnyObjectId src,
                        int type)

Construct for the specified object id.

Parameters:
  `src` - object id of object for packing
  `type` - real type code of the object, not its in-pack type.

### Method Detail

#### getDeltaBaseId

    public final ObjectId getDeltaBaseId()

Returns:
  delta base object id if object is going to be packed in delta representation; null otherwise - if going to be packed as a whole object.

#### getDeltaBase

    public final ObjectToPack getDeltaBase()

Returns:
  delta base object to pack if object is going to be packed in delta representation and delta is specified as object to pack; null otherwise - if going to be packed as a whole object or delta base is specified only as id.

#### isDeltaRepresentation

    public final boolean isDeltaRepresentation()

Returns:
  true if object is going to be written as delta; false otherwise.

#### isWritten

    public final boolean isWritten()

Check if object is already written in a pack. This information is used to achieve delta-base precedence in a pack file.

Returns:
  true if object is already written; false otherwise.

#### getType

    public final int getType()

Returns:
  the type of this object.

#### isReuseAsIs

    public final boolean isReuseAsIs()

Returns:
  true if an existing representation was selected to be reused as-is into the pack stream.

#### clearReuseAsIs

    protected void clearReuseAsIs()

Forget the reuse information previously stored.

Implementations may subclass this method, but they must also invoke the super version with `super.clearReuseAsIs()` to ensure the flag is properly cleared for the writer.

#### getExtendedFlags

    protected final int getExtendedFlags()

Returns:
  the extended flags on this object, in the range [0x0, 0xf].

#### isExtendedFlag

    protected final boolean isExtendedFlag(int flag)

Determine if a particular extended flag bit has been set. This implementation may be faster than calling `getExtendedFlags()` and testing the result.

Parameters:
  `flag` - the flag mask to test, must be between 0x0 and 0xf.
Returns:
  true if any of the bits matching the mask are non-zero.

#### setExtendedFlag

    protected final void setExtendedFlag(int flag)

Set an extended flag bit. This implementation is more efficient than getting the extended flags, adding the bit, and setting them all back.

Parameters:
  `flag` - the bits to set, must be between 0x0 and 0xf.

#### clearExtendedFlag

    protected final void clearExtendedFlag(int flag)

Clear an extended flag bit. This implementation is more efficient than getting the extended flags, removing the bit, and setting them all back.

Parameters:
  `flag` - the bits to clear, must be between 0x0 and 0xf.

#### setExtendedFlags

    protected final void setExtendedFlags(int extFlags)

Set the extended flags used by the subclass. Subclass implementations may store up to 4 bits of information inside of the internal flags field already used by the base ObjectToPack instance.

Parameters:
  `extFlags` - additional flag bits to store in the flags field. Due to space constraints only values [0x0, 0xf] are permitted.

#### select

    public void select(StoredObjectRepresentation ref)

Remember a specific representation for reuse at a later time.

Implementers should remember the representation chosen, so it can be reused at a later time. `PackWriter` may invoke this method multiple times for the same object, each time saving the current best representation found.

Parameters:
  `ref` - the object representation.

#### toString

    public String toString()

Overrides:
  `toString` in class `AnyObjectId`