Android Open Source - TextEncoder Decimal 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;
/*from  w  ww.jav a 2 s .  c  o  m*/
import java.util.Arrays;
import android.content.Context;

public class DecimalMessage extends Message {

    public DecimalMessage(byte[] inputArray) throws NumberFormatException {
        super(inputArray);
    }

    public DecimalMessage(String inputString, Context context) throws NumberFormatException {
        super(inputString, context);
        checkValid(getStringValuesArray());
        long[] tempArray = new long[getStringValuesArray().length];
        for (int i = 0; i < getStringValuesArray().length; i++) {
            tempArray[i] = Long.parseLong(getStringValuesArray()[i]);
        }
        setLongValuesArray(tempArray);
    }

    public DecimalMessage(long[] inputArray) {
        super(inputArray);
    }

    @Override
    public String toString() {
        return Arrays.toString(getLongValuesArray()).replaceAll("[^0-9\\s]","");
    }

    private boolean checkValid(String[] array) throws NumberFormatException {
        for (String s : array) {
            if (!s.matches("^[0-9]+$")) {
                throw new NumberFormatException(
                        getContext().getResources().getString(R.string.invalid_input_message));
            }
        }
        return true;
    }
}




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