jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Classes | Static Public Member Functions | List of all members
org.jau.util.BaseCodec Class Reference

Base codecs, i.e. More...

Collaboration diagram for org.jau.util.BaseCodec:

Classes

class  Alphabet
 Base Alphabet Specification providing the alphabet for encode() and decode(). More...
 
class  Ascii38Alphabet
 Safe base 38 alphabet with ASCII code-point sorting order. More...
 
class  Ascii64Alphabet
 Safe base 64 alphabet with ASCII code-point sorting order. More...
 
class  Ascii86Alphabet
 Base 86 alphabet with ASCII code-point sorting order. More...
 
class  Base64Alphabet
 Safe canonical base64 alphabet, without ASCII code-point sorting order. More...
 
class  Base64urlAlphabet
 Safe canonical base64url alphabet, without ASCII code-point sorting order. More...
 
class  Natural64Alphabet
 Safe natural base 64 alphabet, both without ASCII code-point sorting order. More...
 
class  Natural86Alphabet
 Natural base 86 alphabet, without ASCII code-point sorting order. More...
 

Static Public Member Functions

static String encode (int num, final Alphabet aspec, final int min_width)
 Encodes a given positive decimal number to a symbolic string representing a given alphabet and its base. More...
 
static String encode (long num, final Alphabet aspec, final int min_width)
 Encodes a given positive decimal number to a symbolic string representing given alphabet and its base. More...
 
static String encode (final int num, final Alphabet aspec)
 Encodes a given positive decimal number to a symbolic string representing a given alphabet and its base. More...
 
static String encode (final long num, final Alphabet aspec)
 Encodes a given positive decimal number to a symbolic string representing a given alphabet and its base. More...
 
static long decode (final String str, final Alphabet aspec)
 Decodes a given symbolic string representing a given alphabet and its base to a positive decimal number. More...
 
static StringBuilder encode64 (final byte[] in_octets, int in_pos, int in_len, final Alphabet aspec)
 Encodes given octets using the given alphabet and fixed base 64 encoding according to base64 RFC 4648. More...
 
static ByteBuffer decode64 (final String in_code, final Alphabet aspec)
 Decodes a given symbolic string representing using given alphabet and fixed base 64 to octets according to base64 RFC 4648. More...
 
static int insert_lf (final StringBuilder str, final int period)
 Inserts a line feed (LF) character \n (ASCII 0x0a) after every period of characters. More...
 
static int remove_lf (final StringBuilder str)
 Removes line feed character from str. More...
 
static StringBuilder encode64_pem (final byte[] in_octets, final int in_pos, final int in_len, final Alphabet aspec)
 Encodes given octets using the given alphabet and fixed base 64 encoding according to base64 RFC 4648 and adds line-feeds every 64 characters as required for PEM. More...
 
static StringBuilder encode64_mime (final byte[] in_octets, final int in_pos, final int in_len, final Alphabet aspec)
 Encodes given octets using the given alphabet and fixed base 64 encoding according to base64 RFC 4648 and adds line-feeds every 76 characters as required for MIME. More...
 
static ByteBuffer decode64_lf (final String str, final Alphabet aspec)
 Decodes a given symbolic string representing using given alphabet and fixed base 64 to octets according to base64 RFC 4648 and removes all linefeeds before decoding as required for PEM and MIME. More...
 
static ByteBuffer decode64_lf (final StringBuilder str, final Alphabet aspec)
 Decodes a given symbolic string representing using given alphabet and fixed base 64 to octets according to base64 RFC 4648 and removes all linefeeds before decoding as required for PEM and MIME. More...
 

Detailed Description

Base codecs, i.e.

changing the decimal or binary values' base for a different representation.

Definition at line 31 of file BaseCodec.java.

Member Function Documentation

◆ decode()

static long org.jau.util.BaseCodec.decode ( final String  str,
final Alphabet  aspec 
)
static

Decodes a given symbolic string representing a given alphabet and its base to a positive decimal number.

