Android Open Source - TextEncoder Message






From Project

Back to project page TextEncoder.

License

The source code is released under:

Apache License

If you think the Android project TextEncoder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.csab.TextEncoder;
/*  w  w  w .j av a2  s . c  o  m*/
import android.content.Context;

public class Message implements Converter<Message, Class> {

    private byte[] byteValuesArray;
    private long[] longValuesArray;
    private String[] stringValuesArray;
    private Context messageContext;

    public Message() { }

    public Message(byte[] inputArray) {
        byteValuesArray = inputArray;
        longValuesArray = new long[inputArray.length];
        for (int i = 0; i < longValuesArray.length; i++) {
            longValuesArray[i] = (long)inputArray[i];
        }
    }

    public Message(String inputString, Context context) {
        stringValuesArray = inputString.split("\\s+");
        messageContext = context;
    }

    public Message(long[] inputArray) {
        longValuesArray = inputArray;
    }

    public byte[] getByteValuesArray() {
        return byteValuesArray;
    }

    public void setByteValuesArray(byte[] updatedArray) {
        byteValuesArray = updatedArray;
    }

    public long[] getLongValuesArray() {
        return longValuesArray;
    }

    public void setLongValuesArray(long[] updatedArray) {
        longValuesArray = updatedArray;
    }

    public String[] getStringValuesArray() {
        return stringValuesArray;
    }

    public void setStringValuesArray(String[] updatedArray) {
        stringValuesArray = updatedArray;
    }

    public Context getContext() { return messageContext; }

    public <T> T convert(Class<T> clazz) throws Exception {
        return clazz.getConstructor(long[].class).newInstance(getLongValuesArray());
    }

    @Override
    public String toString() {
        return new String(byteValuesArray);
    }
}




Java Source Code List

com.csab.TextEncoder.AsciiMessage.java
com.csab.TextEncoder.Base64Message.java
com.csab.TextEncoder.BinaryMessage.java
com.csab.TextEncoder.Converter.java
com.csab.TextEncoder.DecimalMessage.java
com.csab.TextEncoder.HexMessage.java
com.csab.TextEncoder.MainActivity.java
com.csab.TextEncoder.Message.java
com.csab.TextEncoder.OctalMessage.java