org.jnetpcap.nio
Class JNumber

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JNumber

public class JNumber
extends JMemory

A peered number pointer class that stores and retrieves number values from native/direct memory locations. This class facilitates exchange of number values (from bytes to doubles) to various native functions. The key being that these numbers at JNI level can be passed in as pointers and thus allows natives methods to both send and receive values between native and java space. The methods are named similarly like java.lang.Number class, with the exception of existance of setter methods.

Typical usage for JNumber is to use it wherever a function requests a primitive type pointer.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class JNumber.Type
          Used to request a specific type of primitive that this number will be dealing with possibly allocating memory more efficiently to fit the primitive type.
 
Field Summary
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME
 
Constructor Summary
JNumber()
           
JNumber(JMemory.Type type)
          Creates a number pointer, which does not allocate any memory on its own, but needs to be peered with primitive pointer.
JNumber(JNumber.Type type)
          Allocates a number of the specified size and type.
 
Method Summary
 byte byteValue()
           
 void byteValue(byte value)
           
 double doubleValue()
           
 void doubleValue(double value)
           
 float floatValue()
           
 void floatValue(float value)
           
 int intValue()
           
 void intValue(int value)
           
 long longValue()
           
 void longValue(long value)
           
 int peer(JBuffer buffer)
           
 int peer(JBuffer buffer, int offset)
           
 int peer(JNumber number)
           
 short shortValue()
           
 void shortValue(short value)
           
 int transferFrom(java.nio.ByteBuffer peer)
          Copies data from memory from direct byte buffer to this memory
 
Methods inherited from class org.jnetpcap.nio.JMemory
check, cleanup, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, peer, peer, setSize, size, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNumber

public JNumber()

JNumber

public JNumber(JNumber.Type type)
Allocates a number of the specified size and type.

Parameters:
type - primitive type for which to allocate memory

JNumber

public JNumber(JMemory.Type type)
Creates a number pointer, which does not allocate any memory on its own, but needs to be peered with primitive pointer.

Method Detail

intValue

public int intValue()

intValue

public void intValue(int value)

byteValue

public byte byteValue()

byteValue

public void byteValue(byte value)

shortValue

public short shortValue()

shortValue

public void shortValue(short value)

longValue

public long longValue()

longValue

public void longValue(long value)

floatValue

public float floatValue()

floatValue

public void floatValue(float value)

doubleValue

public double doubleValue()

doubleValue

public void doubleValue(double value)

peer

public int peer(JNumber number)

peer

public int peer(JBuffer buffer)

peer

public int peer(JBuffer buffer,
                int offset)

transferFrom

public int transferFrom(java.nio.ByteBuffer peer)
Description copied from class: JMemory
Copies data from memory from direct byte buffer to this memory

Overrides:
transferFrom in class JMemory
Parameters:
peer - source buffer
Returns:
actual number of bytes that was copied