Besides using a custom alphabet, the following build-in alphabets are provided

Parameters
stran encoded string
aspecthe used alphabet specification
Returns
the decoded radix decimal value or -1 if base exceeds Alphabet.max_base(), unknown code-point or invalid arguments
See also
BaseCodec#encode(int, int, Alphabet, int)
BaseCodec#encode(long, int, Alphabet, int)

Definition at line 573 of file BaseCodec.java.

Here is the call graph for this function:

◆ decode64()

static ByteBuffer org.jau.util.BaseCodec.decode64 ( final String  in_code,
final Alphabet  aspec 
)
static

Decodes a given symbolic string representing using given alphabet and fixed base 64 to octets according to base64 RFC 4648.

An error only occurs if the encoded string length > 0 and resulting decoded octets size is empty.

Parameters
in_codeencoded string
aspecthe used base 64 alphabet specification
Returns
the decoded octets, empty if base exceeds alphabet::max_base(), unknown code-point or invalid arguments

Definition at line 663 of file BaseCodec.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode64_lf() [1/2]

static ByteBuffer org.jau.util.BaseCodec.decode64_lf ( final String  str,
final Alphabet  aspec 
)
static

Decodes a given symbolic string representing using given alphabet and fixed base 64 to octets according to base64 RFC 4648 and removes all linefeeds before decoding as required for PEM and MIME.

An error only occurs if the encoded string length > 0 and resulting decoded octets size is empty.

Parameters
strand encoded string, will be copied
aspecthe used base 64 alphabet specification
Returns
the decoded octets, empty if base exceeds alphabet::max_base(), unknown code-point or invalid arguments

Definition at line 814 of file BaseCodec.java.

Here is the call graph for this function:

◆ decode64_lf() [2/2]

static ByteBuffer org.jau.util.BaseCodec.decode64_lf ( final StringBuilder  str,
final Alphabet  aspec 
)
static

Decodes a given symbolic string representing using given alphabet and fixed base 64 to octets according to base64 RFC 4648 and removes all linefeeds before decoding as required for PEM and MIME.

An error only occurs if the encoded string length > 0 and resulting decoded octets size is empty.

Parameters
strand encoded string, no copy, will be mutated
aspecthe used base 64 alphabet specification
Returns
the decoded octets, empty if base exceeds alphabet::max_base(), unknown code-point or invalid arguments

Definition at line 831 of file BaseCodec.java.

Here is the call graph for this function:

◆ encode() [1/4]

static String org.jau.util.BaseCodec.encode ( final int  num,
final Alphabet  aspec 
)
static

Encodes a given positive decimal number to a symbolic string representing a given alphabet and its base.

Besides using a custom alphabet, the following build-in alphabets are provided

Parameters
numa positive decimal number
aspecthe used alphabet specification
Returns
the encoded string or an empty string if base exceeds Alphabet.max_base() or invalid arguments
See also
BaseCodec#encode(int, int, Alphabet, int)
BaseCodec#decode(String, int, Alphabet)

Definition at line 531 of file BaseCodec.java.

Here is the call graph for this function:

◆ encode() [2/4]

static String org.jau.util.BaseCodec.encode ( final long  num,
final Alphabet  aspec 
)
static

Encodes a given positive decimal number to a symbolic string representing a given alphabet and its base.

Besides using a custom alphabet, the following build-in alphabets are provided

Parameters
numa positive decimal number
aspecthe used alphabet specification
Returns
the encoded string or an empty string if base exceeds Alphabet.max_base() or invalid arguments
See also
BaseCodec#encode(long, int, Alphabet, int)
BaseCodec#decode(String, int, Alphabet)

Definition at line 552 of file BaseCodec.java.

Here is the call graph for this function:

◆ encode() [3/4]

static String org.jau.util.BaseCodec.encode ( int  num,
final Alphabet  aspec,
final int  min_width 
)
static

Encodes a given positive decimal number to a symbolic string representing a given alphabet and its base.

