class ChecksumPipe extends FixedForwardPipe {

	@Override
	public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException {
		String result;
		try {
			ChecksumGenerator cg=createChecksumGenerator();
			if (isInputIsFile()) {
				byte barr[]=new byte[1000];
				FileInputStream fis=new FileInputStream(message.asString());
				int c;
				while ((c=fis.read(barr))>=0) {
					cg.update(barr,c);
				}
			} else {
				byte barr[];
				if (StringUtils.isEmpty(getCharset())) {
					barr=message.asByteArray();
				} else {
					barr=message.asByteArray(getCharset());
				}
				cg.update(barr,barr.length);
			}
			result=cg.getResult();
			return new PipeRunResult(getForward(),result);
		} catch (Exception e) {
			throw new PipeRunException(this,"cannot calculate ["+getType()+"]"+(isInputIsFile()?" on file ["+message+"]":" using charset ["+getCharset()+"]"),e);
		}
	}

}