java.lang.Object
me.ahoo.cosid.codec.Radix
- All Implemented Interfaces:
IdCodec
Encodes non-negative ids in base 2 to 62 with the digits
0-9A-Za-z; replaces the 4.x
ToStringIdConverter, Radix36IdConverter and Radix62IdConverter (03-core-model.md ยง1).-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlongDecodes text produced byIdCodec.encode(long).encode(long id) Encodes an id (R1-core-16).longmaxValue()The largest id that fitswidth()digits, computed with integer arithmetic.static intmaxWidth(int radix) The digitsLong.MAX_VALUEtakes inradix: the widest a radix codec can be.static Radixof(int radix, int width, boolean padStart) A radix codec.booleanpadStart()intradix()intwidth()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.codec.IdCodec
withPrefix, withSuffix
-
Field Details
-
MIN_RADIX
public static final int MIN_RADIX- See Also:
-
MAX_RADIX
public static final int MAX_RADIX- See Also:
-
-
Method Details
-
of
A radix codec.- Parameters:
radix- the base, from 2 to 62width- the most digits an id takes, from 1 tomaxWidth(int)padStart- whether shorter ids are padded with leading zeros towidth- Returns:
- the codec
-
maxWidth
public static int maxWidth(int radix) The digitsLong.MAX_VALUEtakes inradix: the widest a radix codec can be.- Parameters:
radix- the base- Returns:
- the number of digits
-
radix
public int radix() -
width
public int width() -
padStart
public boolean padStart() -
maxValue
public long maxValue()The largest id that fitswidth()digits, computed with integer arithmetic.- Returns:
- the largest encodable id
-
encode
Description copied from interface:IdCodecEncodes an id (R1-core-16). -
decode
Description copied from interface:IdCodecDecodes text produced byIdCodec.encode(long).
-