Besides using a custom alphabet, the following build-in alphabets are provided

Parameters
numa positive decimal number
aspecthe used alphabet specification
min_widthminimum width of the encoded string, encoded zero is used for padding
Returns
the encoded string or an empty string if base exceeds Alphabet.max_base() or invalid arguments
See also
BaseCodec#encode(long, int, Alphabet, int)
BaseCodec#decode(String, int, Alphabet)

Definition at line 460 of file BaseCodec.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode() [4/4]

static String org.jau.util.BaseCodec.encode ( long  num,
final Alphabet  aspec,
final int  min_width 
)
static

Encodes a given positive decimal number to a symbolic string representing given alphabet and its base.

Besides using a custom alphabet, the following build-in alphabets are provided

Parameters
numa positive decimal number
aspecthe used alphabet specification
min_widthminimum width of the encoded string, encoded zero is used for padding
Returns
the encoded string or an empty string if base exceeds Alphabet.max_base() or invalid arguments
See also
BaseCodec#encode(int, int, Alphabet, int)
BaseCodec#decode(String, int, Alphabet)

Definition at line 496 of file BaseCodec.java.

Here is the call graph for this function:

◆ encode64()

static StringBuilder org.jau.util.BaseCodec.encode64 ( final byte[]  in_octets,
int  in_pos,
int  in_len,
final Alphabet  aspec 
)
static

Encodes given octets using the given alphabet and fixed base 64 encoding according to base64 RFC 4648.

An error only occurs if in_len > 0 and resulting encoded string is empty.

Parameters
in_octetssource byte array
in_posindex to octets start
in_lenlength of octets in bytes
aspecthe used base 64 alphabet specification
Returns
the encoded string, empty if base exceeds alphabet::max_base() or invalid arguments

Definition at line 604 of file BaseCodec.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode64_mime()

static StringBuilder org.jau.util.BaseCodec.encode64_mime ( final byte[]  in_octets,
final int  in_pos,
final int  in_len,
final Alphabet  aspec 
)
static

Encodes given octets using the given alphabet and fixed base 64 encoding according to base64 RFC 4648 and adds line-feeds every 76 characters as required for MIME.

An error only occurs if in_len > 0 and resulting encoded string is empty.

Parameters
in_octetspointer to octets start
in_lenlength of octets in bytes
aspecthe used base 64 alphabet specification
Returns
the encoded string, empty if base exceeds alphabet::max_base() or invalid arguments

Definition at line 797 of file BaseCodec.java.

Here is the call graph for this function:

◆ encode64_pem()

static StringBuilder org.jau.util.BaseCodec.encode64_pem ( final byte[]  in_octets,
final int  in_pos,
final int  in_len,
final Alphabet  aspec 
)
static

Encodes given octets using the given alphabet and fixed base 64 encoding according to base64 RFC 4648 and adds line-feeds every 64 characters as required for PEM.

An error only occurs if in_len > 0 and resulting encoded string is empty.

Parameters
in_octetspointer to octets start
in_lenlength of octets in bytes
aspecthe used alphabet specification
Returns
the encoded string, empty if base exceeds alphabet::max_base() or invalid arguments

Definition at line 779 of file BaseCodec.java.

Here is the call graph for this function:

◆ insert_lf()

static int org.jau.util.BaseCodec.insert_lf ( final StringBuilder  str,
final int  period 
)
static

Inserts a line feed (LF) character \n (ASCII 0x0a) after every period of characters.

Parameters
strthe input string of characters, which will be mutated.
periodperiod of characters after which one LF will be inserted.
Returns
count of inserted LF characters

Definition at line 740 of file BaseCodec.java.

Here is the caller graph for this function:

◆ remove_lf()

static int org.jau.util.BaseCodec.remove_lf ( final StringBuilder  str)
static

Removes line feed character from str.

Parameters
strthe input string of characters, which will be mutated.
Returns
count of removed LF characters

Definition at line 755 of file BaseCodec.java.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: