src/org/ohmage/validator/ImageValidators.java
public static Image validateImageContents(
			final UUID imageId,
			final byte[] imageContents) throws ValidationException {
		
		if(imageId == null) {
			throw new ValidationException("The image ID is null.");
		}
		if((imageContents == null) || (imageContents.length == 0)) {
			return null;
		}
		
		try {
			return new Image(imageId, new ByteArrayInputStream(imageContents));
		}
		catch(DomainException e) {
			throw new ValidationException(
				ErrorCode.IMAGE_INVALID_DATA,
				"The image data was not valid image data.",
				e);
		}
	}
/**
	 * Validates that an image's contents as a byte array are decodable as an 
	 * image.
	 * 
	 * @param imageId The ID for this image.
	 *  
	 * @param imageContents The image's contents as a byte array.
	 * 
	 * @return Returns null if the image's contents are null or have a length 
	 * 		   of zero; otherwise, a BufferedImage representing a decoded  
	 * 		   version of the image are returned.
	 * 
	 * @throws ValidationException Thrown if the image is not null, has a 
	 * 							   length greater than 0, and isn't decodable 
	 * 							   as any type of known image.
	 */
Validates that an image's contents as a byte array are decodable as an
image.

@param imageId The ID for this image.

@param imageContents The image's contents as a byte array.

@return Returns null if the image's contents are null or have a length
of zero; otherwise, a BufferedImage representing a decoded
version of the image are returned.

@throws ValidationException Thrown if the image is not null, has a
length greater than 0, and isn't decodable
as any type of known image.
Validates that an image ' s contents as a byte array are decodable as an image . @param imageId The ID for this image . @param imageContents The image ' s contents as a byte array . @return Returns null if the image ' s contents are null or have a length of zero ; otherwise a BufferedImage representing a decoded version of the image are returned . @throws ValidationException Thrown if the image is not null has a length greater than 0 and isn ' t decodable as any type of known image .
public static Image validateImageContents(
			final UUID imageId,
			final byte[] imageContents) throws ValidationException {
		if(imageId == null) {
			throw new ValidationException("The image ID is null.");
		}
		if((imageContents == null) || (imageContents.length == 0)) {
			return null;
		}
		try {
			return new Image(imageId, new ByteArrayInputStream(imageContents));
		}
		catch(DomainException e) {
			throw new ValidationException(
				ErrorCode.IMAGE_INVALID_DATA,
				"The image data was not valid image data.",
				e);
		}
	}
public static Image validateImageContents ( final UUID imageId , final byte [ ] imageContents ) throws ValidationException { if ( imageId == null ) { throw new ValidationException ( "The image ID is null." ) ; } if ( ( imageContents == null ) || ( imageContents . length == 0 ) ) { return null ; } try { return new Image ( imageId , new ByteArrayInputStream ( imageContents ) ) ; } catch ( DomainException e ) { throw new ValidationException ( ErrorCode . IMAGE_INVALID_DATA , "The image data was not valid image data." , e ) ; } }
Validates that an image's contents as a byte array are decodable as an
 image.
Validates that an image ' s contents as a byte array are decodable as an image .