ImageObject { public String getSegmentType(int segmentNumber) { if (log.isDebugEnabled()) log.debug("getSegmentType:" + segmentNumber); if (segmentNumber < 1 || segmentNumber > MAX_SEGMENTS) { throw new IllegalArgumentException(); } if (segmentArray[segmentNumber - 1] == null || segmentArray[segmentNumber - 1].length == 0) return null; byte[] buffer = segmentArray[segmentNumber - 1]; if (isTypeTiff(buffer)) { return TYPE_TIFF; } else { return TYPE_JPEG; } } ImageObject();  ImageObject(CimsObjectHeader header);  ImageObject(ByteArray buffer); ByteArray toByteArray(); int getSegmentLength(int segmentNumber); String getSegmentType(int segmentNumber); byte[] getSegment(int segmentNumber); void addSegment(int segmentNumber, byte[] segmentBuffer); void removeSegment(int segmentNumber); byte getSegmentCount(); CimsObjectHeader getCimsObjectHeader(); CimsCodedDataHeader getCimsCodedDataHeader(); void setCimsObjectHeader(CimsObjectHeader header); void setCimsCodedDataHeader(CimsCodedDataHeader segment0); static final int MAX_SEGMENTS; static final String TYPE_JPEG; static final String TYPE_TIFF; final static int FRONTBW; final static int FRONTGS; final static int REARBW; final static int REARGS; }
@Test public void getSegmentType() throws Exception { byte[] imageIntel = readTiffImage(); byte[] imageMotorola = readTiffImageMotorola(); ImageObject io = new ImageObject(); io.addSegment(1, imageIntel); io.addSegment(2, imageMotorola); assertEquals("should be TIFF", ImageObject.TYPE_TIFF, io.getSegmentType(1)); assertEquals("should be TIFF", ImageObject.TYPE_TIFF, io.getSegmentType(2)); }