|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectccs.utils.LongEncoder
public final class LongEncoder
Encodes a long as a string using a more compact representation (i.e. a higher
radix, actually base-64) than is available from the Long
class.
The output is as though the input were unsigned, and is not zero-padded. The algorithm
may be slower than that of Long.toString
.
This class is intended as a specialised helper for applications that have
to produce string representations of inconveniently large numbers for
cryptography-related purposes. For example, suppose you have a 160-bit hash
value; you could convert this into a string by splitting it into 3 longs
and encoding each into a StringBuilder with successive calls to
encode
. YMMV for other types of job; in particular, we don't
provide a parser.
Method Summary | |
---|---|
static java.lang.String |
encode(long x)
Encodes the supplied long and returns the result. |
static void |
encode(long x,
java.lang.StringBuilder sb)
Encodes the supplied long and appends the result onto the supplied StringBuilder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void encode(long x, java.lang.StringBuilder sb)
x
- The long to encode.sb
- The StringBuilder to append the output to.public static java.lang.String encode(long x)
x
- The long to encode.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |