Class BaseConverterBuilder

    • Constructor Detail

      • BaseConverterBuilder

        public BaseConverterBuilder()
        Instantiates a new base converter builder impl.
    • Method Detail

      • getCharSet

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

        public void setCharSet​(char[] aCharSet)
        Specified by:
        setCharSet in interface org.refcodes.mixin.CharSetAccessor.CharSetMutator
      • setNumberBase

        public void setNumberBase​(int aNumberBase)
        Sets the value for the number base property.
        Specified by:
        setNumberBase in interface NumberBaseAccessor.NumberBaseMutator
        Parameters:
        aNumberBase - The value to be stored by the number base property.
      • getNumberBase

        public int getNumberBase()
        Retrieves the value from the number base property.
        Specified by:
        getNumberBase in interface NumberBaseAccessor
        Returns:
        The name stored by the number base property.
      • toNumberBaseValue

        public String toNumberBaseValue​(long aNumber)
        Retrieves the number base value calculated from the number. This method is to be side effect free in terms of the number (and the encoded result) is not part of the state for this instance (from the point of view of this method). For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination of withNumberData(byte[]) with getNumberBaseValue()
        Parameters:
        aNumber - The number to be encoded.
        Returns:
        The number base value calculated from the number.
      • getNumber

        public long getNumber()
        Retrieves the number from the number property.
        Returns:
        The number stored by the number property.
      • toNumber

        public long toNumber​(String aNumberBaseValue)
                      throws IllegalArgumentException
        Retrieves the number calculated from the provided number base value. This method is to be side effect free in terms of the number base value (and the decoded result) is not part of the state for this instance (from the point of view of this method). For avoiding thread race conditions / side effects regarding the encoded text (and the decoded result), use this method instead of the combination of withNumberBaseValue(String) with getNumberData().
        Parameters:
        aNumberBaseValue - The number base value to be decoded.
        Returns:
        The number decoded from the number base value.
        Throws:
        IllegalArgumentException - the illegal argument exception
      • setNumber

        public void setNumber​(long aNumber)
        Sets the number for the number property.
        Parameters:
        aNumber - The number to be stored by the number property.
      • getNumberBaseValue

        public String getNumberBaseValue()
        Retrieves the number base value from the number base value property.
        Returns:
        The number base value stored by the number base value property.
      • setNumberBaseValue

        public void setNumberBaseValue​(String aNumberBaseValue)
        Sets the number base value for the number base value property.
        Parameters:
        aNumberBaseValue - The number base value to be stored by the number base value property.
      • getNumberData

        public byte[] getNumberData()
        Retrieves the number from the number property.
        Returns:
        The number stored by the number property.
      • setNumberData

        public void setNumberData​(byte[] aNumberData)
        Sets the number for the number property.
        Parameters:
        aNumberData - The number to be stored by the number property.
      • toNumberBaseValue

        public String toNumberBaseValue​(byte[] aNumberData)
        Retrieves the number base value calculated from the number. This method is to be side effect free in terms of the number (and the encoded result) is not part of the state for this instance (from the point of view of this method). For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination of withNumberData(byte[]) with getNumberBaseValue()
        Parameters:
        aNumberData - The number to be encoded.
        Returns:
        The number base value calculated from the number.
      • toNumberData

        public byte[] toNumberData​(String aNumberBaseValue)
        Retrieves the number calculated from the provided number base value. This method is to be side effect free in terms of the number base value (and the decoded result) is not part of the state for this instance (from the point of view of this method). For avoiding thread race conditions / side effects regarding the encoded text (and the decoded result), use this method instead of the combination of withNumberBaseValue(String) with getNumberData().
        Parameters:
        aNumberBaseValue - The number base value to be decoded.
        Returns:
        The number decoded from the number base value.
        Throws:
        NumberFormatException - the number format exception
      • withNumberBaseValue

        public BaseConverterBuilder withNumberBaseValue​(String aNumberBaseValue)
        Sets the number base value for the number base value property.
        Parameters:
        aNumberBaseValue - The number base value to be stored by the number base value property.
        Returns:
        The builder for applying multiple build operations.
      • withNumberData

        public BaseConverterBuilder withNumberData​(byte[] aNumberData)
        Sets the number for the number property.
        Parameters:
        aNumberData - The number to be stored by the number property.
        Returns:
        The builder for applying multiple build operations.
      • withNumber

        public BaseConverterBuilder withNumber​(long aNumber)
        Sets the number for the number property.
        Parameters:
        aNumber - The number to be stored by the number property.
        Returns:
        The builder for applying multiple build operations.
      • asEncoded

        public static String asEncoded​(byte[] aData,
                                       int aNumberBase,
                                       char... aCharSet)
        Encodes the given bytes to a String as of the given number base and the charset for the value's digits.
        Parameters:
        aData - The data to be encoded.
        aNumberBase - The number base to be used for encoding.
        aCharSet - The charset to be used for the digits of the targeted number base.
        Returns:
        Returns the accordingly encoded data as a String.
      • asDecoded

        public static byte[] asDecoded​(String aEncodedData,
                                       int aNumberBase,
                                       char... aCharSet)
        Decodes the given (number base encoded) data to a byte array as of the given number base and the charset for the value's digits.
        Parameters:
        aEncodedData - The (number base encoded) data to be decoded.
        aNumberBase - The number base to be used for decoding.
        aCharSet - The charset to be used for the digits of the used number base.
        Returns:
        Returns the accordingly decoded data .
      • asVerboseString

        protected static String asVerboseString​(byte[] aBytes)