|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.mdr.persistence.btreeimpl.btreeindex; import org.netbeans.mdr.persistence.btreeimpl.btreestorage.*; /* for Converter */ /** * EntryTypeInfo implementation for integer data. */ public class IntInfo extends EntryTypeInfo { public String typeName() { return "Integer"; } /** * Store an integer in a byte array * * @param i Integer to be stored * * @return byte array containing the integer */ public byte[] toBuffer(Object i) { byte[] buffer = new byte[4]; if (!(i instanceof Integer)) { return null; } Converter.writeInt(buffer, 0, ((Integer) i).intValue()); return buffer; } /** * Reads an integer from a byte array * * @param buffer byte array containing an integer * * @return new Integer containing the value read from the byte array */ public Object fromBuffer(byte[] buffer) { return new Integer(Converter.readInt(buffer, 0)); } /** * Returns an int read from the 4 bytes starting at the location * passed in. * */ public int fromBuffer(byte[] buffer, int offset) { return Converter.readInt(buffer, offset); } /** * Compares two integers stored in byte arrays * * @param key1Buffer byte array containing integer search key * @param key2Buffer byte array containing integer target key * @param offset offset into key2Buffer of target key * @param length should always be 4 * * @return Returns one of: * |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.