class LongValueToUnsignedIntValue implements TranslateFunction<LongValue, IntValue> {

	@Override
	public IntValue translate(LongValue value, IntValue reuse)
			throws Exception {
		if (reuse == null) {
			reuse = new IntValue();
		}

		long l = value.getValue();

		if (l < 0 || l >= (1L << 32)) {
			throw new IllegalArgumentException("Cannot cast long value " + value + " to integer.");
		} else {
			reuse.setValue((int)(l & 0xffffffffL));
		}

		return reuse;
	}

}