Package me.ahoo.cosid.converter
Class RadixIdConverter
java.lang.Object
me.ahoo.cosid.converter.RadixIdConverter
- All Implemented Interfaces:
IdConverter
,Statistical
- Direct Known Subclasses:
Radix36IdConverter
,Radix62IdConverter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
Convert aString
type ID back to itslong
representation.asString
(long id) Convert along
type ID to itsString
representation.int
long
getMaxId()
static int
maxCharSize
(int radix, int bits) static int
offset
(char digitChar) stat()
Get statistical information about this converter.
-
Field Details
-
PAD_CHAR
public static final char PAD_CHAR- See Also:
-
-
Constructor Details
-
RadixIdConverter
protected RadixIdConverter(boolean padStart, int charSize)
-
-
Method Details
-
offset
public static int offset(char digitChar) -
maxCharSize
public static int maxCharSize(int radix, int bits) -
getCharSize
public int getCharSize() -
getMaxId
public long getMaxId() -
asString
Description copied from interface:IdConverter
Convert along
type ID to itsString
representation.This method transforms a numeric ID into a string format according to the specific conversion algorithm implemented by the converter. For example, a radix converter might convert the number 12345 to "3d7".
- Specified by:
asString
in interfaceIdConverter
- Parameters:
id
- Thelong
type ID to convert- Returns:
- The
String
representation of the ID
-
asLong
Description copied from interface:IdConverter
Convert aString
type ID back to itslong
representation.This method performs the reverse operation of
IdConverter.asString(long)
, transforming a string ID back into its original numeric form. Implementations should be able to correctly parse strings generated by theirIdConverter.asString(long)
method.- Specified by:
asLong
in interfaceIdConverter
- Parameters:
idString
- TheString
type ID to convert- Returns:
- The
long
representation of the ID
-
stat
Description copied from interface:IdConverter
Get statistical information about this converter.This method provides basic statistical information about the converter, including its implementation class name.
- Specified by:
stat
in interfaceIdConverter
- Specified by:
stat
in interfaceStatistical
- Returns:
- Statistical information about this converter
-