java.lang.Object
org.refcodes.codec.BaseBuilder
- All Implemented Interfaces:
BaseMetricsAccessor
,BaseMetricsAccessor.BaseMetricsBuilder<BaseBuilder>
,BaseMetricsAccessor.BaseMetricsMutator
,BaseMetricsAccessor.BaseMetricsProperty
public class BaseBuilder
extends Object
implements BaseMetricsAccessor.BaseMetricsProperty, BaseMetricsAccessor.BaseMetricsBuilder<BaseBuilder>
The
BaseBuilder
provides the functionality to do base encoding and
decoding such as done by the Base64 encoding and decoding functionality (see
"https://en.wikipedia.org/wiki/Base64"). The BaseBuilder
makes use of
the utility-Builder-Pattern and is designed to support codes starting with
Base2 till Base64 and further up.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.codec.BaseMetricsAccessor
BaseMetricsAccessor.BaseMetricsBuilder<B extends BaseMetricsAccessor.BaseMetricsBuilder<B>>, BaseMetricsAccessor.BaseMetricsMutator, BaseMetricsAccessor.BaseMetricsProperty
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves the base codec metrics from the base codec metrics property.byte[]
Retrieves the decoded data from the decoded data property.Retrieves the encoded text from the encoded text property.void
setBaseMetrics
(int aNumberBase) Sets the number base for the number base property.void
setBaseMetrics
(BaseMetrics aBaseMetrics) Sets the base codec metrics for the base codec metrics property.void
setDecodedData
(byte[] aDecodedData) Sets the decoded data for the decoded data property.void
setDecodedData
(long aDecodedData) Sets the decoded data for the decoded data property.void
setDecodedData
(String aDecodedData) Sets the decoded data for the decoded data property.void
setDecodedData
(String aDecodedData, String aCharset) Sets the decoded data for the decoded data property.void
setDecodedData
(String aDecodedData, Charset aCharset) Sets the decoded data for the decoded data property.void
setEncodedText
(String aEncodedText) Sets the encoded text for the encoded text property.protected static int
toBytes
(byte[] aDecodedBytes, int aOffset, int aWord, int aTrailingBytes, BaseMetrics aBaseMetrics) To bytes.byte[]
toDecodedData
(String aEncodedText) Retrieves the decoded data calculated from the provided encoded text.protected static byte[]
toDecodedData
(String aEncodedText, BaseMetrics aBaseMetrics) To decoded data.protected static int
toDecodedSize
(String aEncodedText, BaseMetrics aBaseMetrics) To decoded size.toEncodedText
(byte[] aDecodedData) Retrieves the encoded text calculated from the decoded data.protected static String
toEncodedText
(byte[] aDecodedData, BaseMetrics aBaseMetrics) To encoded text.toEncodedText
(long aDecodedData) Retrieves the encoded text calculated from the decoded data.toEncodedText
(String aDecodedData) Retrieves the encoded text calculated from the decoded data.toEncodedText
(String aDecodedData, String aCharset) Retrieves the encoded text calculated from the decoded data.toEncodedText
(String aDecodedData, Charset aCharset) Retrieves the encoded text calculated from the decoded data.withBaseMetrics
(int aNumberBase) Sets the number base for the number base property.withBaseMetrics
(BaseMetrics aBaseMetricsCodec) Sets the base codec metrics for the base codec metrics property.withDecodedData
(byte[] aDecodedData) Sets the decoded data for the decoded data property.withDecodedData
(long aDecodedData) Sets the decoded data for the decoded data property.withDecodedData
(String aDecodedData) Sets the decoded data for the decoded data property.withDecodedData
(String aDecodedData, String aCharset) Sets the decoded data for the decoded data property.withDecodedData
(String aDecodedData, Charset aCharset) Sets the decoded data for the decoded data property.withEncodedText
(String aEncodedText) Sets the encoded text for the encoded text property.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.codec.BaseMetricsAccessor.BaseMetricsProperty
letBaseMetrics
-
Constructor Details
-
BaseBuilder
public BaseBuilder()
-
-
Method Details
-
withBaseMetrics
Sets the base codec metrics for the base codec metrics property.- Specified by:
withBaseMetrics
in interfaceBaseMetricsAccessor.BaseMetricsBuilder<BaseBuilder>
- Parameters:
aBaseMetricsCodec
- The base codec metrics to be stored by the font style property.- Returns:
- The builder for applying multiple build operations.
-
setBaseMetrics
public void setBaseMetrics(int aNumberBase) Sets the number base for the number base property.- Parameters:
aNumberBase
- The number base to be stored by the base codec metrics property.
-
withBaseMetrics
Sets the number base for the number base property.- Parameters:
aNumberBase
- The number base to be stored by the base codec metrics property.- Returns:
- The builder for applying multiple build operations.
-
toEncodedText
Retrieves the encoded text calculated from the decoded data. This method is to be side effect free in terms of the decoded data (and the encoded result) is not part of the state for this instance (from the point of view of this method). Still changing for example theBaseMetrics
viawithBaseMetrics(BaseMetrics)
can cause side effects! For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination ofwithDecodedData(byte[])
withgetEncodedText()
- Parameters:
aDecodedData
- The decoded data to be encoded.- Returns:
- The encoded text calculated from the decoded data.
-
toEncodedText
Retrieves the encoded text calculated from the decoded data. This method is to be side effect free in terms of the decoded data (and the encoded result) is not part of the state for this instance (from the point of view of this method). Still changing for example theBaseMetrics
viawithBaseMetrics(BaseMetrics)
can cause side effects! For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination ofwithDecodedData(byte[])
withgetEncodedText()
- Parameters:
aDecodedData
- The decoded data to be encoded.aCharset
- The charset to use when interpreting the decoded data string.- Returns:
- The encoded text calculated from the decoded data.
-
toEncodedText
public String toEncodedText(String aDecodedData, String aCharset) throws UnsupportedEncodingException Retrieves the encoded text calculated from the decoded data. This method is to be side effect free in terms of the decoded data (and the encoded result) is not part of the state for this instance (from the point of view of this method). Still changing for example theBaseMetrics
viawithBaseMetrics(BaseMetrics)
can cause side effects! For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination ofwithDecodedData(byte[])
withgetEncodedText()
- Parameters:
aDecodedData
- The decoded data to be encoded.aCharset
- The charset to use when interpreting the decoded data string.- Returns:
- The encoded text calculated from the decoded data.
- Throws:
UnsupportedEncodingException
- thrown in case the provided charset name is not supported.
-
setDecodedData
Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.
-
setDecodedData
Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.aCharset
- The charset to use when interpreting the decoded data string.
-
setDecodedData
public void setDecodedData(String aDecodedData, String aCharset) throws UnsupportedEncodingException Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.aCharset
- The charset to use when interpreting the decoded data string.- Throws:
UnsupportedEncodingException
- thrown in case the provided charset name is not supported.
-
withDecodedData
Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.- Returns:
- The builder for applying multiple build operations.
-
withDecodedData
Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.- Returns:
- The builder for applying multiple build operations.
-
withDecodedData
Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.aCharset
- The charset to use when interpreting the decoded data string.- Returns:
- The builder for applying multiple build operations.
-
withDecodedData
public BaseBuilder withDecodedData(String aDecodedData, String aCharset) throws UnsupportedEncodingException Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.aCharset
- The charset to use when interpreting the decoded data string.- Returns:
- The builder for applying multiple build operations.
- Throws:
UnsupportedEncodingException
- thrown in case the provided charset name is not supported.
-
withDecodedData
Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.- Returns:
- The builder for applying multiple build operations.
-
getBaseMetrics
Retrieves the base codec metrics from the base codec metrics property.- Specified by:
getBaseMetrics
in interfaceBaseMetricsAccessor
- Returns:
- The base codec metrics stored by the base codec metrics property.
-
setBaseMetrics
Sets the base codec metrics for the base codec metrics property.- Specified by:
setBaseMetrics
in interfaceBaseMetricsAccessor.BaseMetricsMutator
- Parameters:
aBaseMetrics
- The base codec metrics to be stored by the font style property.
-
getEncodedText
Retrieves the encoded text from the encoded text property.- Returns:
- The encoded text stored by the encoded text property.
-
setEncodedText
Sets the encoded text for the encoded text property.- Parameters:
aEncodedText
- The encoded text to be stored by the encoded text property.
-
withEncodedText
Sets the encoded text for the encoded text property.- Parameters:
aEncodedText
- The encoded text to be stored by the encoded text property.- Returns:
- The builder for applying multiple build operations.
-
getDecodedData
public byte[] getDecodedData()Retrieves the decoded data from the decoded data property.- Returns:
- The decoded data stored by the decoded data property.
-
setDecodedData
public void setDecodedData(byte[] aDecodedData) Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.
-
setDecodedData
public void setDecodedData(long aDecodedData) Sets the decoded data for the decoded data property.- Parameters:
aDecodedData
- The decoded data to be stored by the decoded data property.
-
toEncodedText
Retrieves the encoded text calculated from the decoded data. This method is to be side effect free in terms of the decoded data (and the encoded result) is not part of the state for this instance (from the point of view of this method). Still changing for example theBaseMetrics
viawithBaseMetrics(BaseMetrics)
can cause side effects! For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination ofwithDecodedData(byte[])
withgetEncodedText()
- Parameters:
aDecodedData
- The decoded data to be encoded.- Returns:
- The encoded text calculated from the decoded data.
-
toDecodedData
Retrieves the decoded data calculated from the provided encoded text. This method is to be side effect free in terms of the encoded text (and the decoded result) is not part of the state for this instance (from the point of view of this method). Still changing for example theBaseMetrics
viawithBaseMetrics(BaseMetrics)
can cause side effects! For avoiding thread race conditions / side effects regarding the encoded text (and the decoded result), use this method instead of the combination ofwithEncodedText(String)
withgetDecodedData()
.- Parameters:
aEncodedText
- The encoded text to be decoded.- Returns:
- The decoded data decoded from the encoded text.
-
toEncodedText
Retrieves the encoded text calculated from the decoded data. This method is to be side effect free in terms of the decoded data (and the encoded result) is not part of the state for this instance (from the point of view of this method). Still changing for example theBaseMetrics
viawithBaseMetrics(BaseMetrics)
can cause side effects! For avoiding thread race conditions / side effects regarding the decoded data (and the encoded result), use this method instead of the combination ofwithDecodedData(byte[])
withgetEncodedText()
- Parameters:
aDecodedData
- The decoded data to be encoded.- Returns:
- The encoded text calculated from the decoded data.
-
toEncodedText
To encoded text.- Parameters:
aDecodedData
- the decoded dataaBaseMetrics
- the base metrics- Returns:
- the string
-
toDecodedData
To decoded data.- Parameters:
aEncodedText
- the encoded textaBaseMetrics
- the base metrics- Returns:
- the byte[]
-
toDecodedSize
To decoded size.- Parameters:
aEncodedText
- the encoded textaBaseMetrics
- the base metrics- Returns:
- the int
-
toBytes
protected static int toBytes(byte[] aDecodedBytes, int aOffset, int aWord, int aTrailingBytes, BaseMetrics aBaseMetrics) To bytes.- Parameters:
aDecodedBytes
- the decoded bytesaOffset
- the offsetaWord
- the wordaTrailingBytes
- the trailing bytesaBaseMetrics
- the base metrics- Returns:
- the int
-