- java.lang.Object
-
- au.notzed.dez.DEZEncoder
-
- All Implemented Interfaces:
ByteDeltaEncoder
,DEZFormat
public class DEZEncoder extends java.lang.Object implements ByteDeltaEncoder, DEZFormat
'DeltaZ-1' format encoder.Encoder for the a binary delta format.
- See Also:
DEZDecoder
-
-
Field Summary
-
Fields inherited from interface au.notzed.dez.DEZFormat
ADDR_ABSOLUTE, ADDR_RELATIVE, ADDR_SIGN, MAGIC, OP_ADD, OP_COPY, OP_DUAL_COPY, OP_EXT, OP_RUN, OP_SINGLE, OP_SINGLE_LIMIT, OP_SINGLE_SPLIT
-
-
Constructor Summary
Constructors Constructor Description DEZEncoder()
Creates a new encoder with default parameters.DEZEncoder(int smallest, int split)
Creates a new encoder with a smallest copy size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(byte[] data, int off, int len)
Appends an add command.void
copy(int addr, int len)
Appends a copy command.int
getSmallest()
int
getSplit()
void
init(int sourceSize, int targetSize)
Initialises creating a new patch.void
run(byte b, int len)
Appends a byte-run.byte[]
toPatch(int targetCRC32)
Retrieves the patch.
-
-
-
Constructor Detail
-
DEZEncoder
public DEZEncoder()
Creates a new encoder with default parameters.smallest is 4 and split is @{value #OP_SINGLE_SPLIT}.
-
DEZEncoder
public DEZEncoder(int smallest, int split)
Creates a new encoder with a smallest copy size.Out of range values are silently clamped.
- Parameters:
smallest
- Sets the smallest copy allowed. It must be ≥ 4.split
- Sets the split for a single opcode. 0 ≤ split ≤ 124;
-
-
Method Detail
-
getSmallest
public int getSmallest()
-
getSplit
public int getSplit()
-
init
public void init(int sourceSize, int targetSize)
Description copied from interface:ByteDeltaEncoder
Initialises creating a new patch.Source is the data which will be common to both the encoder and decoder, target is only known by the encoder.
- Specified by:
init
in interfaceByteDeltaEncoder
- Parameters:
sourceSize
- Size of source data.targetSize
- Size of target data.
-
copy
public void copy(int addr, int len)
Description copied from interface:ByteDeltaEncoder
Appends a copy command.- Specified by:
copy
in interfaceByteDeltaEncoder
- Parameters:
addr
- Address of data.len
- Length of data.
-
add
public void add(byte[] data, int off, int len)
Description copied from interface:ByteDeltaEncoder
Appends an add command.- Specified by:
add
in interfaceByteDeltaEncoder
- Parameters:
data
- Buffer containing bytes to add.off
- Offset of addition.len
- Length of addition.
-
run
public void run(byte b, int len)
Description copied from interface:ByteDeltaEncoder
Appends a byte-run.- Specified by:
run
in interfaceByteDeltaEncoder
- Parameters:
b
- Byte to run.len
- Number of times to repeat byte.
-
toPatch
public byte[] toPatch(int targetCRC32)
Description copied from interface:ByteDeltaEncoder
Retrieves the patch.- Specified by:
toPatch
in interfaceByteDeltaEncoder
- Parameters:
targetCRC32
- CRC32 of target data.- Returns:
- The encoded patch bytes.
-
-