package com.nickww.finitefield;

public abstract class ChecksumVector
{
	/**
	 * Calculates checksums for the given data, and returns a vector which is the given data bytes followed by the
	 * checksum bytes.
	 * 
	 * @param data The data to checksum.
	 * @return An array with the data and the checksums.
	 */
	public abstract byte[] withChecksums(byte[] data);
	
	/**
	 * Calculates the data bytes from the given array. The array must represent the data bytes, in order, followed by
	 * the checksum bytes, in order. Values which are missing (to be solved for) should be present as a
	 * <code>null</code>.
	 * 
	 * @param dataWithChecksums The data, followed by the checksums, with nulls for unknown values.
	 * @return An array with the original data bytes (no checksums).
	 * @throws IllegalArgumentException if the given byte array has too many missing values (nulls) to recalculate the
	 * original data, or if the array is not large enough to be valid.
	 */
	public abstract byte[] solveMissingValues(Byte[] dataWithChecksums);
}

@@ -28,16 +28,71 @@
 eld;%0D%0A%0D%0A
+import java.util.ArrayList;%0D%0Aimport java.util.List;%0D%0A%0D%0A
 public a
@@ -1108,11 +1108,554 @@
 sums);%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Returns a list of the indices of the given array whose values are null. If the given array is null, null is%0D%0A%09 * returned.%0D%0A%09 * %0D%0A%09 * @param array The array in which to check for nulls.%0D%0A%09 * @return The indices of the given array which are null, sorted in ascending order, or null.%0D%0A%09 */%0D%0A%09protected List%3CInteger%3E missingIndices(Byte%5B%5D array)%0D%0A%09%7B%0D%0A%09%09if(array == null)%0D%0A%09%09%09return null;%0D%0A%09%09%0D%0A%09%09List%3CInteger%3E nulls = new ArrayList%3C%3E();%0D%0A%09%09for(int index = 0; index %3C array.length; index++)%0D%0A%09%09%09nulls.add(index);%0D%0A%09%09return nulls;%0D%0A%09%7D%0D%0A
 %7D%0D%0A

Create convenience method to determine the indices of null in an array