Java Utililty Methods Encode

List of utility methods to do Encode

Description

The list of methods to do Encode are organized into topic(s).

Method

voidencodeUInt32(int value, OutputStream out)
encode U Int
byte[] tmp = new byte[4];
tmp[0] = (byte) ((value >>> 24) & 0xff);
tmp[1] = (byte) ((value >>> 16) & 0xff);
tmp[2] = (byte) ((value >>> 8) & 0xff);
tmp[3] = (byte) (value & 0xff);
out.write(tmp);
voidencodeUnknownString(String in, OutputStream os)
encode Unknown String
if (isPrintableString(in)) {
    encodePrintableString(in, os);
} else {
    encodeIA5String(in, os);
voidencodeUTCTime(long time, OutputStream os)
encode UTC Time
byte[] tbuf = new byte[13];
int offset = 0;
Date d = new Date(time);
TimeZone tz = TimeZone.getTimeZone("GMT");
Calendar cal = new GregorianCalendar(tz);
cal.setTime(d);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
...
StringencodeUtf8AsBase64(String data)
encode Utf As Base
return encodeAsBase64(decodeAsUtf8(data));
intencodeVarUInt32(int unsignedValue, OutputStream outputStream)
Encodes an unsigned uint32 value (represented as a signed int32 value) into a stream.
int length = 1;
if (unsignedValue >= 0x80 || unsignedValue < 0) {
    outputStream.write((byte) (unsignedValue | 0x80));
    unsignedValue >>>= 7;
    length = 2;
    if (unsignedValue >= 0x80) {
        outputStream.write((byte) (unsignedValue | 0x80));
        unsignedValue >>>= 7;
...
intencodeVarUInt64(long unsignedValue, OutputStream outputStream)
Encodes an unsigned uint64 value (represented as signed int64 value) into a stream.
int length = 1;
if (unsignedValue >= 0x80 || unsignedValue < 0) {
    outputStream.write((byte) (unsignedValue | 0x80));
    unsignedValue >>>= 7;
    length = 2;
    if (unsignedValue >= 0x80) {
        outputStream.write((byte) (unsignedValue | 0x80));
        unsignedValue >>>= 7;
...
StringencodeWikiTag(String s)
This is a variant of the encoder which employs the naming convention of Wikimedia, where every character but the first one is case sensitive
StringBuilder sb = null;
try {
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (isUnreserved(c)) {
            if (isLowecaseAlphabet(c) && i == 0) {
                c = capitalize(c);
                sb = new StringBuilder(s.length()); 
...
StringencodeXML(String input)
Encodes an input string of plain text to it's XML representation.
StringReader in = new StringReader(input);
StringBuffer out = new StringBuffer();
int ch;
try {
    while ((ch = in.read()) != -1) {
        if (ch < 127 && ch != '&' && ch != '<' && ch != '>' && ch != '"') {
            out.append((char) ch);
        } else {
...
voidencodeXMLString(String aString, PrintWriter aWriter)
encode XML String
int len = aString.length();
for (int i = 0; i < len; i++) {
    char ch = aString.charAt(i);
    switch (ch) {
    case '&':
        aWriter.print("&amp;");
        break;
    case '>':
...