// Path: op1/src/main/java/com/op1/iff/Chunk.java
// public interface Chunk {
// 
//     /**
//      * Returns the ID of this chunk.
//      */
//     ID getChunkID();
// 
//     /**
//      * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the
//      * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes,
//      * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count.
//      */
//     SignedLong getChunkSize();
// 
//     /**
//      * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by
//      * getChunkSize() + 8 [+1 if getChunkSize() is odd].
//      */
//     int getPhysicalSize();
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/ID.java
// public class ID extends DataType {
// 
//     private final String name;
// 
//     public ID(byte[] bytes) {
//         // TODO: ahem, validation?
//         super(bytes, 4);
//         this.name = new String(bytes);
//     }
// 
//     public static ID valueOf(String s) {
//         return new ID(s.getBytes());
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     @Override
//     public String toString() {
//         return getName();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final ID id = (ID) o;
// 
//         return Arrays.equals(bytes, id.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/SignedLong.java
// public class SignedLong extends DataType {
// 
// 
//     public SignedLong(byte[] bytes) {
//         super(bytes, 4);
//     }
// 
//     public int toInt() {
//         return ByteBuffer.wrap(bytes).getInt();
//     }
// 
//     public static SignedLong fromInt(int i) {
//         return new SignedLong(ByteBuffer.allocate(4).putInt(i).array());
//     }
// 
//     @Override
//     public String toString() {
//         return String.valueOf(toInt());
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final SignedLong that = (SignedLong) o;
// 
//         return Arrays.equals(bytes, that.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }


import com.op1.aiff.*;
import com.op1.iff.Chunk;
import com.op1.iff.types.ID;
import com.op1.iff.types.SignedLong;
import java.util.ArrayList;
import java.util.List;
import static com.op1.aiff.ChunkType.APPLICATION;
import static java.lang.String.format;
    private void checkComplianceOfCommonChunk() {

        final CommonChunk chunk = aiff.getCommonChunk();

        int physicalSizeOfDataPortion = 0;

        physicalSizeOfDataPortion += chunk.getNumChannels().getSize();
        physicalSizeOfDataPortion += chunk.getNumSampleFrames().getSize();
        physicalSizeOfDataPortion += chunk.getSampleSize().getSize();
        physicalSizeOfDataPortion += chunk.getSampleRate().getSize();

        if (codecAndDescriptionArePresent(chunk.getCodec(), chunk.getDescription())) {
            physicalSizeOfDataPortion += chunk.getCodec().getSize();
            physicalSizeOfDataPortion += chunk.getDescription().length;
        }

        int expectedChunkSize = physicalSizeOfDataPortion % 2 == 0 ? physicalSizeOfDataPortion : physicalSizeOfDataPortion + 1;
        int expectedPhysicalSize = physicalSizeOfDataPortion + 8;

        if (expectedPhysicalSize % 2 == 1) {
            expectedPhysicalSize++;
        }

        checkChunkSizes(chunk, expectedChunkSize, expectedPhysicalSize);
    }

    private void checkChunkSizes(Chunk chunk, int expectedChunkSize, int expectedPhysicalSize) {

        final String message = format("chunkSize in the %s chunk is %s, was expecting %s",
                chunk.getChunkID().toString(), chunk.getChunkSize().toInt(), expectedChunkSize);
// Path: op1/src/main/java/com/op1/iff/Chunk.java
// public interface Chunk {
// 
//     /**
//      * Returns the ID of this chunk.
//      */
//     ID getChunkID();
// 
//     /**
//      * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the
//      * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes,
//      * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count.
//      */
//     SignedLong getChunkSize();
// 
//     /**
//      * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by
//      * getChunkSize() + 8 [+1 if getChunkSize() is odd].
//      */
//     int getPhysicalSize();
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/ID.java
// public class ID extends DataType {
// 
//     private final String name;
// 
//     public ID(byte[] bytes) {
//         // TODO: ahem, validation?
//         super(bytes, 4);
//         this.name = new String(bytes);
//     }
// 
//     public static ID valueOf(String s) {
//         return new ID(s.getBytes());
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     @Override
//     public String toString() {
//         return getName();
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final ID id = (ID) o;
// 
//         return Arrays.equals(bytes, id.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }
// 
// Path: op1/src/main/java/com/op1/iff/types/SignedLong.java
// public class SignedLong extends DataType {
// 
// 
//     public SignedLong(byte[] bytes) {
//         super(bytes, 4);
//     }
// 
//     public int toInt() {
//         return ByteBuffer.wrap(bytes).getInt();
//     }
// 
//     public static SignedLong fromInt(int i) {
//         return new SignedLong(ByteBuffer.allocate(4).putInt(i).array());
//     }
// 
//     @Override
//     public String toString() {
//         return String.valueOf(toInt());
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         final SignedLong that = (SignedLong) o;
// 
//         return Arrays.equals(bytes, that.bytes);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return Arrays.hashCode(bytes);
//     }
// }


// Path: op1/src/main/java/com/op1/util/ComplianceCheck.java
import com.op1.aiff.*;
import com.op1.iff.Chunk;
import com.op1.iff.types.ID;
import com.op1.iff.types.SignedLong;
import java.util.ArrayList;
import java.util.List;
import static com.op1.aiff.ChunkType.APPLICATION;
import static java.lang.String.format;

    private void checkComplianceOfCommonChunk() {

        final CommonChunk chunk = aiff.getCommonChunk();

        int physicalSizeOfDataPortion = 0;

        physicalSizeOfDataPortion += chunk.getNumChannels().getSize();
        physicalSizeOfDataPortion += chunk.getNumSampleFrames().getSize();
        physicalSizeOfDataPortion += chunk.getSampleSize().getSize();
        physicalSizeOfDataPortion += chunk.getSampleRate().getSize();

        if (codecAndDescriptionArePresent(chunk.getCodec(), chunk.getDescription())) {
            physicalSizeOfDataPortion += chunk.getCodec().getSize();
            physicalSizeOfDataPortion += chunk.getDescription().length;
        }

        int expectedChunkSize = physicalSizeOfDataPortion % 2 == 0 ? physicalSizeOfDataPortion : physicalSizeOfDataPortion + 1;
        int expectedPhysicalSize = physicalSizeOfDataPortion + 8;

        if (expectedPhysicalSize % 2 == 1) {
            expectedPhysicalSize++;
        }

        checkChunkSizes(chunk, expectedChunkSize, expectedPhysicalSize);
    }

    private void checkChunkSizes(Chunk chunk, int expectedChunkSize, int expectedPhysicalSize) {

        final String message = format("chunkSize in the %s chunk is %s, was expecting %s",
                chunk.getChunkID().toString(), chunk.getChunkSize().toInt(), expectedChunkSize);
        check(chunk.getChunkSize().equals(SignedLong.fromInt(expectedChunkSize)), message);