it.geosolutions.imageio.utilities
Class NumberToByteArray

Object
  extended by NumberToByteArray

public final class NumberToByteArray
extends Object

Utility Class used to convert numbers in byte array containing representation of each digit as byte. This will increase write performances. This code is an adaption/improvement over the code found at the following address http://etutorials.org/Programming/Java+performance+tuning/Chapter+5.+ Strings/5.3+Conversions+to+Strings/.

Author:
Daniele Romagnoli, GeoSolutions., Simone Giannecchini, GeoSolutions.

Field Summary
static byte[] DOT_ZERO
           
static byte[] DOUBLE_ZERO
           
static byte[] DOUBLE_ZERO0
           
static byte[] DOUBLE_ZERO2
           
static byte[] INFINITY
           
static byte[] MIN_VALUE
           
static byte[] MINUS_DOUBLE_ZERO
           
static byte[] NaN
           
static byte[] NEGATIVE_INFINITY
           
static byte[] POSITIVE_INFINITY
           
static byte[][] ZEROS
          Array containing byte arrays containing "zeros" The element at index N within this array contains a byte array of N zero.
 
Constructor Summary
NumberToByteArray()
           
 
Method Summary
 void append(FastByteArrayWrapper ba, double d)
           
 void append(FastByteArrayWrapper ba, int i)
           
static long getNthDigit(long l, int n)
          Retrieve the n-th digit of a specified number
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITY

public static final byte[] INFINITY

NaN

public static final byte[] NaN

NEGATIVE_INFINITY

public static final byte[] NEGATIVE_INFINITY

MIN_VALUE

public static final byte[] MIN_VALUE

POSITIVE_INFINITY

public static final byte[] POSITIVE_INFINITY

DOUBLE_ZERO

public static final byte[] DOUBLE_ZERO

MINUS_DOUBLE_ZERO

public static final byte[] MINUS_DOUBLE_ZERO

DOUBLE_ZERO2

public static final byte[] DOUBLE_ZERO2

DOUBLE_ZERO0

public static final byte[] DOUBLE_ZERO0

DOT_ZERO

public static final byte[] DOT_ZERO

ZEROS

public static final byte[][] ZEROS
Array containing byte arrays containing "zeros" The element at index N within this array contains a byte array of N zero.
As you can notice, at index 0 there is an empty array, while at index 1 there is a byte array containing representation for a single zero, at index 2 there is a byte array containing representation for 2 zeros and so on.

Constructor Detail

NumberToByteArray

public NumberToByteArray()
Method Detail

getNthDigit

public static long getNthDigit(long l,
                               int n)
Retrieve the n-th digit of a specified number

Parameters:
l - The number for which we need to find the n-th digit
n - the index of the required digit (1-based = first digit)
Returns:
the n-th digit of the specified number.

append

public void append(FastByteArrayWrapper ba,
                   double d)
            throws IOException
Throws:
IOException

append

public void append(FastByteArrayWrapper ba,
                   int i)
            throws IOException
Throws:
IOException


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.