001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 *
012 * $Id: DWord.java 29029 2008-01-14 18:38:14Z ldoguin $
013 */
014
015package org.nuxeo.ecm.core.io.impl;
016
017import java.nio.ByteBuffer;
018
019/**
020 * An 32 bit integer that can handle bit operations.
021 *
022 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
023 */
024public class DWord {
025
026    private final ByteBuffer bb = ByteBuffer.allocate(4);
027
028    public DWord() {
029    }
030
031    public DWord(int n) {
032        bb.putInt(n);
033    }
034
035    public DWord(byte[] bytes) {
036        bb.put(bytes);
037    }
038
039    public final void setInt(int n) {
040        bb.putInt(n);
041    }
042
043    public void setBytes(byte[] bytes) {
044        bb.put(bytes);
045    }
046
047    public final int getInt() {
048        return bb.getInt(0);
049    }
050
051    public byte[] getBytes() {
052        return bb.array();
053    }
054
055}