Class BaseMetricsImpl

java.lang.Object
org.refcodes.codec.BaseMetricsImpl
All Implemented Interfaces:
BaseMetrics, org.refcodes.mixin.CharSetAccessor, org.refcodes.numerical.NumberBaseAccessor, org.refcodes.numerical.PaddingCharAccessor

public class BaseMetricsImpl extends Object implements BaseMetrics
BaseMetrics implementation for playing around with your own configuration. You may use a template as one provided by BaseMetricsConfig and tweak some attributes as you wish.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.refcodes.mixin.CharSetAccessor

    org.refcodes.mixin.CharSetAccessor.CharSetBuilder<B extends org.refcodes.mixin.CharSetAccessor.CharSetBuilder<B>>, org.refcodes.mixin.CharSetAccessor.CharSetMutator, org.refcodes.mixin.CharSetAccessor.CharSetProperty

    Nested classes/interfaces inherited from interface org.refcodes.numerical.NumberBaseAccessor

    org.refcodes.numerical.NumberBaseAccessor.NumberBaseBuilder<B extends org.refcodes.numerical.NumberBaseAccessor.NumberBaseBuilder<B>>, org.refcodes.numerical.NumberBaseAccessor.NumberBaseMutator, org.refcodes.numerical.NumberBaseAccessor.NumberBaseProperty

    Nested classes/interfaces inherited from interface org.refcodes.numerical.PaddingCharAccessor

    org.refcodes.numerical.PaddingCharAccessor.PaddingCharBuilder<B extends org.refcodes.numerical.PaddingCharAccessor.PaddingCharBuilder<B>>, org.refcodes.numerical.PaddingCharAccessor.PaddingCharMutator, org.refcodes.numerical.PaddingCharAccessor.PaddingCharProperty
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseMetricsImpl(int aBase)
    Instantiates a new base metrics impl.
    BaseMetricsImpl(int aBase, char[] aCharSet)
    Instantiates a new base metrics impl.
    BaseMetricsImpl(int aBase, char[] aCharSet, char aPaddingChar)
    Instantiates a new base metrics impl.
    BaseMetricsImpl(int aBase, int aBitsPerDigit, int aDigitsPerByte, int aDigitsPerInt, int aBytesPerInt, char[] aCharSet)
    Instantiates a new base metrics impl.
    BaseMetricsImpl(int aBase, int aBitsPerDigit, int aDigitsPerByte, int aDigitsPerInt, int aBytesPerInt, char[] aCharSet, char aPaddingChar)
    Instantiates a new base metrics impl.
    Instantiates a new base metrics impl.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    int
    Number in bits for one digit.
    int
    Number of bytes to exactly fit into an encoded block.
    int
    Number of bytes to exactly store a minimum number of digits.
    char[]
    int
    The digit mask is the bit-field covering just the digit's bits (starting at bit 0).
    int
    Number of digits required to represent a byte.
    int
    Number of digits stored in an integer.
    int
    char
    int
    protected static int
    toBitsPerDigit(int aBase)
    To bits per digit.
    protected static int
    toBytesPerBlock(int aBitsPerDigit)
    Calculates the number of bytes which fully fit into a base encoded block.
    protected static int
    toBytesPerInt(int aBitsPerDigit)
    To bytes per int.
    char
    toChar(int aValue)
    Retrieves the (encoded) character for the (decoded) value.
    protected static int
    toDigitMask(int aBitsPerDigit)
    To digit mask.
    protected static int
    toDigitsPerByte(int aBase)
    To digits per byte.
    protected static int
    toDigitsPerInt(int aBytesPerInt, int aBitsPerDigit)
    To digits per int.
    int
    toValue(char aChar)
    Retrieves the (decoded) value for the (encoded) character.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.refcodes.codec.BaseMetrics

    getDigitsPerBlock, toPaddingChars, toPaddingCharsNumber
  • Constructor Details

    • BaseMetricsImpl

      public BaseMetricsImpl(int aBase)
      Instantiates a new base metrics impl.
      Parameters:
      aBase - the base
    • BaseMetricsImpl

      public BaseMetricsImpl(int aBase, char[] aCharSet)
      Instantiates a new base metrics impl.
      Parameters:
      aBase - the base
      aCharSet - the char set
    • BaseMetricsImpl

      public BaseMetricsImpl(int aBase, char[] aCharSet, char aPaddingChar)
      Instantiates a new base metrics impl.
      Parameters:
      aBase - the base
      aCharSet - the char set
      aPaddingChar - the padding char
    • BaseMetricsImpl

      public BaseMetricsImpl(int aBase, int aBitsPerDigit, int aDigitsPerByte, int aDigitsPerInt, int aBytesPerInt, char[] aCharSet)
      Instantiates a new base metrics impl.
      Parameters:
      aBase - the base
      aBitsPerDigit - the bits per digit
      aDigitsPerByte - the digits per byte
      aDigitsPerInt - the digits per int
      aBytesPerInt - the bytes per int
      aCharSet - the char set
    • BaseMetricsImpl

      public BaseMetricsImpl(int aBase, int aBitsPerDigit, int aDigitsPerByte, int aDigitsPerInt, int aBytesPerInt, char[] aCharSet, char aPaddingChar)
      Instantiates a new base metrics impl.
      Parameters:
      aBase - the base
      aBitsPerDigit - the bits per digit
      aDigitsPerByte - the digits per byte
      aDigitsPerInt - the digits per int
      aBytesPerInt - the bytes per int
      aCharSet - the char set
      aPaddingChar - the padding char
    • BaseMetricsImpl

      public BaseMetricsImpl(BaseMetrics aBaseMetrics)
      Instantiates a new base metrics impl.
      Parameters:
      aBaseMetrics - the base metrics
  • Method Details

    • getNumberBase

      public int getNumberBase()
      Specified by:
      getNumberBase in interface org.refcodes.numerical.NumberBaseAccessor
    • getCharSet

      public char[] getCharSet()
      Specified by:
      getCharSet in interface BaseMetrics
      Specified by:
      getCharSet in interface org.refcodes.mixin.CharSetAccessor
    • getBytesPerInt

      public int getBytesPerInt()
      Number of bytes to exactly store a minimum number of digits.
      Specified by:
      getBytesPerInt in interface BaseMetrics
      Returns:
      the bytes per int
    • getBytesPerBlock

      public int getBytesPerBlock()
      Number of bytes to exactly fit into an encoded block.
      Specified by:
      getBytesPerBlock in interface BaseMetrics
      Returns:
      the bytes per block
    • getDigitsPerInt

      public int getDigitsPerInt()
      Number of digits stored in an integer.
      Specified by:
      getDigitsPerInt in interface BaseMetrics
      Returns:
      the digits per int
    • getBitsPerDigit

      public int getBitsPerDigit()
      Number in bits for one digit.
      Specified by:
      getBitsPerDigit in interface BaseMetrics
      Returns:
      the bits per digit
    • getDigitsPerByte

      public int getDigitsPerByte()
      Number of digits required to represent a byte.
      Specified by:
      getDigitsPerByte in interface BaseMetrics
      Returns:
      the digits per byte
    • getDigitMask

      public int getDigitMask()
      The digit mask is the bit-field covering just the digit's bits (starting at bit 0). Those bits in the mask are set to one which are required to represent a digit.
      Specified by:
      getDigitMask in interface BaseMetrics
      Returns:
      the digit mask
    • toValue

      public int toValue(char aChar)
      Retrieves the (decoded) value for the (encoded) character.
      Specified by:
      toValue in interface BaseMetrics
      Parameters:
      aChar - the char
      Returns:
      the int
    • toChar

      public char toChar(int aValue)
      Retrieves the (encoded) character for the (decoded) value.
      Specified by:
      toChar in interface BaseMetrics
      Parameters:
      aValue - the value
      Returns:
      the char
    • getPaddingChar

      public char getPaddingChar()
      Specified by:
      getPaddingChar in interface org.refcodes.numerical.PaddingCharAccessor
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDigitMask

      protected static int toDigitMask(int aBitsPerDigit)
      To digit mask.
      Parameters:
      aBitsPerDigit - the bits per digit
      Returns:
      the int
    • toBitsPerDigit

      protected static int toBitsPerDigit(int aBase)
      To bits per digit.
      Parameters:
      aBase - the base
      Returns:
      the int
    • toDigitsPerInt

      protected static int toDigitsPerInt(int aBytesPerInt, int aBitsPerDigit)
      To digits per int.
      Parameters:
      aBytesPerInt - the bytes per int
      aBitsPerDigit - the bits per digit
      Returns:
      the int
    • toDigitsPerByte

      protected static int toDigitsPerByte(int aBase)
      To digits per byte.
      Parameters:
      aBase - the base
      Returns:
      the int
    • toBytesPerInt

      protected static int toBytesPerInt(int aBitsPerDigit)
      To bytes per int.
      Parameters:
      aBitsPerDigit - the bits per digit
      Returns:
      the int
    • toBytesPerBlock

      protected static int toBytesPerBlock(int aBitsPerDigit)
      Calculates the number of bytes which fully fit into a base encoded block.
      Parameters:
      aBitsPerDigit - The bits used per digit.
      Returns:
      The number of bytes completely fitting into one block.