org.xith3d.utility.characters
Class CharIndex

java.lang.Object
  extended by org.xith3d.utility.characters.CharIndex

public abstract class CharIndex
extends java.lang.Object

Provides methods to get information about printable characters. Any printable character is assotiated with an index to be used in an array of the size [total number of printable chars].


Nested Class Summary
static class CharIndex.MemoryStrategy
          For expressing values within the MemoryStrategy: p is the number of printable characters a is the number of all possible characters
 
Constructor Summary
protected CharIndex()
           
 
Method Summary
static CharIndex createBinSearchOptimizedCharIndex()
          Creates a search-optimized CharIndex.
static CharIndex createBinSearchOptimizedCharIndex(java.nio.charset.Charset charset)
          Creates a search-optimized CharIndex.
static CharIndex createBinSearchOptimizedCharIndex(java.lang.String charset)
          Creates a search-optimized CharIndex.
static CharIndex createBitSetOptimizedCharIndex()
          Creates a BitSet-optimized CharIndex.
static CharIndex createBitSetOptimizedCharIndex(java.nio.charset.Charset charset)
          Creates a BitSet-optimized CharIndex.
static CharIndex createBitSetOptimizedCharIndex(java.lang.String charset)
          Creates a BitSet-optimized CharIndex.
static CharIndex createGCOptimizedCharIndex()
          Creates a GC-optimized CharIndex.
static CharIndex createGCOptimizedCharIndex(java.nio.charset.Charset charset)
          Creates a GC-optimized CharIndex.
static CharIndex createGCOptimizedCharIndex(java.lang.String charset)
          Creates a GC-optimized CharIndex.
static CharIndex createHashOptimizedCharIndex()
          Creates a hash-optimized CharIndex.
static CharIndex createHashOptimizedCharIndex(java.nio.charset.Charset charset)
          Creates a hash-optimized CharIndex.
static CharIndex createHashOptimizedCharIndex(java.lang.String charset)
          Creates a hash-optimized CharIndex.
static CharIndex createSpaceOptimizedCharIndex()
          Creates a space-optimized CharIndex.
static CharIndex createSpaceOptimizedCharIndex(java.nio.charset.Charset charset)
          Creates a space-optimized CharIndex.
static CharIndex createSpaceOptimizedCharIndex(java.lang.String charset)
          Creates a space-optimized CharIndex.
abstract  java.nio.charset.Charset getCharset()
           
abstract  int getIndex(char ch)
          If you want to allocate a smaller array [size: getNumberOfPrintableChars()], You can use the int returned by this method as the index in this array.
abstract  CharIndex.MemoryStrategy getMemoryStrategy()
           
abstract  int getNumberOfPrintableChars()
           
abstract  int getTotalNumberOfCharacters()
           
static boolean isPrintable(char ch)
          Simply determines, if the given char is printable without any optimizations.
static boolean isPrintable(char ch, java.nio.charset.Charset charset)
          Simply determines, if the given char is printable without any optimizations.
protected static boolean isPrintable(char ch, java.nio.charset.CharsetEncoder encoder, java.nio.CharBuffer charBuffer, java.nio.ByteBuffer byteBuffer)
           
static boolean isPrintable(char ch, java.lang.String charset)
          Simply determines, if the given char is printable without any optimizations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharIndex

protected CharIndex()
Method Detail

isPrintable

protected static boolean isPrintable(char ch,
                                     java.nio.charset.CharsetEncoder encoder,
                                     java.nio.CharBuffer charBuffer,
                                     java.nio.ByteBuffer byteBuffer)

isPrintable

public static boolean isPrintable(char ch,
                                  java.nio.charset.Charset charset)
Simply determines, if the given char is printable without any optimizations.

Parameters:
ch - the questionary char
charset - the Charset to use
Returns:
true, if the char is printable

isPrintable

public static boolean isPrintable(char ch,
                                  java.lang.String charset)
Simply determines, if the given char is printable without any optimizations.

Parameters:
ch - the questionary char
charset - the Charset to use
Returns:
true, if the char is printable

isPrintable

public static boolean isPrintable(char ch)
Simply determines, if the given char is printable without any optimizations.

Parameters:
ch - the questionary char
Returns:
true, if the char is printable

getMemoryStrategy

public abstract CharIndex.MemoryStrategy getMemoryStrategy()
Returns:
the MemoryStrategy used by this CharIndex

getCharset

public abstract java.nio.charset.Charset getCharset()
Returns:
the Charset used by this CharIndex

getTotalNumberOfCharacters

public abstract int getTotalNumberOfCharacters()
Returns:
the total number of chars, that is cared of.

getNumberOfPrintableChars

public abstract int getNumberOfPrintableChars()
Returns:
the number of printable chars in this CharIndex.

getIndex

public abstract int getIndex(char ch)
If you want to allocate a smaller array [size: getNumberOfPrintableChars()], You can use the int returned by this method as the index in this array.

Parameters:
ch - the questionary char
Returns:
the index in a smaller array
See Also:
getNumberOfPrintableChars()

createSpaceOptimizedCharIndex

public static CharIndex createSpaceOptimizedCharIndex(java.nio.charset.Charset charset)
Creates a space-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.SPACE_OPTIMIZED

createSpaceOptimizedCharIndex

public static CharIndex createSpaceOptimizedCharIndex(java.lang.String charset)
Creates a space-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.SPACE_OPTIMIZED

createSpaceOptimizedCharIndex

public static CharIndex createSpaceOptimizedCharIndex()
Creates a space-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.SPACE_OPTIMIZED

createBitSetOptimizedCharIndex

public static CharIndex createBitSetOptimizedCharIndex(java.nio.charset.Charset charset)
Creates a BitSet-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.BITSET_OPTIMIZED

createBitSetOptimizedCharIndex

public static CharIndex createBitSetOptimizedCharIndex(java.lang.String charset)
Creates a BitSet-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.BITSET_OPTIMIZED

createBitSetOptimizedCharIndex

public static CharIndex createBitSetOptimizedCharIndex()
Creates a BitSet-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.BITSET_OPTIMIZED

createGCOptimizedCharIndex

public static CharIndex createGCOptimizedCharIndex(java.nio.charset.Charset charset)
Creates a GC-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.GC_OPTIMIZED

createGCOptimizedCharIndex

public static CharIndex createGCOptimizedCharIndex(java.lang.String charset)
Creates a GC-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.GC_OPTIMIZED

createGCOptimizedCharIndex

public static CharIndex createGCOptimizedCharIndex()
Creates a GC-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.GC_OPTIMIZED

createHashOptimizedCharIndex

public static CharIndex createHashOptimizedCharIndex(java.nio.charset.Charset charset)
Creates a hash-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.HASH_OPTIMIZED

createHashOptimizedCharIndex

public static CharIndex createHashOptimizedCharIndex(java.lang.String charset)
Creates a hash-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.HASH_OPTIMIZED

createHashOptimizedCharIndex

public static CharIndex createHashOptimizedCharIndex()
Creates a hash-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.HASH_OPTIMIZED

createBinSearchOptimizedCharIndex

public static CharIndex createBinSearchOptimizedCharIndex(java.nio.charset.Charset charset)
Creates a search-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.BINSEARCH_OPTIMIZED

createBinSearchOptimizedCharIndex

public static CharIndex createBinSearchOptimizedCharIndex(java.lang.String charset)
Creates a search-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.BINSEARCH_OPTIMIZED

createBinSearchOptimizedCharIndex

public static CharIndex createBinSearchOptimizedCharIndex()
Creates a search-optimized CharIndex.

See Also:
CharIndex.MemoryStrategy.BINSEARCH_OPTIMIZED